[llvm-branch-commits] [BOLT][NFCI] Use heuristic for matching split global functions (PR #90429)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/90429 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [BOLT][NFCI] Use heuristic for matching split global functions (PR #90429)
llvmbot wrote: @llvm/pr-subscribers-bolt Author: Amir Ayupov (aaupov) Changes There should be no functional change, only faster fragment matching for large BOLTed binaries where all fragments of global parent functions are put under bolt-pseudo.o file symbol. Test Plan: NFC --- Full diff: https://github.com/llvm/llvm-project/pull/90429.diff 1 Files Affected: - (modified) bolt/lib/Rewrite/RewriteInstance.cpp (+5) ``diff diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp index 8eb2e5a9d9120a..d92775e16b7cf1 100644 --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -1511,6 +1511,11 @@ void RewriteInstance::registerFragments() { uint64_t ParentAddress{0}; +// Check if containing FILE symbol is BOLT emitted synthetic symbol marking +// local fragments of global parents. +if (cantFail(FSI[-1].getName()) == getBOLTFileSymbolName()) + goto registerParent; + // BOLT split fragment symbols are emitted just before the main function // symbol. for (ELFSymbolRef NextSymbol = Symbol; NextSymbol < StopSymbol; `` https://github.com/llvm/llvm-project/pull/90429 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [BOLT][NFCI] Use heuristic for matching split global functions (PR #90429)
https://github.com/aaupov created https://github.com/llvm/llvm-project/pull/90429 There should be no functional change, only faster fragment matching for large BOLTed binaries where all fragments of global parent functions are put under bolt-pseudo.o file symbol. Test Plan: NFC ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [BOLT] Use heuristic for matching split local functions (PR #90424)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/90424 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [BOLT] Use heuristic for matching split local functions (PR #90424)
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/90424 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [BOLT] Use heuristic for matching split local functions (PR #90424)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/90424 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [BOLT] Use heuristic for matching BOLT split functions (PR #90424)
llvmbot wrote: @llvm/pr-subscribers-bolt Author: Amir Ayupov (aaupov) Changes Use known order of BOLT split function symbols: fragment symbols immediately precede the parent fragment symbol. Depends On: https://github.com/llvm/llvm-project/pull/89648 Test Plan: updated cdsplit-symbol-names.s --- Full diff: https://github.com/llvm/llvm-project/pull/90424.diff 2 Files Affected: - (modified) bolt/lib/Rewrite/RewriteInstance.cpp (+21) - (modified) bolt/test/X86/cdsplit-symbol-names.s (+13-2) ``diff diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp index d08c760f4da18d..8eb2e5a9d9120a 100644 --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -1510,6 +1510,26 @@ void RewriteInstance::registerFragments() { StopSymbol = *FSI; uint64_t ParentAddress{0}; + +// BOLT split fragment symbols are emitted just before the main function +// symbol. +for (ELFSymbolRef NextSymbol = Symbol; NextSymbol < StopSymbol; + NextSymbol.moveNext()) { + Expected NameOrError = Symbol.getName(); + if (!NameOrError) +break; + StringRef Name = *NameOrError; + if (Name == ParentName) { +ParentAddress = cantFail(NextSymbol.getValue()); +goto registerParent; + } + if (Name.starts_with(ParentName)) +// With multi-way splitting, there are multiple fragments with different +// suffixes. Parent follows the last fragment. +continue; + break; +} + // Iterate over local file symbols and check symbol names to match parent. for (ELFSymbolRef Symbol(FSI[-1]); Symbol < StopSymbol; Symbol.moveNext()) { if (cantFail(Symbol.getName()) == ParentName) { @@ -1518,6 +1538,7 @@ void RewriteInstance::registerFragments() { } } +registerParent: // No local parent is found, use global parent function. if (!ParentAddress) if (BinaryData *ParentBD = BC->getBinaryDataByName(ParentName)) diff --git a/bolt/test/X86/cdsplit-symbol-names.s b/bolt/test/X86/cdsplit-symbol-names.s index e53863e22246d6..1d3fa91936af04 100644 --- a/bolt/test/X86/cdsplit-symbol-names.s +++ b/bolt/test/X86/cdsplit-symbol-names.s @@ -7,7 +7,7 @@ # RUN: llvm-strip --strip-unneeded %t.o # RUN: %clang %cflags %t.o -o %t.exe -Wl,-q # RUN: llvm-bolt %t.exe -o %t.bolt --split-functions --split-strategy=cdsplit \ -# RUN: --call-scale=2 --data=%t.fdata --reorder-blocks=ext-tsp +# RUN: --call-scale=2 --data=%t.fdata --reorder-blocks=ext-tsp --enable-bat # RUN: llvm-objdump --syms %t.bolt | FileCheck %s --check-prefix=CHECK-SYMS-WARM # CHECK-SYMS-WARM: l df *ABS* bolt-pseudo.o @@ -16,8 +16,19 @@ # CHECK-SYMS-WARM: .text.cold # CHECK-SYMS-WARM-SAME: dummy.cold +# RUN: link_fdata %s %t.bolt %t.preagg PREAGG +# PREAGG: B X:0 #chain.warm# 1 0 +# RUN: perf2bolt %t.bolt -p %t.preagg --pa -o %t.bat.fdata -w %t.bat.yaml -v=1 \ +# RUN: | FileCheck %s --check-prefix=CHECK-REGISTER + +# CHECK-REGISTER: BOLT-INFO: marking chain.warm/1(*2) as a fragment of chain/2(*2) + .text -.globl chain +.type chain, @function +chain: +ret +.size chain, .-chain + .type chain, @function chain: pushq %rbp `` https://github.com/llvm/llvm-project/pull/90424 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [BOLT] Use heuristic for matching BOLT split functions (PR #90424)
https://github.com/aaupov created https://github.com/llvm/llvm-project/pull/90424 Use known order of BOLT split function symbols: fragment symbols immediately precede the parent fragment symbol. Depends On: https://github.com/llvm/llvm-project/pull/89648 Test Plan: updated cdsplit-symbol-names.s ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [IRCE] Skip icmp ptr in `InductiveRangeCheck::parseRangeCheckICmp` (#89967) (PR #90182)
https://github.com/nikic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/90182 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [X86][EVEX512] Check hasEVEX512 for canExtendTo512DQ (#90390) (PR #90422)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: None (llvmbot) Changes Backport 35b89dda2b9734917824b1457f149192669b314c Requested by: @phoebewang --- Full diff: https://github.com/llvm/llvm-project/pull/90422.diff 2 Files Affected: - (modified) llvm/lib/Target/X86/X86Subtarget.h (+2-1) - (modified) llvm/test/CodeGen/X86/avx512bwvl-arith.ll (+33-2) ``diff diff --git a/llvm/lib/Target/X86/X86Subtarget.h b/llvm/lib/Target/X86/X86Subtarget.h index a458b5f9ec8fbb..4d55a084b730e4 100644 --- a/llvm/lib/Target/X86/X86Subtarget.h +++ b/llvm/lib/Target/X86/X86Subtarget.h @@ -244,7 +244,8 @@ class X86Subtarget final : public X86GenSubtargetInfo { // TODO: Currently we're always allowing widening on CPUs without VLX, // because for many cases we don't have a better option. bool canExtendTo512DQ() const { -return hasAVX512() && (!hasVLX() || getPreferVectorWidth() >= 512); +return hasAVX512() && hasEVEX512() && + (!hasVLX() || getPreferVectorWidth() >= 512); } bool canExtendTo512BW() const { return hasBWI() && canExtendTo512DQ(); diff --git a/llvm/test/CodeGen/X86/avx512bwvl-arith.ll b/llvm/test/CodeGen/X86/avx512bwvl-arith.ll index 4988fc35b10eef..fdc25f44b156a7 100644 --- a/llvm/test/CodeGen/X86/avx512bwvl-arith.ll +++ b/llvm/test/CodeGen/X86/avx512bwvl-arith.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512bw,+avx512vl | FileCheck %s -; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512bw,+avx512vl,-evex512 | FileCheck %s +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512bw,+avx512vl | FileCheck %s --check-prefixes=CHECK,EVEX256 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512bw,+avx512vl,-evex512 | FileCheck %s --check-prefixes=CHECK,EVEX512 ; 256-bit @@ -236,3 +236,34 @@ define <8 x i16> @vpmullw128_test(<8 x i16> %i, <8 x i16> %j) { ret <8 x i16> %x } +define i16 @PR90356(<16 x i1> %a) { +; EVEX256-LABEL: PR90356: +; EVEX256: # %bb.0: +; EVEX256-NEXT:vpsllw $7, %xmm0, %xmm0 +; EVEX256-NEXT:vpmovb2m %xmm0, %k1 +; EVEX256-NEXT:vpternlogd $255, %zmm0, %zmm0, %zmm0 {%k1} {z} +; EVEX256-NEXT:movb $63, %al +; EVEX256-NEXT:kmovd %eax, %k1 +; EVEX256-NEXT:vpexpandq %zmm0, %zmm0 {%k1} {z} +; EVEX256-NEXT:vptestmd %zmm0, %zmm0, %k0 +; EVEX256-NEXT:kmovd %k0, %eax +; EVEX256-NEXT:# kill: def $ax killed $ax killed $eax +; EVEX256-NEXT:vzeroupper +; EVEX256-NEXT:retq +; +; EVEX512-LABEL: PR90356: +; EVEX512: # %bb.0: +; EVEX512-NEXT:vpsllw $7, %xmm0, %xmm0 +; EVEX512-NEXT:vpmovb2m %xmm0, %k0 +; EVEX512-NEXT:vpmovm2w %k0, %ymm0 +; EVEX512-NEXT:vpxor %xmm1, %xmm1, %xmm1 +; EVEX512-NEXT:vpblendd {{.*#+}} ymm0 = ymm0[0,1,2,3,4,5],ymm1[6,7] +; EVEX512-NEXT:vpmovw2m %ymm0, %k0 +; EVEX512-NEXT:kmovd %k0, %eax +; EVEX512-NEXT:# kill: def $ax killed $ax killed $eax +; EVEX512-NEXT:vzeroupper +; EVEX512-NEXT:retq + %1 = shufflevector <16 x i1> %a, <16 x i1> zeroinitializer, <16 x i32> + %2 = bitcast <16 x i1> %1 to i16 + ret i16 %2 +} `` https://github.com/llvm/llvm-project/pull/90422 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [X86][EVEX512] Check hasEVEX512 for canExtendTo512DQ (#90390) (PR #90422)
llvmbot wrote: @RKSimon What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/90422 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [X86][EVEX512] Check hasEVEX512 for canExtendTo512DQ (#90390) (PR #90422)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/90422 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/18.x: [X86][EVEX512] Check hasEVEX512 for canExtendTo512DQ (#90390) (PR #90422)
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/90422 Backport 35b89dda2b9734917824b1457f149192669b314c Requested by: @phoebewang >From 7100664b68f5c38c2b163a8927a268a7c6ab91ae Mon Sep 17 00:00:00 2001 From: Phoebe Wang Date: Mon, 29 Apr 2024 08:40:26 +0800 Subject: [PATCH] [X86][EVEX512] Check hasEVEX512 for canExtendTo512DQ (#90390) Fixes #90356 (cherry picked from commit 35b89dda2b9734917824b1457f149192669b314c) --- llvm/lib/Target/X86/X86Subtarget.h| 3 +- llvm/test/CodeGen/X86/avx512bwvl-arith.ll | 35 +-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/X86/X86Subtarget.h b/llvm/lib/Target/X86/X86Subtarget.h index a458b5f9ec8fbb..4d55a084b730e4 100644 --- a/llvm/lib/Target/X86/X86Subtarget.h +++ b/llvm/lib/Target/X86/X86Subtarget.h @@ -244,7 +244,8 @@ class X86Subtarget final : public X86GenSubtargetInfo { // TODO: Currently we're always allowing widening on CPUs without VLX, // because for many cases we don't have a better option. bool canExtendTo512DQ() const { -return hasAVX512() && (!hasVLX() || getPreferVectorWidth() >= 512); +return hasAVX512() && hasEVEX512() && + (!hasVLX() || getPreferVectorWidth() >= 512); } bool canExtendTo512BW() const { return hasBWI() && canExtendTo512DQ(); diff --git a/llvm/test/CodeGen/X86/avx512bwvl-arith.ll b/llvm/test/CodeGen/X86/avx512bwvl-arith.ll index 4988fc35b10eef..fdc25f44b156a7 100644 --- a/llvm/test/CodeGen/X86/avx512bwvl-arith.ll +++ b/llvm/test/CodeGen/X86/avx512bwvl-arith.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512bw,+avx512vl | FileCheck %s -; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512bw,+avx512vl,-evex512 | FileCheck %s +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512bw,+avx512vl | FileCheck %s --check-prefixes=CHECK,EVEX256 +; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx512bw,+avx512vl,-evex512 | FileCheck %s --check-prefixes=CHECK,EVEX512 ; 256-bit @@ -236,3 +236,34 @@ define <8 x i16> @vpmullw128_test(<8 x i16> %i, <8 x i16> %j) { ret <8 x i16> %x } +define i16 @PR90356(<16 x i1> %a) { +; EVEX256-LABEL: PR90356: +; EVEX256: # %bb.0: +; EVEX256-NEXT:vpsllw $7, %xmm0, %xmm0 +; EVEX256-NEXT:vpmovb2m %xmm0, %k1 +; EVEX256-NEXT:vpternlogd $255, %zmm0, %zmm0, %zmm0 {%k1} {z} +; EVEX256-NEXT:movb $63, %al +; EVEX256-NEXT:kmovd %eax, %k1 +; EVEX256-NEXT:vpexpandq %zmm0, %zmm0 {%k1} {z} +; EVEX256-NEXT:vptestmd %zmm0, %zmm0, %k0 +; EVEX256-NEXT:kmovd %k0, %eax +; EVEX256-NEXT:# kill: def $ax killed $ax killed $eax +; EVEX256-NEXT:vzeroupper +; EVEX256-NEXT:retq +; +; EVEX512-LABEL: PR90356: +; EVEX512: # %bb.0: +; EVEX512-NEXT:vpsllw $7, %xmm0, %xmm0 +; EVEX512-NEXT:vpmovb2m %xmm0, %k0 +; EVEX512-NEXT:vpmovm2w %k0, %ymm0 +; EVEX512-NEXT:vpxor %xmm1, %xmm1, %xmm1 +; EVEX512-NEXT:vpblendd {{.*#+}} ymm0 = ymm0[0,1,2,3,4,5],ymm1[6,7] +; EVEX512-NEXT:vpmovw2m %ymm0, %k0 +; EVEX512-NEXT:kmovd %k0, %eax +; EVEX512-NEXT:# kill: def $ax killed $ax killed $eax +; EVEX512-NEXT:vzeroupper +; EVEX512-NEXT:retq + %1 = shufflevector <16 x i1> %a, <16 x i1> zeroinitializer, <16 x i32> + %2 = bitcast <16 x i1> %1 to i16 + ret i16 %2 +} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone::to_sys. (PR #90394)
https://github.com/mordante updated https://github.com/llvm/llvm-project/pull/90394 >From e0f5f099af76108a1b3de6b2735e084047e029c0 Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Wed, 17 Apr 2024 21:00:22 +0200 Subject: [PATCH] [libc++][TZDB] Implements time_zone::to_sys. This implements the throwing overload and the exception classes throw by this overload. Implements parts of: - P0355 Extending chrono to Calendars and Time Zones --- libcxx/include/CMakeLists.txt | 1 + libcxx/include/__chrono/exception.h | 129 ++ libcxx/include/__chrono/time_zone.h | 26 ++ libcxx/include/chrono | 9 + libcxx/include/module.modulemap | 6 +- libcxx/modules/std/chrono.inc | 2 - libcxx/src/CMakeLists.txt | 3 + libcxx/src/chrono_exception.cpp | 20 ++ .../assert.ctor.pass.cpp | 53 .../assert.ctor.pass.cpp | 53 .../time.zone.members/assert.to_sys.pass.cpp | 39 +++ .../test/libcxx/transitive_includes/cxx03.csv | 3 - .../test/libcxx/transitive_includes/cxx11.csv | 3 - .../test/libcxx/transitive_includes/cxx14.csv | 3 - .../test/libcxx/transitive_includes/cxx17.csv | 3 - .../test/libcxx/transitive_includes/cxx20.csv | 8 +- .../test/libcxx/transitive_includes/cxx23.csv | 12 +- .../test/libcxx/transitive_includes/cxx26.csv | 12 +- .../time.zone.exception.ambig/ctor.pass.cpp | 171 + .../types.compile.pass.cpp| 31 +++ .../ctor.pass.cpp | 172 + .../types.compile.pass.cpp| 31 +++ .../time.zone.members/to_sys.pass.cpp | 237 ++ 23 files changed, 983 insertions(+), 44 deletions(-) create mode 100644 libcxx/include/__chrono/exception.h create mode 100644 libcxx/src/chrono_exception.cpp create mode 100644 libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.ambig/assert.ctor.pass.cpp create mode 100644 libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.nonexist/assert.ctor.pass.cpp create mode 100644 libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/assert.to_sys.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/ctor.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/types.compile.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/ctor.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/types.compile.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/to_sys.pass.cpp diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 1296c536bc882c..386bd967eed7ab 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -264,6 +264,7 @@ set(files __chrono/convert_to_tm.h __chrono/day.h __chrono/duration.h + __chrono/exception.h __chrono/file_clock.h __chrono/formatter.h __chrono/hh_mm_ss.h diff --git a/libcxx/include/__chrono/exception.h b/libcxx/include/__chrono/exception.h new file mode 100644 index 00..fa9e0cf90e5d96 --- /dev/null +++ b/libcxx/include/__chrono/exception.h @@ -0,0 +1,129 @@ +// -*- C++ -*- +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html + +#ifndef _LIBCPP___CHRONO_EXCEPTION_H +#define _LIBCPP___CHRONO_EXCEPTION_H + +#include +// Enable the contents of the header only when libc++ was built with experimental features enabled. +#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) + +# include <__availability> +# include <__chrono/calendar.h> +# include <__chrono/local_info.h> +# include <__chrono/time_point.h> +# include <__config> +# include <__verbose_abort> +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +# endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +# if _LIBCPP_STD_VER >= 20 + +namespace chrono { + +class nonexistent_local_time : public runtime_error { +public: + template + _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const local_time<_Duration>& __time, const local_info& __info) + : runtime_error{__create_message(__time, __info)} { +// [time.zone.exception.nonexist]/2 +// Preconditions: i.result == local_info::nonexistent is true. +// The value of
[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone::to_sys. (PR #90394)
https://github.com/mordante updated https://github.com/llvm/llvm-project/pull/90394 >From c0cdd074a1e22c3d35f2e235cfd6f0bf74b406dc Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Wed, 17 Apr 2024 21:00:22 +0200 Subject: [PATCH] [libc++][TZDB] Implements time_zone::to_sys. This implements the throwing overload and the exception classes throw by this overload. Implements parts of: - P0355 Extending chrono to Calendars and Time Zones --- libcxx/include/CMakeLists.txt | 1 + libcxx/include/__chrono/exception.h | 129 ++ libcxx/include/__chrono/time_zone.h | 26 ++ libcxx/include/chrono | 9 + libcxx/include/module.modulemap | 6 +- libcxx/modules/std/chrono.inc | 2 - libcxx/src/CMakeLists.txt | 3 + libcxx/src/chrono_exception.cpp | 20 ++ .../assert.ctor.pass.cpp | 53 .../assert.ctor.pass.cpp | 53 .../time.zone.members/assert.to_sys.pass.cpp | 39 +++ .../test/libcxx/transitive_includes/cxx03.csv | 3 - .../test/libcxx/transitive_includes/cxx11.csv | 3 - .../test/libcxx/transitive_includes/cxx14.csv | 3 - .../test/libcxx/transitive_includes/cxx17.csv | 3 - .../test/libcxx/transitive_includes/cxx20.csv | 8 +- .../test/libcxx/transitive_includes/cxx23.csv | 12 +- .../test/libcxx/transitive_includes/cxx26.csv | 12 +- .../time.zone.exception.ambig/ctor.pass.cpp | 169 + .../types.compile.pass.cpp| 31 +++ .../ctor.pass.cpp | 170 + .../types.compile.pass.cpp| 31 +++ .../time.zone.members/to_sys.pass.cpp | 237 ++ 23 files changed, 979 insertions(+), 44 deletions(-) create mode 100644 libcxx/include/__chrono/exception.h create mode 100644 libcxx/src/chrono_exception.cpp create mode 100644 libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.ambig/assert.ctor.pass.cpp create mode 100644 libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.nonexist/assert.ctor.pass.cpp create mode 100644 libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/assert.to_sys.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/ctor.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/types.compile.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/ctor.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/types.compile.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/to_sys.pass.cpp diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 1296c536bc882c..386bd967eed7ab 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -264,6 +264,7 @@ set(files __chrono/convert_to_tm.h __chrono/day.h __chrono/duration.h + __chrono/exception.h __chrono/file_clock.h __chrono/formatter.h __chrono/hh_mm_ss.h diff --git a/libcxx/include/__chrono/exception.h b/libcxx/include/__chrono/exception.h new file mode 100644 index 00..fa9e0cf90e5d96 --- /dev/null +++ b/libcxx/include/__chrono/exception.h @@ -0,0 +1,129 @@ +// -*- C++ -*- +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html + +#ifndef _LIBCPP___CHRONO_EXCEPTION_H +#define _LIBCPP___CHRONO_EXCEPTION_H + +#include +// Enable the contents of the header only when libc++ was built with experimental features enabled. +#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) + +# include <__availability> +# include <__chrono/calendar.h> +# include <__chrono/local_info.h> +# include <__chrono/time_point.h> +# include <__config> +# include <__verbose_abort> +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +# endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +# if _LIBCPP_STD_VER >= 20 + +namespace chrono { + +class nonexistent_local_time : public runtime_error { +public: + template + _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const local_time<_Duration>& __time, const local_info& __info) + : runtime_error{__create_message(__time, __info)} { +// [time.zone.exception.nonexist]/2 +// Preconditions: i.result == local_info::nonexistent is true. +// The value of
[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone::to_sys. (PR #90394)
llvmbot wrote: @llvm/pr-subscribers-libcxx Author: Mark de Wever (mordante) Changes This implements the throwing overload and the exception classes throw by this overload. Implements parts of: - P0355 Extending chrono to Calendars and Time Zones --- Patch is 44.82 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/90394.diff 16 Files Affected: - (modified) libcxx/include/CMakeLists.txt (+1) - (added) libcxx/include/__chrono/exception.h (+128) - (modified) libcxx/include/__chrono/time_zone.h (+25) - (modified) libcxx/include/chrono (+9) - (modified) libcxx/include/module.modulemap (+1) - (modified) libcxx/modules/std/chrono.inc (-2) - (modified) libcxx/src/CMakeLists.txt (+3) - (added) libcxx/src/chrono_exception.cpp (+20) - (added) libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.ambig/assert.ctor.pass.cpp (+53) - (added) libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.nonexist/assert.ctor.pass.cpp (+53) - (added) libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/assert.to_sys.pass.cpp (+39) - (added) libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/ctor.pass.cpp (+169) - (added) libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/types.compile.pass.cpp (+31) - (added) libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/ctor.pass.cpp (+170) - (added) libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/types.compile.pass.cpp (+31) - (added) libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/to_sys.pass.cpp (+237) ``diff diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 1296c536bc882c..386bd967eed7ab 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -264,6 +264,7 @@ set(files __chrono/convert_to_tm.h __chrono/day.h __chrono/duration.h + __chrono/exception.h __chrono/file_clock.h __chrono/formatter.h __chrono/hh_mm_ss.h diff --git a/libcxx/include/__chrono/exception.h b/libcxx/include/__chrono/exception.h new file mode 100644 index 00..ca0acecf151ba9 --- /dev/null +++ b/libcxx/include/__chrono/exception.h @@ -0,0 +1,128 @@ +// -*- C++ -*- +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html + +#ifndef _LIBCPP___CHRONO_EXCEPTION_H +#define _LIBCPP___CHRONO_EXCEPTION_H + +#include +// Enable the contents of the header only when libc++ was built with experimental features enabled. +#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) + +# include <__availability> +# include <__chrono/calendar.h> +# include <__chrono/local_info.h> +# include <__config> +# include <__verbose_abort> +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +# endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +# if _LIBCPP_STD_VER >= 20 + +namespace chrono { + +class nonexistent_local_time : public runtime_error { +public: + template + _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const local_time<_Duration>& __time, const local_info& __info) + : runtime_error{__create_message(__time, __info)} { +// [time.zone.exception.nonexist]/2 +// Preconditions: i.result == local_info::nonexistent is true. +// The value of __info.result is not used. +_LIBCPP_ASSERT_PEDANTIC(__info.result == local_info::nonexistent, +"creating an nonexistent_local_time from a local_info that is not non-existent"); + } + + _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI ~nonexistent_local_time() override; // exported as key function + +private: + template + _LIBCPP_HIDE_FROM_ABI string __create_message(const local_time<_Duration>& __time, const local_info& __info) { +return std::format( +R"({} is in a gap between +{} {} and +{} {} which are both equivalent to +{} UTC)", +__time, +local_seconds{__info.first.end.time_since_epoch()} + __info.first.offset, +__info.first.abbrev, +local_seconds{__info.second.begin.time_since_epoch()} + __info.second.offset, +__info.second.abbrev, +__info.first.end); + } +}; + +template +_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_nonexistent_local_time( +[[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) { +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS + throw nonexistent_local_time(__time, __info); +#else +
[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements time_zone::to_sys. (PR #90394)
https://github.com/mordante created https://github.com/llvm/llvm-project/pull/90394 This implements the throwing overload and the exception classes throw by this overload. Implements parts of: - P0355 Extending chrono to Calendars and Time Zones >From e722747d35b87cbcf8e12847c799f87a6082bb73 Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Wed, 17 Apr 2024 21:00:22 +0200 Subject: [PATCH] [libc++][TZDB] Implements time_zone::to_sys. This implements the throwing overload and the exception classes throw by this overload. Implements parts of: - P0355 Extending chrono to Calendars and Time Zones --- libcxx/include/CMakeLists.txt | 1 + libcxx/include/__chrono/exception.h | 128 ++ libcxx/include/__chrono/time_zone.h | 25 ++ libcxx/include/chrono | 9 + libcxx/include/module.modulemap | 1 + libcxx/modules/std/chrono.inc | 2 - libcxx/src/CMakeLists.txt | 3 + libcxx/src/chrono_exception.cpp | 20 ++ .../assert.ctor.pass.cpp | 53 .../assert.ctor.pass.cpp | 53 .../time.zone.members/assert.to_sys.pass.cpp | 39 +++ .../time.zone.exception.ambig/ctor.pass.cpp | 169 + .../types.compile.pass.cpp| 31 +++ .../ctor.pass.cpp | 170 + .../types.compile.pass.cpp| 31 +++ .../time.zone.members/to_sys.pass.cpp | 237 ++ 16 files changed, 970 insertions(+), 2 deletions(-) create mode 100644 libcxx/include/__chrono/exception.h create mode 100644 libcxx/src/chrono_exception.cpp create mode 100644 libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.ambig/assert.ctor.pass.cpp create mode 100644 libcxx/test/libcxx/time/time.zone/time.zone.exception/time.zone.exception.nonexist/assert.ctor.pass.cpp create mode 100644 libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/assert.to_sys.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/ctor.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.ambig/types.compile.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/ctor.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.exception/time.zone.exception.nonexist/types.compile.pass.cpp create mode 100644 libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/to_sys.pass.cpp diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 1296c536bc882c..386bd967eed7ab 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -264,6 +264,7 @@ set(files __chrono/convert_to_tm.h __chrono/day.h __chrono/duration.h + __chrono/exception.h __chrono/file_clock.h __chrono/formatter.h __chrono/hh_mm_ss.h diff --git a/libcxx/include/__chrono/exception.h b/libcxx/include/__chrono/exception.h new file mode 100644 index 00..ca0acecf151ba9 --- /dev/null +++ b/libcxx/include/__chrono/exception.h @@ -0,0 +1,128 @@ +// -*- C++ -*- +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html + +#ifndef _LIBCPP___CHRONO_EXCEPTION_H +#define _LIBCPP___CHRONO_EXCEPTION_H + +#include +// Enable the contents of the header only when libc++ was built with experimental features enabled. +#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) + +# include <__availability> +# include <__chrono/calendar.h> +# include <__chrono/local_info.h> +# include <__config> +# include <__verbose_abort> +# include +# include +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +# endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +# if _LIBCPP_STD_VER >= 20 + +namespace chrono { + +class nonexistent_local_time : public runtime_error { +public: + template + _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const local_time<_Duration>& __time, const local_info& __info) + : runtime_error{__create_message(__time, __info)} { +// [time.zone.exception.nonexist]/2 +// Preconditions: i.result == local_info::nonexistent is true. +// The value of __info.result is not used. +_LIBCPP_ASSERT_PEDANTIC(__info.result == local_info::nonexistent, +"creating an nonexistent_local_time from a local_info that is not non-existent"); + } + + _LIBCPP_AVAILABILITY_TZDB
[llvm-branch-commits] [libcxx] [libc++][chrono] implements UTC clock. (PR #90393)
llvmbot wrote: @llvm/pr-subscribers-libcxx Author: Mark de Wever (mordante) Changes While implementing this feature and its associated LWG issues it turns out - LWG3316 Correctly define epoch for utc_clock / utc_timepoint only added non-normative wording to the standard. Implements parts of: - P0355 Extending chrono to Calendars and Time Zones - P1361 Integration of chrono with text formatting - LWG3359 chrono leap second support should allow for negative leap seconds --- Patch is 115.96 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/90393.diff 26 Files Affected: - (modified) libcxx/benchmarks/CMakeLists.txt (+1) - (added) libcxx/benchmarks/utc_clock.bench.cpp (+54) - (modified) libcxx/docs/Status/Cxx20.rst (+1-1) - (modified) libcxx/docs/Status/Cxx20Issues.csv (+1-1) - (modified) libcxx/docs/Status/FormatPaper.csv (+1-1) - (modified) libcxx/include/CMakeLists.txt (+1) - (modified) libcxx/include/__chrono/convert_to_tm.h (+18) - (modified) libcxx/include/__chrono/formatter.h (+18) - (modified) libcxx/include/__chrono/ostream.h (+12) - (added) libcxx/include/__chrono/utc_clock.h (+155) - (modified) libcxx/include/chrono (+38) - (modified) libcxx/include/module.modulemap (+4) - (modified) libcxx/modules/std/chrono.inc (+10-2) - (modified) libcxx/test/libcxx/diagnostics/chrono.nodiscard.verify.cpp (+14) - (added) libcxx/test/libcxx/time/time.clock/time.clock.utc/get_leap_second_info.pass.cpp (+124) - (added) libcxx/test/libcxx/time/time.clock/time.clock.utc/time.clock.utc.members/from_sys.pass.cpp (+106) - (added) libcxx/test/libcxx/time/time.clock/time.clock.utc/time.clock.utc.members/to_sys.pass.cpp (+115) - (added) libcxx/test/std/time/time.clock/time.clock.utc/get_leap_second_info.pass.cpp (+126) - (added) libcxx/test/std/time/time.clock/time.clock.utc/leap_second_info.members.pass.cpp (+37) - (added) libcxx/test/std/time/time.clock/time.clock.utc/time.clock.utc.members/from_sys.pass.cpp (+213) - (added) libcxx/test/std/time/time.clock/time.clock.utc/time.clock.utc.members/now.pass.cpp (+30) - (added) libcxx/test/std/time/time.clock/time.clock.utc/time.clock.utc.members/to_sys.pass.cpp (+147) - (added) libcxx/test/std/time/time.clock/time.clock.utc/types.compile.pass.cpp (+59) - (added) libcxx/test/std/time/time.clock/time.clock.utc/utc_time.ostream.pass.cpp (+165) - (added) libcxx/test/std/time/time.syn/formatter.utc_time.pass.cpp (+1004) - (modified) libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp (+1-1) ``diff diff --git a/libcxx/benchmarks/CMakeLists.txt b/libcxx/benchmarks/CMakeLists.txt index 527a2acf2d3b36..ea7ef6902f7266 100644 --- a/libcxx/benchmarks/CMakeLists.txt +++ b/libcxx/benchmarks/CMakeLists.txt @@ -229,6 +229,7 @@ set(BENCHMARK_TESTS system_error.bench.cpp to_chars.bench.cpp unordered_set_operations.bench.cpp +utc_clock.bench.cpp util_smartptr.bench.cpp variant_visit_1.bench.cpp variant_visit_2.bench.cpp diff --git a/libcxx/benchmarks/utc_clock.bench.cpp b/libcxx/benchmarks/utc_clock.bench.cpp new file mode 100644 index 00..255b1dde52aa67 --- /dev/null +++ b/libcxx/benchmarks/utc_clock.bench.cpp @@ -0,0 +1,54 @@ +//===--===// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include + +#include "benchmark/benchmark.h" + +// Benchmarks the performance of the UTC <-> system time conversions. These +// operations determine the sum of leap second insertions at a specific time. + +static void BM_from_sys(benchmark::State& state) { + std::chrono::sys_days date{std::chrono::July / 1 / state.range(0)}; + for (auto _ : state) +benchmark::DoNotOptimize(std::chrono::utc_clock::from_sys(date)); +} + +BENCHMARK(BM_from_sys) +->Arg(1970) // before the first leap seconds +->Arg(1979) // in the first half of inserted leap seconds +->Arg(1993) // in the second half of inserted leap seconds +->Arg(2100); // after the last leap second + +BENCHMARK(BM_from_sys)->Arg(1970)->Arg(1979)->Arg(1993)->Arg(2100)->Threads(4); +BENCHMARK(BM_from_sys)->Arg(1970)->Arg(1979)->Arg(1993)->Arg(2100)->Threads(16); + +static void BM_to_sys(benchmark::State& state) { + // 59 sec offset means we pass th UTC offset for the leap second; assuming + // there won't be more than 59 leap seconds ever. + std::chrono::utc_seconds date{ + std::chrono::sys_days{std::chrono::July / 1 / state.range(0)}.time_since_epoch() + std::chrono::seconds{59}}; + for (auto _ : state) +benchmark::DoNotOptimize(std::chrono::utc_clock::to_sys(date)); +} + +BENCHMARK(BM_to_sys) +->Arg(1970) // before