From dac3aaf9e1279f6096f3d356012dbb1de44ff230 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Sun, 28 Sep 2025 21:36:03 +0800 Subject: [PATCH 1/7] [CodeGen] Get rid of incorrect `std` template specializations (#160804) This patch renames comparators - from `std::equal_to` to `llvm::rdf::RegisterRefEqualTo`, and - from `std::less` to `llvm::rdf::RegisterRefLess`. The original specializations don't satisfy the requirements for the original `std` templates by being stateful and non-default-constructible, so they make the program have UB due to C++17 [namespace.std]/2, C++20/23 [namespace.std]/5. > A program may explicitly instantiate a class template defined in the standard library only if the declaration > - depends on the name of at least one program-defined type, and > - the instantiation meets the standard library requirements for the original template. Backport of https://github.com/llvm/llvm-project/commit/a558d656043734cc4d02e0a0a12e4c308c28f8c7 (cherry picked from commit 3e7b8ddeae70a269cfd89b781b00236fa083c255) --- .../llvm/include/llvm/CodeGen/RDFGraph.h | 2 +- .../llvm/include/llvm/CodeGen/RDFRegisters.h | 54 ++++++++++--------- .../llvm/lib/CodeGen/RDFLiveness.cpp | 9 ++-- .../llvm/lib/Target/Hexagon/RDFCopy.cpp | 2 +- .../llvm/lib/Target/Hexagon/RDFCopy.h | 8 +-- 5 files changed, 39 insertions(+), 36 deletions(-) diff --git a/interpreter/llvm-project/llvm/include/llvm/CodeGen/RDFGraph.h b/interpreter/llvm-project/llvm/include/llvm/CodeGen/RDFGraph.h index cf7344e8c3e74..30c38da96c112 100644 --- a/interpreter/llvm-project/llvm/include/llvm/CodeGen/RDFGraph.h +++ b/interpreter/llvm-project/llvm/include/llvm/CodeGen/RDFGraph.h @@ -447,7 +447,7 @@ struct NodeAllocator { AllocatorTy MemPool; }; -using RegisterSet = std::set; +using RegisterSet = std::set; struct TargetOperandInfo { TargetOperandInfo(const TargetInstrInfo &tii) : TII(tii) {} diff --git a/interpreter/llvm-project/llvm/include/llvm/CodeGen/RDFRegisters.h b/interpreter/llvm-project/llvm/include/llvm/CodeGen/RDFRegisters.h index 7eed0b4e1e7b8..c5060f00a0889 100644 --- a/interpreter/llvm-project/llvm/include/llvm/CodeGen/RDFRegisters.h +++ b/interpreter/llvm-project/llvm/include/llvm/CodeGen/RDFRegisters.h @@ -201,6 +201,33 @@ struct PhysicalRegisterInfo { std::vector AliasInfos; }; +struct RegisterRefEqualTo { + constexpr RegisterRefEqualTo(const llvm::rdf::PhysicalRegisterInfo &pri) + : PRI(&pri) {} + + bool operator()(llvm::rdf::RegisterRef A, llvm::rdf::RegisterRef B) const { + return PRI->equal_to(A, B); + } + +private: + // Make it a pointer just in case. See comment in `RegisterRefLess` below. + const llvm::rdf::PhysicalRegisterInfo *PRI; +}; + +struct RegisterRefLess { + constexpr RegisterRefLess(const llvm::rdf::PhysicalRegisterInfo &pri) + : PRI(&pri) {} + + bool operator()(llvm::rdf::RegisterRef A, llvm::rdf::RegisterRef B) const { + return PRI->less(A, B); + } + +private: + // Make it a pointer because apparently some versions of MSVC use std::swap + // on the comparator object. + const llvm::rdf::PhysicalRegisterInfo *PRI; +}; + struct RegisterAggr { RegisterAggr(const PhysicalRegisterInfo &pri) : Units(pri.getTRI().getNumRegUnits()), PRI(pri) {} @@ -336,18 +363,6 @@ template <> struct hash { } }; -template <> struct equal_to { - constexpr equal_to(const llvm::rdf::PhysicalRegisterInfo &pri) : PRI(&pri) {} - - bool operator()(llvm::rdf::RegisterRef A, llvm::rdf::RegisterRef B) const { - return PRI->equal_to(A, B); - } - -private: - // Make it a pointer just in case. See comment in `less` below. - const llvm::rdf::PhysicalRegisterInfo *PRI; -}; - template <> struct equal_to { bool operator()(const llvm::rdf::RegisterAggr &A, const llvm::rdf::RegisterAggr &B) const { @@ -355,23 +370,10 @@ template <> struct equal_to { } }; -template <> struct less { - constexpr less(const llvm::rdf::PhysicalRegisterInfo &pri) : PRI(&pri) {} - - bool operator()(llvm::rdf::RegisterRef A, llvm::rdf::RegisterRef B) const { - return PRI->less(A, B); - } - -private: - // Make it a pointer because apparently some versions of MSVC use std::swap - // on the std::less specialization. - const llvm::rdf::PhysicalRegisterInfo *PRI; -}; - } // namespace std namespace llvm::rdf { -using RegisterSet = std::set>; +using RegisterSet = std::set; } // namespace llvm::rdf #endif // LLVM_CODEGEN_RDFREGISTERS_H diff --git a/interpreter/llvm-project/llvm/lib/CodeGen/RDFLiveness.cpp b/interpreter/llvm-project/llvm/lib/CodeGen/RDFLiveness.cpp index 682d316a5bfac..ce7ee998db536 100644 --- a/interpreter/llvm-project/llvm/lib/CodeGen/RDFLiveness.cpp +++ b/interpreter/llvm-project/llvm/lib/CodeGen/RDFLiveness.cpp @@ -655,8 +655,9 @@ void Liveness::computePhiInfo() { // defs, cache the result of subtracting these defs from a given register // ref. using RefHash = std::hash; - using RefEqual = std::equal_to; - using SubMap = std::unordered_map; + using RefEqual = RegisterRefEqualTo; + using SubMap = + std::unordered_map; std::unordered_map Subs; auto ClearIn = [](RegisterRef RR, const RegisterAggr &Mid, SubMap &SM) { if (Mid.empty()) @@ -873,7 +874,7 @@ void Liveness::computeLiveIns() { std::vector LV; for (const MachineBasicBlock::RegisterMaskPair &LI : B.liveins()) LV.push_back(RegisterRef(LI.PhysReg, LI.LaneMask)); - llvm::sort(LV, std::less(PRI)); + llvm::sort(LV, RegisterRefLess(PRI)); dbgs() << printMBBReference(B) << "\t rec = {"; for (auto I : LV) dbgs() << ' ' << Print(I, DFG); @@ -883,7 +884,7 @@ void Liveness::computeLiveIns() { LV.clear(); for (RegisterRef RR : LiveMap[&B].refs()) LV.push_back(RR); - llvm::sort(LV, std::less(PRI)); + llvm::sort(LV, RegisterRefLess(PRI)); dbgs() << "\tcomp = {"; for (auto I : LV) dbgs() << ' ' << Print(I, DFG); diff --git a/interpreter/llvm-project/llvm/lib/Target/Hexagon/RDFCopy.cpp b/interpreter/llvm-project/llvm/lib/Target/Hexagon/RDFCopy.cpp index fdd7e4cf99e35..55111667085cf 100644 --- a/interpreter/llvm-project/llvm/lib/Target/Hexagon/RDFCopy.cpp +++ b/interpreter/llvm-project/llvm/lib/Target/Hexagon/RDFCopy.cpp @@ -108,7 +108,7 @@ bool CopyPropagation::scanBlock(MachineBasicBlock *B) { for (NodeAddr IA : BA.Addr->members(DFG)) { if (DFG.IsCode(IA)) { NodeAddr SA = IA; - EqualityMap EM(std::less(DFG.getPRI())); + EqualityMap EM(RegisterRefLess(DFG.getPRI())); if (interpretAsCopy(SA.Addr->getCode(), EM)) recordCopy(SA, EM); } diff --git a/interpreter/llvm-project/llvm/lib/Target/Hexagon/RDFCopy.h b/interpreter/llvm-project/llvm/lib/Target/Hexagon/RDFCopy.h index e4fb89892831d..92b2c65982655 100644 --- a/interpreter/llvm-project/llvm/lib/Target/Hexagon/RDFCopy.h +++ b/interpreter/llvm-project/llvm/lib/Target/Hexagon/RDFCopy.h @@ -25,8 +25,8 @@ class MachineInstr; namespace rdf { struct CopyPropagation { - CopyPropagation(DataFlowGraph &dfg) : MDT(dfg.getDT()), DFG(dfg), - RDefMap(std::less(DFG.getPRI())) {} + CopyPropagation(DataFlowGraph &dfg) + : MDT(dfg.getDT()), DFG(dfg), RDefMap(RegisterRefLess(DFG.getPRI())) {} virtual ~CopyPropagation() = default; @@ -35,7 +35,7 @@ namespace rdf { bool trace() const { return Trace; } DataFlowGraph &getDFG() { return DFG; } - using EqualityMap = std::map; + using EqualityMap = std::map; virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM); private: @@ -45,7 +45,7 @@ namespace rdf { bool Trace = false; // map: register -> (map: stmt -> reaching def) - std::map> RDefMap; + std::map, RegisterRefLess> RDefMap; // map: statement -> (map: dst reg -> src reg) std::map CopyMap; std::vector Copies; From 2d61bf6e3a7915eea7b198fa248fee3a63208c66 Mon Sep 17 00:00:00 2001 From: Ian Anderson Date: Tue, 29 Apr 2025 14:59:28 -0700 Subject: [PATCH 2/7] [clang][headers][Apple] Don't include_next float.h to avoid an unnecessary module dependency (#137432) float.h doesn't define anything in Apple's SDKs that the clang float.h doesn't undefine, so all the include_next does is add an unnecessary module dependency. Skip the include_next and completely shadow the SDK header. Backport of https://github.com/llvm/llvm-project/commit/557ddc2e5d066dbc9900cb158a842b9cd5864d8a (cherry picked from commit 7e4318ba3cdc604be7b074d74e484e87a8929bfa) --- interpreter/llvm-project/clang/lib/Headers/float.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/interpreter/llvm-project/clang/lib/Headers/float.h b/interpreter/llvm-project/clang/lib/Headers/float.h index e5c439a9d47ae..84551af473b28 100644 --- a/interpreter/llvm-project/clang/lib/Headers/float.h +++ b/interpreter/llvm-project/clang/lib/Headers/float.h @@ -18,21 +18,12 @@ * additional definitions provided for Windows. * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx * - * Also fall back on Darwin and AIX to allow additional definitions and + * Also fall back on AIX to allow additional definitions and * implementation-defined values. */ -#if (defined(__APPLE__) || defined(__MINGW32__) || defined(_MSC_VER) || \ - defined(_AIX)) && \ +#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(_AIX)) && \ __STDC_HOSTED__ && __has_include_next() -/* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra level - * of #include_next to keep Metrowerks compilers happy. Avoid this - * extra indirection. - */ -#ifdef __APPLE__ -#define _FLOAT_H_ -#endif - # include_next /* Undefine anything that we'll be redefining below. */ From 503cd7cb1064324aeee29073f44dc2cc1c076eeb Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Mon, 13 Oct 2025 07:52:02 -0400 Subject: [PATCH 3/7] [C23] Support the SNAN macros in (#162858) These macros were brought in as part of the TS 18661-1 integration in C23, and then renamed in WG14 N2710. Test coverage is being added to WG14 N3364 from C2y because that paper was fixing a bug with the way these macros are handled with unary + and - operators, so all the existing test coverage was there, just needed to use a header file instead of defining the macros manually. Fixes #162830 Backport of https://github.com/llvm/llvm-project/commit/0e3fdc222a04f723f85b1c78322bf20d71dcdafc (cherry picked from commit 52497d81f83fa53003c4e8512ee6622f7595d7cf) --- interpreter/llvm-project/clang/docs/ReleaseNotes.rst | 3 +++ interpreter/llvm-project/clang/lib/Headers/float.h | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/interpreter/llvm-project/clang/docs/ReleaseNotes.rst b/interpreter/llvm-project/clang/docs/ReleaseNotes.rst index f24fd2b48e55a..6f3b71ffade98 100644 --- a/interpreter/llvm-project/clang/docs/ReleaseNotes.rst +++ b/interpreter/llvm-project/clang/docs/ReleaseNotes.rst @@ -460,6 +460,9 @@ C2y Feature Support C23 Feature Support ^^^^^^^^^^^^^^^^^^^ +- Added ``FLT_SNAN``, ``DBL_SNAN``, and ``LDBL_SNAN`` to Clang's ```` + header in C23 and later modes. This implements + `WG14 N2710 `_. - Clang now supports `N3029 `_ Improved Normal Enumerations. - Clang now officially supports `N3030 `_ Enhancements to Enumerations. Clang already supported it as an extension, so there were no changes to compiler behavior. diff --git a/interpreter/llvm-project/clang/lib/Headers/float.h b/interpreter/llvm-project/clang/lib/Headers/float.h index 84551af473b28..30427c29dcdbd 100644 --- a/interpreter/llvm-project/clang/lib/Headers/float.h +++ b/interpreter/llvm-project/clang/lib/Headers/float.h @@ -89,6 +89,9 @@ !defined(__STRICT_ANSI__) # undef INFINITY # undef NAN +# undef FLT_SNAN +# undef DBL_SNAN +# undef LDBL_SNAN #endif /* Characteristics of floating point types, C99 5.2.4.2.2 */ @@ -160,9 +163,15 @@ #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ !defined(__STRICT_ANSI__) + /* C23 5.2.5.3.2p28 */ +# define FLT_SNAN (__builtin_nansf("")) +# define DBL_SNAN (__builtin_nans("")) +# define LDBL_SNAN (__builtin_nansl("")) + /* C23 5.2.5.3.3p29-30 */ # define INFINITY (__builtin_inff()) # define NAN (__builtin_nanf("")) + /* C23 5.2.5.3.3p32 */ # define FLT_NORM_MAX __FLT_NORM_MAX__ # define DBL_NORM_MAX __DBL_NORM_MAX__ From 649fab4b39fbefad3c6f99cbb181f1e00a4c151a Mon Sep 17 00:00:00 2001 From: Ian Anderson Date: Thu, 23 Oct 2025 10:15:00 -0700 Subject: [PATCH 4/7] [clang][headers] Need a way for math.h to share the definitions of INIFINITY and NAN with float.h (#164348) In C23 mode, both float.h and math.h are required to define INIFINITY and NAN. However, with clang modules, there needs to be a single owner for the declarations. Let that be float.h since that's the suggested true owner in Annex F.2.2 of ISO/IEC 9899:2024, and introduce `__need_infinity_nan` so that math.h can pick up the compiler definitions. Backport of https://github.com/llvm/llvm-project/commit/38473c5d351d6b2ae21b5eb1ce66c2bcc2f7c6f7 (cherry picked from commit ae49e193a2389bfb7b1455df20f59ef99ba673e3) --- .../clang/lib/Headers/CMakeLists.txt | 3 + .../clang/lib/Headers/__float_float.h | 176 +++++++++++++++++ .../clang/lib/Headers/__float_header_macro.h | 12 ++ .../clang/lib/Headers/__float_infinity_nan.h | 20 ++ .../llvm-project/clang/lib/Headers/float.h | 180 ++---------------- .../clang/lib/Headers/module.modulemap | 18 +- 6 files changed, 243 insertions(+), 166 deletions(-) create mode 100644 interpreter/llvm-project/clang/lib/Headers/__float_float.h create mode 100644 interpreter/llvm-project/clang/lib/Headers/__float_header_macro.h create mode 100644 interpreter/llvm-project/clang/lib/Headers/__float_infinity_nan.h diff --git a/interpreter/llvm-project/clang/lib/Headers/CMakeLists.txt b/interpreter/llvm-project/clang/lib/Headers/CMakeLists.txt index 43124111b7ba5..f760fba569146 100644 --- a/interpreter/llvm-project/clang/lib/Headers/CMakeLists.txt +++ b/interpreter/llvm-project/clang/lib/Headers/CMakeLists.txt @@ -4,6 +4,9 @@ set(core_files builtins.h float.h + __float_float.h + __float_header_macro.h + __float_infinity_nan.h inttypes.h iso646.h limits.h diff --git a/interpreter/llvm-project/clang/lib/Headers/__float_float.h b/interpreter/llvm-project/clang/lib/Headers/__float_float.h new file mode 100644 index 0000000000000..267c0721a7ee4 --- /dev/null +++ b/interpreter/llvm-project/clang/lib/Headers/__float_float.h @@ -0,0 +1,176 @@ +/*===---- __float_float.h --------------------------------------------------=== + * + * 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 + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_FLOAT_FLOAT_H +#define __CLANG_FLOAT_FLOAT_H + +#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(_AIX)) && \ + __STDC_HOSTED__ + +/* Undefine anything that we'll be redefining below. */ +# undef FLT_EVAL_METHOD +# undef FLT_ROUNDS +# undef FLT_RADIX +# undef FLT_MANT_DIG +# undef DBL_MANT_DIG +# undef LDBL_MANT_DIG +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + !defined(__STRICT_ANSI__) || \ + (defined(__cplusplus) && __cplusplus >= 201103L) || \ + (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) +# undef DECIMAL_DIG +# endif +# undef FLT_DIG +# undef DBL_DIG +# undef LDBL_DIG +# undef FLT_MIN_EXP +# undef DBL_MIN_EXP +# undef LDBL_MIN_EXP +# undef FLT_MIN_10_EXP +# undef DBL_MIN_10_EXP +# undef LDBL_MIN_10_EXP +# undef FLT_MAX_EXP +# undef DBL_MAX_EXP +# undef LDBL_MAX_EXP +# undef FLT_MAX_10_EXP +# undef DBL_MAX_10_EXP +# undef LDBL_MAX_10_EXP +# undef FLT_MAX +# undef DBL_MAX +# undef LDBL_MAX +# undef FLT_EPSILON +# undef DBL_EPSILON +# undef LDBL_EPSILON +# undef FLT_MIN +# undef DBL_MIN +# undef LDBL_MIN +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ + !defined(__STRICT_ANSI__) || \ + (defined(__cplusplus) && __cplusplus >= 201703L) || \ + (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) +# undef FLT_TRUE_MIN +# undef DBL_TRUE_MIN +# undef LDBL_TRUE_MIN +# undef FLT_DECIMAL_DIG +# undef DBL_DECIMAL_DIG +# undef LDBL_DECIMAL_DIG +# undef FLT_HAS_SUBNORM +# undef DBL_HAS_SUBNORM +# undef LDBL_HAS_SUBNORM +# endif +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ + !defined(__STRICT_ANSI__) +# undef FLT_NORM_MAX +# undef DBL_NORM_MAX +# undef LDBL_NORM_MAX +#endif +#endif + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ + !defined(__STRICT_ANSI__) +# undef FLT_SNAN +# undef DBL_SNAN +# undef LDBL_SNAN +#endif + +/* Characteristics of floating point types, C99 5.2.4.2.2 */ + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + (defined(__cplusplus) && __cplusplus >= 201103L) +#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +#endif +#define FLT_ROUNDS (__builtin_flt_rounds()) +#define FLT_RADIX __FLT_RADIX__ + +#define FLT_MANT_DIG __FLT_MANT_DIG__ +#define DBL_MANT_DIG __DBL_MANT_DIG__ +#define LDBL_MANT_DIG __LDBL_MANT_DIG__ + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ + !defined(__STRICT_ANSI__) || \ + (defined(__cplusplus) && __cplusplus >= 201103L) || \ + (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) +# define DECIMAL_DIG __DECIMAL_DIG__ +#endif + +#define FLT_DIG __FLT_DIG__ +#define DBL_DIG __DBL_DIG__ +#define LDBL_DIG __LDBL_DIG__ + +#define FLT_MIN_EXP __FLT_MIN_EXP__ +#define DBL_MIN_EXP __DBL_MIN_EXP__ +#define LDBL_MIN_EXP __LDBL_MIN_EXP__ + +#define FLT_MIN_10_EXP __FLT_MIN_10_EXP__ +#define DBL_MIN_10_EXP __DBL_MIN_10_EXP__ +#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ + +#define FLT_MAX_EXP __FLT_MAX_EXP__ +#define DBL_MAX_EXP __DBL_MAX_EXP__ +#define LDBL_MAX_EXP __LDBL_MAX_EXP__ + +#define FLT_MAX_10_EXP __FLT_MAX_10_EXP__ +#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__ +#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ + +#define FLT_MAX __FLT_MAX__ +#define DBL_MAX __DBL_MAX__ +#define LDBL_MAX __LDBL_MAX__ + +#define FLT_EPSILON __FLT_EPSILON__ +#define DBL_EPSILON __DBL_EPSILON__ +#define LDBL_EPSILON __LDBL_EPSILON__ + +#define FLT_MIN __FLT_MIN__ +#define DBL_MIN __DBL_MIN__ +#define LDBL_MIN __LDBL_MIN__ + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ + !defined(__STRICT_ANSI__) || \ + (defined(__cplusplus) && __cplusplus >= 201703L) || \ + (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) +# define FLT_TRUE_MIN __FLT_DENORM_MIN__ +# define DBL_TRUE_MIN __DBL_DENORM_MIN__ +# define LDBL_TRUE_MIN __LDBL_DENORM_MIN__ +# define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__ +# define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__ +# define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__ +# define FLT_HAS_SUBNORM __FLT_HAS_DENORM__ +# define DBL_HAS_SUBNORM __DBL_HAS_DENORM__ +# define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__ +#endif + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ + !defined(__STRICT_ANSI__) + /* C23 5.2.5.3.2p28 */ +# define FLT_SNAN (__builtin_nansf("")) +# define DBL_SNAN (__builtin_nans("")) +# define LDBL_SNAN (__builtin_nansl("")) + + /* C23 5.2.5.3.3p32 */ +# define FLT_NORM_MAX __FLT_NORM_MAX__ +# define DBL_NORM_MAX __DBL_NORM_MAX__ +# define LDBL_NORM_MAX __LDBL_NORM_MAX__ +#endif + +#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define FLT16_MANT_DIG __FLT16_MANT_DIG__ +# define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__ +# define FLT16_DIG __FLT16_DIG__ +# define FLT16_MIN_EXP __FLT16_MIN_EXP__ +# define FLT16_MIN_10_EXP __FLT16_MIN_10_EXP__ +# define FLT16_MAX_EXP __FLT16_MAX_EXP__ +# define FLT16_MAX_10_EXP __FLT16_MAX_10_EXP__ +# define FLT16_MAX __FLT16_MAX__ +# define FLT16_EPSILON __FLT16_EPSILON__ +# define FLT16_MIN __FLT16_MIN__ +# define FLT16_TRUE_MIN __FLT16_TRUE_MIN__ +#endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */ + +#endif /* __CLANG_FLOAT_FLOAT_H */ diff --git a/interpreter/llvm-project/clang/lib/Headers/__float_header_macro.h b/interpreter/llvm-project/clang/lib/Headers/__float_header_macro.h new file mode 100644 index 0000000000000..11b270e90deb9 --- /dev/null +++ b/interpreter/llvm-project/clang/lib/Headers/__float_header_macro.h @@ -0,0 +1,12 @@ +/*===---- __float_header_macro.h -------------------------------------------=== + * + * 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 + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_FLOAT_H +#define __CLANG_FLOAT_H +#endif /* __CLANG_FLOAT_H */ diff --git a/interpreter/llvm-project/clang/lib/Headers/__float_infinity_nan.h b/interpreter/llvm-project/clang/lib/Headers/__float_infinity_nan.h new file mode 100644 index 0000000000000..7e253d0bc59b9 --- /dev/null +++ b/interpreter/llvm-project/clang/lib/Headers/__float_infinity_nan.h @@ -0,0 +1,20 @@ +/*===---- __float_infinity_nan.h -------------------------------------------=== + * + * 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 + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __CLANG_FLOAT_INFINITY_NAN_H +#define __CLANG_FLOAT_INFINITY_NAN_H + +/* C23 5.2.5.3.3p29-30 */ +#undef INFINITY +#undef NAN + +#define INFINITY (__builtin_inff()) +#define NAN (__builtin_nanf("")) + +#endif /* __CLANG_FLOAT_INFINITY_NAN_H */ diff --git a/interpreter/llvm-project/clang/lib/Headers/float.h b/interpreter/llvm-project/clang/lib/Headers/float.h index 30427c29dcdbd..82974f60048c9 100644 --- a/interpreter/llvm-project/clang/lib/Headers/float.h +++ b/interpreter/llvm-project/clang/lib/Headers/float.h @@ -7,13 +7,21 @@ *===-----------------------------------------------------------------------=== */ -#ifndef __CLANG_FLOAT_H -#define __CLANG_FLOAT_H - #if defined(__MVS__) && __has_include_next() +#include <__float_header_macro.h> #include_next #else +#if !defined(__need_infinity_nan) +#define __need_float_float +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ + !defined(__STRICT_ANSI__) +#define __need_infinity_nan +#endif +#include <__float_header_macro.h> +#endif + +#ifdef __need_float_float /* If we're on MinGW, fall back to the system's float.h, which might have * additional definitions provided for Windows. * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx @@ -26,171 +34,15 @@ # include_next -/* Undefine anything that we'll be redefining below. */ -# undef FLT_EVAL_METHOD -# undef FLT_ROUNDS -# undef FLT_RADIX -# undef FLT_MANT_DIG -# undef DBL_MANT_DIG -# undef LDBL_MANT_DIG -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ - !defined(__STRICT_ANSI__) || \ - (defined(__cplusplus) && __cplusplus >= 201103L) || \ - (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) -# undef DECIMAL_DIG -# endif -# undef FLT_DIG -# undef DBL_DIG -# undef LDBL_DIG -# undef FLT_MIN_EXP -# undef DBL_MIN_EXP -# undef LDBL_MIN_EXP -# undef FLT_MIN_10_EXP -# undef DBL_MIN_10_EXP -# undef LDBL_MIN_10_EXP -# undef FLT_MAX_EXP -# undef DBL_MAX_EXP -# undef LDBL_MAX_EXP -# undef FLT_MAX_10_EXP -# undef DBL_MAX_10_EXP -# undef LDBL_MAX_10_EXP -# undef FLT_MAX -# undef DBL_MAX -# undef LDBL_MAX -# undef FLT_EPSILON -# undef DBL_EPSILON -# undef LDBL_EPSILON -# undef FLT_MIN -# undef DBL_MIN -# undef LDBL_MIN -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ - !defined(__STRICT_ANSI__) || \ - (defined(__cplusplus) && __cplusplus >= 201703L) || \ - (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) -# undef FLT_TRUE_MIN -# undef DBL_TRUE_MIN -# undef LDBL_TRUE_MIN -# undef FLT_DECIMAL_DIG -# undef DBL_DECIMAL_DIG -# undef LDBL_DECIMAL_DIG -# undef FLT_HAS_SUBNORM -# undef DBL_HAS_SUBNORM -# undef LDBL_HAS_SUBNORM -# endif -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ - !defined(__STRICT_ANSI__) -# undef FLT_NORM_MAX -# undef DBL_NORM_MAX -# undef LDBL_NORM_MAX -#endif -#endif - -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ - !defined(__STRICT_ANSI__) -# undef INFINITY -# undef NAN -# undef FLT_SNAN -# undef DBL_SNAN -# undef LDBL_SNAN -#endif - -/* Characteristics of floating point types, C99 5.2.4.2.2 */ - -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ - (defined(__cplusplus) && __cplusplus >= 201103L) -#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ #endif -#define FLT_ROUNDS (__builtin_flt_rounds()) -#define FLT_RADIX __FLT_RADIX__ -#define FLT_MANT_DIG __FLT_MANT_DIG__ -#define DBL_MANT_DIG __DBL_MANT_DIG__ -#define LDBL_MANT_DIG __LDBL_MANT_DIG__ - -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ - !defined(__STRICT_ANSI__) || \ - (defined(__cplusplus) && __cplusplus >= 201103L) || \ - (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) -# define DECIMAL_DIG __DECIMAL_DIG__ -#endif - -#define FLT_DIG __FLT_DIG__ -#define DBL_DIG __DBL_DIG__ -#define LDBL_DIG __LDBL_DIG__ - -#define FLT_MIN_EXP __FLT_MIN_EXP__ -#define DBL_MIN_EXP __DBL_MIN_EXP__ -#define LDBL_MIN_EXP __LDBL_MIN_EXP__ - -#define FLT_MIN_10_EXP __FLT_MIN_10_EXP__ -#define DBL_MIN_10_EXP __DBL_MIN_10_EXP__ -#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ - -#define FLT_MAX_EXP __FLT_MAX_EXP__ -#define DBL_MAX_EXP __DBL_MAX_EXP__ -#define LDBL_MAX_EXP __LDBL_MAX_EXP__ - -#define FLT_MAX_10_EXP __FLT_MAX_10_EXP__ -#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__ -#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ - -#define FLT_MAX __FLT_MAX__ -#define DBL_MAX __DBL_MAX__ -#define LDBL_MAX __LDBL_MAX__ - -#define FLT_EPSILON __FLT_EPSILON__ -#define DBL_EPSILON __DBL_EPSILON__ -#define LDBL_EPSILON __LDBL_EPSILON__ - -#define FLT_MIN __FLT_MIN__ -#define DBL_MIN __DBL_MIN__ -#define LDBL_MIN __LDBL_MIN__ - -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \ - !defined(__STRICT_ANSI__) || \ - (defined(__cplusplus) && __cplusplus >= 201703L) || \ - (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE)) -# define FLT_TRUE_MIN __FLT_DENORM_MIN__ -# define DBL_TRUE_MIN __DBL_DENORM_MIN__ -# define LDBL_TRUE_MIN __LDBL_DENORM_MIN__ -# define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__ -# define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__ -# define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__ -# define FLT_HAS_SUBNORM __FLT_HAS_DENORM__ -# define DBL_HAS_SUBNORM __DBL_HAS_DENORM__ -# define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__ +#include <__float_float.h> +#undef __need_float_float #endif -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \ - !defined(__STRICT_ANSI__) - /* C23 5.2.5.3.2p28 */ -# define FLT_SNAN (__builtin_nansf("")) -# define DBL_SNAN (__builtin_nans("")) -# define LDBL_SNAN (__builtin_nansl("")) - - /* C23 5.2.5.3.3p29-30 */ -# define INFINITY (__builtin_inff()) -# define NAN (__builtin_nanf("")) - - /* C23 5.2.5.3.3p32 */ -# define FLT_NORM_MAX __FLT_NORM_MAX__ -# define DBL_NORM_MAX __DBL_NORM_MAX__ -# define LDBL_NORM_MAX __LDBL_NORM_MAX__ +#ifdef __need_infinity_nan +#include <__float_infinity_nan.h> +#undef __need_infinity_nan #endif -#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__ -# define FLT16_MANT_DIG __FLT16_MANT_DIG__ -# define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__ -# define FLT16_DIG __FLT16_DIG__ -# define FLT16_MIN_EXP __FLT16_MIN_EXP__ -# define FLT16_MIN_10_EXP __FLT16_MIN_10_EXP__ -# define FLT16_MAX_EXP __FLT16_MAX_EXP__ -# define FLT16_MAX_10_EXP __FLT16_MAX_10_EXP__ -# define FLT16_MAX __FLT16_MAX__ -# define FLT16_EPSILON __FLT16_EPSILON__ -# define FLT16_MIN __FLT16_MIN__ -# define FLT16_TRUE_MIN __FLT16_TRUE_MIN__ -#endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */ - #endif /* __MVS__ */ -#endif /* __CLANG_FLOAT_H */ diff --git a/interpreter/llvm-project/clang/lib/Headers/module.modulemap b/interpreter/llvm-project/clang/lib/Headers/module.modulemap index dcaf09e8f2c55..b6a5248cde9e1 100644 --- a/interpreter/llvm-project/clang/lib/Headers/module.modulemap +++ b/interpreter/llvm-project/clang/lib/Headers/module.modulemap @@ -163,8 +163,22 @@ module _Builtin_intrinsics [system] [extern_c] { // that module. The system float.h (if present) will be treated // as a textual header in the sytem module. module _Builtin_float [system] { - header "float.h" - export * + textual header "float.h" + + explicit module float { + header "__float_float.h" + export * + } + + explicit module header_macro { + header "__float_header_macro.h" + export * + } + + explicit module infinity_nan { + header "__float_infinity_nan.h" + export * + } } module _Builtin_inttypes [system] { From c633ca335b9bb525acb5610b15be92d653f29f19 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Tue, 16 Jun 2026 14:56:20 +0200 Subject: [PATCH 5/7] [llvm-project] Bump to tag ROOT-llvm20-20260616-01 (cherry picked from commit 765d976f56c54d5b22ee4367957a9d5c0303e799) --- interpreter/llvm-project/llvm-project.tag | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interpreter/llvm-project/llvm-project.tag b/interpreter/llvm-project/llvm-project.tag index d8f26d75d936d..26bc433175990 100644 --- a/interpreter/llvm-project/llvm-project.tag +++ b/interpreter/llvm-project/llvm-project.tag @@ -1 +1 @@ -ROOT-llvm20-20260408-01 +ROOT-llvm20-20260616-01 From f0b06f8b311e0ba6236dc2923155c04e2f076ec9 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Tue, 16 Jun 2026 11:13:41 +0200 Subject: [PATCH 6/7] [cling] Restrict BuiltinHeadersInSystemModules to non-Apple It was introduced in commit c28b205e19 during the upgrade to LLVM 18 to fix the build on (basically) all platforms, and this remains true on Linux. For Apple however, the newest MacOSX27.0.sdk is incomaptible and the option must not be set. (cherry picked from commit a314567a95d24d6c852555bc369bfa9bafb37efa) --- interpreter/cling/lib/Interpreter/CIFactory.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/interpreter/cling/lib/Interpreter/CIFactory.cpp b/interpreter/cling/lib/Interpreter/CIFactory.cpp index 1442fb2961737..7a3c96916b0d2 100644 --- a/interpreter/cling/lib/Interpreter/CIFactory.cpp +++ b/interpreter/cling/lib/Interpreter/CIFactory.cpp @@ -434,7 +434,9 @@ namespace { } //Opts.Modules = 1; +#ifndef __APPLE__ Opts.BuiltinHeadersInSystemModules = 1; +#endif // See test/CodeUnloading/PCH/VTables.cpp which implicitly compares clang // to cling lang options. They should be the same, we should not have to From 39147419ec9266a8ac8a10b02cb5321bdb937e0b Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Tue, 16 Jun 2026 11:27:04 +0200 Subject: [PATCH 7/7] [macOS] Resolve cyclic dependency of stdint.h Similar to ctype.h, this is also caused by the large std module that wraps all submodules. Instead of removing, it seems sufficient to mark the header as textual. (cherry picked from commit 0f5bfada5f4921760966bcf89d08058c4ae582b2) --- cmake/scripts/std_modulemap_darwin_fix.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cmake/scripts/std_modulemap_darwin_fix.py b/cmake/scripts/std_modulemap_darwin_fix.py index d610a7a8c5030..80d8eab16b4ec 100644 --- a/cmake/scripts/std_modulemap_darwin_fix.py +++ b/cmake/scripts/std_modulemap_darwin_fix.py @@ -4,11 +4,10 @@ import subprocess import sys -def remove_ctype_module(content): - # Break cyclic module dependencies - # See: https://github.com/root-project/root/commit/8045591a17125b49c1007787c586868dea764479 - pattern = re.compile(r"module\s+std_ctype_h\s+\[system\]\s*\{.*?\}", re.DOTALL) - return pattern.sub("", content) +def resolve_cyclic_module_dependencies(content): + for h in ["ctype.h", "stdint.h"]: + content = re.sub(f' header "{h}"', f' textual header "{h}"', content) + return content def main(): @@ -31,7 +30,7 @@ def main(): with open(cpp_modulemap, "r") as f: original_content = f.read() - cleaned_content = remove_ctype_module(original_content) + cleaned_content = resolve_cyclic_module_dependencies(original_content) os.makedirs(os.path.dirname(output_path), exist_ok=True) with open(output_path, "w") as f: