[clang] [llvm] [mlir] [clang] Use VFS for `-fopenmp-host-ir-file-path` (PR #156727)
https://github.com/jansvoboda11 updated https://github.com/llvm/llvm-project/pull/156727 >From 6db502e639b7a4b9c0a0a02f734298d3d4df3bf9 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Tue, 22 Jul 2025 09:44:01 -0700 Subject: [PATCH 1/2] [clang] Use VFS for `-fopenmp-host-ir-file-path` --- clang/lib/CodeGen/CGOpenMPRuntime.cpp | 3 +- clang/lib/CodeGen/CodeGenModule.cpp | 3 +- clang/test/OpenMP/host-ir-file-vfs.c | 33 +++ .../llvm/Frontend/OpenMP/OMPIRBuilder.h | 7 +++- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | 6 ++-- 5 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 clang/test/OpenMP/host-ir-file-vfs.c diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index b38eb54036e60..68ecf6ae347c3 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -1038,7 +1038,8 @@ CGOpenMPRuntime::CGOpenMPRuntime(CodeGenModule &CGM) /*HasRequiresReverseOffload*/ false, /*HasRequiresUnifiedAddress*/ false, hasRequiresUnifiedSharedMemory(), /*HasRequiresDynamicAllocators*/ false); OMPBuilder.initialize(); - OMPBuilder.loadOffloadInfoMetadata(CGM.getLangOpts().OpenMPIsTargetDevice + OMPBuilder.loadOffloadInfoMetadata(*CGM.getFileSystem(), + CGM.getLangOpts().OpenMPIsTargetDevice ? CGM.getLangOpts().OMPHostIRFile : StringRef{}); OMPBuilder.setConfig(Config); diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index f1ddaa875f3e4..89fc9baa73d98 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -582,8 +582,7 @@ void CodeGenModule::createOpenCLRuntime() { } void CodeGenModule::createOpenMPRuntime() { - if (!LangOpts.OMPHostIRFile.empty() && - !llvm::sys::fs::exists(LangOpts.OMPHostIRFile)) + if (!LangOpts.OMPHostIRFile.empty() && !FS->exists(LangOpts.OMPHostIRFile)) Diags.Report(diag::err_omp_host_ir_file_not_found) << LangOpts.OMPHostIRFile; diff --git a/clang/test/OpenMP/host-ir-file-vfs.c b/clang/test/OpenMP/host-ir-file-vfs.c new file mode 100644 index 0..394d8fbcc94ac --- /dev/null +++ b/clang/test/OpenMP/host-ir-file-vfs.c @@ -0,0 +1,33 @@ +// This test checks that the OpenMP host IR file goes through VFS overlays. + +// RUN: rm -rf %t +// RUN: split-file %s %t + +// RUN: sed -e "s|DIR|%/t|g" %t/vfs.json.in > %t/vfs.json +// RUN: %clang_cc1 -fopenmp-simd -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %t/host.c -o %t/host.bc + +// RUN: %clang_cc1 -fopenmp-simd -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %t/device.c -o - \ +// RUN: -fopenmp-is-target-device -fopenmp-host-ir-file-path %t/virtual/host.bc -ivfsoverlay %t/vfs.json -verify + +//--- vfs.json.in +{ + 'version': 0, + 'use-external-names': true, + 'roots': [ +{ + 'name': 'DIR/virtual', + 'type': 'directory', + 'contents': [ +{ + 'name': 'host.bc', + 'type': 'file', + 'external-contents': 'DIR/host.bc' +} + ] +} + ] +} + +//--- host.c +//--- device.c +// expected-no-diagnostics diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h index 1050e3d8b08dd..cc1177ba3d11c 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h +++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h @@ -39,6 +39,10 @@ class Loop; class LoopAnalysis; class LoopInfo; +namespace vfs { +class FileSystem; +} // namespace vfs + /// Move the instruction after an InsertPoint to the beginning of another /// BasicBlock. /// @@ -3629,7 +3633,8 @@ class OpenMPIRBuilder { /// \param HostFilePath The path to the host IR file, /// used to load in offload metadata for the device, allowing host and device /// to maintain the same metadata mapping. - LLVM_ABI void loadOffloadInfoMetadata(StringRef HostFilePath); + LLVM_ABI void loadOffloadInfoMetadata(vfs::FileSystem &VFS, +StringRef HostFilePath); /// Gets (if variable with the given name already exist) or creates /// internal global variable with the specified Name. The created variable has diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp index 03ea58318d4a9..f2ba0f65fd464 100644 --- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp +++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp @@ -50,6 +50,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" @@ -10523,11 +10524,12 @@ void Open
[clang] add MMX/SSE/AVX PHADD/SUB & HADDPS/D intrinsics to be used in constexpr #155395 (PR #156822)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: why (whytolearn) Changes [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add MMX/SSE/AVX PHADD/SUB & HADDPS/D intrinsics to be used in constexpr #155395 cover func: _mm_hadd_pi16 _mm_hadd_epi16 _mm256_hadd_epi16 _mm_hadd_pi32 _mm_hadd_epi32 _mm256_hadd_epi32 _mm_hadds_pi16 _mm_hadds_epi16 _mm256_hadds_epi16 _mm_hsub_pi16 _mm_hsub_epi16 _mm256_hsub_epi16 _mm_hsub_pi32 _mm_hsub_epi32 _mm256_hsub_epi32 _mm_hsubs_pi16 _mm_hsubs_epi16 _mm256_hsubs_epi16 _mm_hadd_pd _mm256_hadd_pd _mm_hadd_ps _mm256_hadd_ps _mm_hsub_pd _mm256_hsub_pd _mm_hsub_ps _mm256_hsub_ps --- Patch is 32.77 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/156822.diff 8 Files Affected: - (modified) clang/lib/Headers/avx2intrin.h (+18-24) - (modified) clang/lib/Headers/avxintrin.h (+8-12) - (modified) clang/lib/Headers/pmmintrin.h (+8-12) - (modified) clang/lib/Headers/tmmintrin.h (+52-67) - (modified) clang/test/CodeGen/X86/avx-builtins.c (+29) - (modified) clang/test/CodeGen/X86/avx2-builtins.c (+63) - (modified) clang/test/CodeGen/X86/mmx-builtins.c (+48) - (modified) clang/test/CodeGen/X86/ssse3-builtins.c (+49) ``diff diff --git a/clang/lib/Headers/avx2intrin.h b/clang/lib/Headers/avx2intrin.h index 4d03103ac1e08..54fe41cad6a46 100644 --- a/clang/lib/Headers/avx2intrin.h +++ b/clang/lib/Headers/avx2intrin.h @@ -854,10 +854,9 @@ _mm256_cmpgt_epi64(__m256i __a, __m256i __b) /// \param __b ///A 256-bit vector of [16 x i16] containing one of the source operands. /// \returns A 256-bit vector of [16 x i16] containing the sums. -static __inline__ __m256i __DEFAULT_FN_ATTRS256 -_mm256_hadd_epi16(__m256i __a, __m256i __b) -{ -return (__m256i)__builtin_ia32_phaddw256((__v16hi)__a, (__v16hi)__b); +static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR +_mm256_hadd_epi16(__m256i __a, __m256i __b) { + return (__m256i)__builtin_ia32_phaddw256((__v16hi)__a, (__v16hi)__b); } /// Horizontally adds the adjacent pairs of 32-bit integers from two 256-bit @@ -886,10 +885,9 @@ _mm256_hadd_epi16(__m256i __a, __m256i __b) /// \param __b ///A 256-bit vector of [8 x i32] containing one of the source operands. /// \returns A 256-bit vector of [8 x i32] containing the sums. -static __inline__ __m256i __DEFAULT_FN_ATTRS256 -_mm256_hadd_epi32(__m256i __a, __m256i __b) -{ -return (__m256i)__builtin_ia32_phaddd256((__v8si)__a, (__v8si)__b); +static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR +_mm256_hadd_epi32(__m256i __a, __m256i __b) { + return (__m256i)__builtin_ia32_phaddd256((__v8si)__a, (__v8si)__b); } /// Horizontally adds the adjacent pairs of 16-bit integers from two 256-bit @@ -921,10 +919,9 @@ _mm256_hadd_epi32(__m256i __a, __m256i __b) /// \param __b ///A 256-bit vector of [16 x i16] containing one of the source operands. /// \returns A 256-bit vector of [16 x i16] containing the sums. -static __inline__ __m256i __DEFAULT_FN_ATTRS256 -_mm256_hadds_epi16(__m256i __a, __m256i __b) -{ -return (__m256i)__builtin_ia32_phaddsw256((__v16hi)__a, (__v16hi)__b); +static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR +_mm256_hadds_epi16(__m256i __a, __m256i __b) { + return (__m256i)__builtin_ia32_phaddsw256((__v16hi)__a, (__v16hi)__b); } /// Horizontally subtracts adjacent pairs of 16-bit integers from two 256-bit @@ -957,10 +954,9 @@ _mm256_hadds_epi16(__m256i __a, __m256i __b) /// \param __b ///A 256-bit vector of [16 x i16] containing one of the source operands. /// \returns A 256-bit vector of [16 x i16] containing the differences. -static __inline__ __m256i __DEFAULT_FN_ATTRS256 -_mm256_hsub_epi16(__m256i __a, __m256i __b) -{ -return (__m256i)__builtin_ia32_phsubw256((__v16hi)__a, (__v16hi)__b); +static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR +_mm256_hsub_epi16(__m256i __a, __m256i __b) { + return (__m256i)__builtin_ia32_phsubw256((__v16hi)__a, (__v16hi)__b); } /// Horizontally subtracts adjacent pairs of 32-bit integers from two 256-bit @@ -989,10 +985,9 @@ _mm256_hsub_epi16(__m256i __a, __m256i __b) /// \param __b ///A 256-bit vector of [8 x i32] containing one of the source operands. /// \returns A 256-bit vector of [8 x i32] containing the differences. -static __inline__ __m256i __DEFAULT_FN_ATTRS256 -_mm256_hsub_epi32(__m256i __a, __m256i __b) -{ -return (__m256i)__builtin_ia32_phsubd256((__v8si)__a, (__v8si)__b); +static __inline__ __m256i __DEFAULT_FN_ATTRS256_CONSTEXPR +_mm256_hsub_epi32(__m256i __a, __m256i __b) { + return (__m256i)__builtin_ia32_phsubd256((__v8si)__a, (__v8si)__b); } /// Horizontally subtracts adjacent pairs of 16-bit integers from two 256-bit @@ -1025,10 +1020,9 @@ _mm256_hsub_epi32(__m256i __a, __m256i __b) /// \param __b ///A 256-bit vector of [16 x i16] containing one of the source operands. /// \returns A 256-bit vector of [16 x i16] containing the differences. -st
[libclc] [NFC][libclc] Set MACRO_ARCH to ${ARCH} uncondionally before customizing (PR #156789)
https://github.com/frasercrmck approved this pull request. LGTM. I don't like `set` repetition in `if`/`else` either. Not least because it's worse for downstreams. https://github.com/llvm/llvm-project/pull/156789 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV][Zicfilp] Enable Zicfilp CFI compiler behaviors by looking at module flags (PR #152121)
@@ -1802,3 +1800,15 @@ def FeatureTaggedGlobals : SubtargetFeature<"tagged-globals", "AllowTaggedGlobals", "true", "Use an instruction sequence for taking the address of a global " "that allows a memory tag in the upper address bits">; + +// Zicfilp-based CFI +def FeatureZicfilpUnlabeled +: SubtargetFeature< + "zicfilp-unlabeled", "HasZicfilpUnlabeled", "true", + "Enforce forward-edge control-flow integrity with ZICFILP-unlabeled">; +def FeatureZicfilpFuncSig +: SubtargetFeature< + "zicfilp-func-sig", "HasZicfilpFuncSig", "true", + "Enforce forward-edge control-flow integrity with ZICFILP-func-sig">; mylai-mtk wrote: In the end, I decided to still implement this series of features as enum target features, since when prototyping riscv-non-isa/riscv-elf-psabi-doc#474 , the disassembler would only know that zicfilp-cfi is enabled, but has no idea about the scheme. As a result, a generic indicator target feature "zicfilp-cfi" is needed, which could be overridden by the zicfilp-unlabeled/zicfilp-func-sig enum. This kinda uses the overriding semantics of enum target features, though still not a perfect match. https://github.com/llvm/llvm-project/pull/152121 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang-tidy] Do not crash when an empty directory is used in the comp… (PR #156873)
@@ -574,22 +574,30 @@ int ClangTool::run(ToolAction *Action) { continue; } for (CompileCommand &CompileCommand : CompileCommandsForFile) { + // If the 'directory' field of the compilation database is empty, display + // an error and use the working directory instead. + std::string Directory = CompileCommand.Directory; localspook wrote: ```suggestion StringRef Directory = CompileCommand.Directory; ``` ? https://github.com/llvm/llvm-project/pull/156873 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libunwind] [llvm] [wasm] Toolchain support for `wasm32-wali-linux-musl` target (PR #156087)
arjunr2 wrote: Ping https://github.com/llvm/llvm-project/pull/156087 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Support for Zvabd fast-track proposal (PR #124239)
https://github.com/wangpc-pp edited https://github.com/llvm/llvm-project/pull/124239 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20][Modules] Implement P1857R3 Modules Dependency Discovery (PR #107168)
@@ -1778,10 +1778,20 @@ def ext_bit_int : Extension< } // end of Parse Issue category. let CategoryName = "Modules Issue" in { -def err_unexpected_module_decl : Error< - "module declaration can only appear at the top level">; +def err_invalid_module_or_import_directive : Error< + "the %select{module|import}0 directive is ill-formed, " + "%select{module contextual keyword must be immediately " + "followed on the same line by an identifier, " + "or a ';' after being at the start of a line, or preceded by " + "an export keyword at the start of a line|" + "import contextual keyword must be immediately followed " yronglin wrote: Can we just remove `contextual` word? https://github.com/llvm/llvm-project/pull/107168 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [win][clang] Align scalar deleting destructors with MSABI (PR #139566)
Fznamznon wrote: > The conflict in ReleaseNotes has to be fixed. I am happy to have this > compatibility fixed since we ran into it at some point. I am guessing that > reviews can be slower during summer. Maybe @aganea or @efriedma-quic could > have a look (again). The conflicts has been fixed. https://github.com/llvm/llvm-project/pull/139566 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Add type annotations for code completion classes (PR #140539)
https://github.com/DeinAlptraum updated https://github.com/llvm/llvm-project/pull/140539 >From 2d899491a409ede826674d7283df7f594987c355 Mon Sep 17 00:00:00 2001 From: Jannick Kremer Date: Mon, 19 May 2025 22:20:00 +0900 Subject: [PATCH 1/2] [libclang/python] Add type annotations for code completion classes --- clang/bindings/python/clang/cindex.py | 69 +++ 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index f65bcad780a70..1dadd44f7d564 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -110,6 +110,7 @@ "tuple[str, Optional[list[Any]], Any]", "tuple[str, Optional[list[Any]], Any, Callable[..., Any]]", ] +CObjP: TypeAlias = _Pointer[Any] TSeq = TypeVar("TSeq", covariant=True) @@ -2960,25 +2961,26 @@ class _CXUnsavedFile(Structure): class CompletionChunk: class Kind: -def __init__(self, name): + +def __init__(self, name: str): self.name = name -def __str__(self): +def __str__(self) -> str: return self.name -def __repr__(self): +def __repr__(self) -> str: return "" % self -def __init__(self, completionString, key): +def __init__(self, completionString: CObjP, key: int): self.cs = completionString self.key = key self.__kindNumberCache = -1 -def __repr__(self): +def __repr__(self) -> str: return "{'" + self.spelling + "', " + str(self.kind) + "}" @CachedProperty -def spelling(self): +def spelling(self) -> str: if self.__kindNumber in SPELLING_CACHE: return SPELLING_CACHE[self.__kindNumber] return _CXString.from_result( @@ -2989,7 +2991,7 @@ def spelling(self): # apparently still significantly faster. Please profile carefully if you # would like to add CachedProperty back. @property -def __kindNumber(self): +def __kindNumber(self) -> int: if self.__kindNumberCache == -1: self.__kindNumberCache = conf.lib.clang_getCompletionChunkKind( self.cs, self.key @@ -2997,30 +2999,30 @@ def __kindNumber(self): return self.__kindNumberCache @CachedProperty -def kind(self): +def kind(self) -> Kind: return completionChunkKindMap[self.__kindNumber] @CachedProperty -def string(self): +def string(self) -> CompletionString | None: res = conf.lib.clang_getCompletionChunkCompletionString(self.cs, self.key) if not res: return None return CompletionString(res) -def isKindOptional(self): +def isKindOptional(self) -> bool: return self.__kindNumber == 0 -def isKindTypedText(self): +def isKindTypedText(self) -> bool: return self.__kindNumber == 1 -def isKindPlaceHolder(self): +def isKindPlaceHolder(self) -> bool: return self.__kindNumber == 3 -def isKindInformative(self): +def isKindInformative(self) -> bool: return self.__kindNumber == 4 -def isKindResultType(self): +def isKindResultType(self) -> bool: return self.__kindNumber == 15 @@ -3051,6 +3053,7 @@ def isKindResultType(self): class CompletionString(ClangObject): class Availability: + def __init__(self, name): self.name = name @@ -3060,14 +3063,14 @@ def __str__(self): def __repr__(self): return "" % self -def __len__(self): +def __len__(self) -> int: return self.num_chunks @CachedProperty -def num_chunks(self): +def num_chunks(self) -> int: return conf.lib.clang_getNumCompletionChunks(self.obj) # type: ignore [no-any-return] -def __getitem__(self, key): +def __getitem__(self, key: int) -> CompletionChunk: if self.num_chunks <= key: raise IndexError return CompletionChunk(self.obj, key) @@ -3075,24 +3078,24 @@ def __getitem__(self, key): if TYPE_CHECKING: # Defining __getitem__ and __len__ is enough to make an iterable # but the typechecker doesn't understand that. -def __iter__(self): +def __iter__(self) -> Iterator[CompletionChunk]: for i in range(len(self)): yield self[i] @property -def priority(self): +def priority(self) -> int: return conf.lib.clang_getCompletionPriority(self.obj) # type: ignore [no-any-return] @property -def availability(self): +def availability(self) -> CompletionChunk.Kind: res = conf.lib.clang_getCompletionAvailability(self.obj) return availabilityKinds[res] @property -def briefComment(self): +def briefComment(self) -> str: return _CXString.from_result(conf.lib.clang_getCompletionBriefComment(self.obj)) -def __re
[clang] [clang-format] Add BreakAfterOpenBracket* and BreakBeforeCloseBracket* (PR #108332)
@@ -543,21 +543,17 @@ TEST(ConfigParseTest, ParsesConfiguration) { CHECK_PARSE("EnumTrailingComma: Remove", EnumTrailingComma, FormatStyle::ETC_Remove); - Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign; - CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket, - FormatStyle::BAS_Align); - CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket, - FormatStyle::BAS_DontAlign); + Style.AlignAfterOpenBracket = false; + CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket, true); + CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket, false); // For backward compatibility: CHECK_PARSE("AlignAfterOpenBracket: AlwaysBreak", AlignAfterOpenBracket, - FormatStyle::BAS_Align); - CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket, - FormatStyle::BAS_DontAlign); + true); + CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket, false); CHECK_PARSE("AlignAfterOpenBracket: BlockIndent", AlignAfterOpenBracket, - FormatStyle::BAS_Align); - Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign; - CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket, - FormatStyle::BAS_Align); + true); + Style.AlignAfterOpenBracket = false; + CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket, true); gedare wrote: done https://github.com/llvm/llvm-project/pull/108332 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Rewrite tests relying on shell environment variable features (PR #156904)
@@ -10,7 +8,9 @@ // RUN: echo "@subdir/cfg-s2" > %t/workdir/cfg-1 // RUN: echo "-Wundefined-var-template" > %t/workdir/subdir/cfg-s2 // -// RUN: ( cd %t && %clang --config=workdir/cfg-1 -c -### %s 2>&1 | FileCheck %s -check-prefix CHECK-REL ) +// RUN: pushd %t +// RUN: %clang --config=workdir/cfg-1 -c -### %s 2>&1 | FileCheck %s -check-prefix CHECK-REL +// RUN: popd // // CHECK-REL: Configuration file: {{.*}}/workdir/cfg-1 ilovepi wrote: I think this is failing due to the use of `/` on windows. https://github.com/llvm/llvm-project/pull/156904 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8bdd909 - [Headers][X86] Add constexpr support for some AVX[512] intrinsics. (#156567)
Author: moorabbit Date: 2025-09-04T12:50:06Z New Revision: 8bdd9090d0c75226b47232380d96051ff173b067 URL: https://github.com/llvm/llvm-project/commit/8bdd9090d0c75226b47232380d96051ff173b067 DIFF: https://github.com/llvm/llvm-project/commit/8bdd9090d0c75226b47232380d96051ff173b067.diff LOG: [Headers][X86] Add constexpr support for some AVX[512] intrinsics. (#156567) The following AVX[512] intrinsics are now constexpr: - `_mm_mask_cvtepi32_pd` - `_mm_maskz_cvtepi32_pd` - `_mm_mask_cvtepi32_ps` - `_mm_maskz_cvtepi32_ps` - `_mm_cvtepu32_pd` - `_mm_mask_cvtepu32_pd` - `_mm_maskz_cvtepu32_pd` - `_mm_cvtepu32_ps` - `_mm_mask_cvtepu32_ps` - `_mm_maskz_cvtepu32_ps` - `_mm256_mask_cvtepi32_pd` - `_mm256_maskz_cvtepi32_pd` - `_mm256_mask_cvtepi32_ps` - `_mm256_maskz_cvtepi32_ps` - `_mm256_cvtepu32_pd` - `_mm256_mask_cvtepu32_pd` - `_mm256_maskz_cvtepu32_pd` - `_mm256_cvtepu32_ps` - `_mm256_mask_cvtepu32_ps` - `_mm256_maskz_cvtepu32_ps` - `_mm512_cvtepi64_pd` - `_mm512_mask_cvtepi64_pd` - `_mm512_maskz_cvtepi64_pd` - `_mm512_cvtepu64_pd` - `_mm512_mask_cvtepu64_pd` - `_mm512_maskz_cvtepu64_pd` This PR is part 2 [[part 1](https://github.com/llvm/llvm-project/pull/156187)] of a series of PRs fixing #155798 Added: Modified: clang/lib/Headers/avx512dqintrin.h clang/lib/Headers/avx512vlintrin.h clang/test/CodeGen/X86/avx512dq-builtins.c clang/test/CodeGen/X86/avx512vl-builtins.c Removed: diff --git a/clang/lib/Headers/avx512dqintrin.h b/clang/lib/Headers/avx512dqintrin.h index b0fe903d82431..ee211d3eae9d7 100644 --- a/clang/lib/Headers/avx512dqintrin.h +++ b/clang/lib/Headers/avx512dqintrin.h @@ -483,21 +483,20 @@ _mm512_maskz_cvtps_epu64 (__mmask8 __U, __m256 __A) { (__v8di)_mm512_setzero_si512(), \ (__mmask8)(U), (int)(R))) - -static __inline__ __m512d __DEFAULT_FN_ATTRS512 -_mm512_cvtepi64_pd (__m512i __A) { +static __inline__ __m512d __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_cvtepi64_pd(__m512i __A) { return (__m512d)__builtin_convertvector((__v8di)__A, __v8df); } -static __inline__ __m512d __DEFAULT_FN_ATTRS512 -_mm512_mask_cvtepi64_pd (__m512d __W, __mmask8 __U, __m512i __A) { +static __inline__ __m512d __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_mask_cvtepi64_pd(__m512d __W, __mmask8 __U, __m512i __A) { return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, (__v8df)_mm512_cvtepi64_pd(__A), (__v8df)__W); } -static __inline__ __m512d __DEFAULT_FN_ATTRS512 -_mm512_maskz_cvtepi64_pd (__mmask8 __U, __m512i __A) { +static __inline__ __m512d __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_maskz_cvtepi64_pd(__mmask8 __U, __m512i __A) { return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, (__v8df)_mm512_cvtepi64_pd(__A), (__v8df)_mm512_setzero_pd()); @@ -714,20 +713,20 @@ _mm512_maskz_cvttps_epu64 (__mmask8 __U, __m256 __A) { (__v8di)_mm512_setzero_si512(), \ (__mmask8)(U), (int)(R))) -static __inline__ __m512d __DEFAULT_FN_ATTRS512 -_mm512_cvtepu64_pd (__m512i __A) { +static __inline__ __m512d __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_cvtepu64_pd(__m512i __A) { return (__m512d)__builtin_convertvector((__v8du)__A, __v8df); } -static __inline__ __m512d __DEFAULT_FN_ATTRS512 -_mm512_mask_cvtepu64_pd (__m512d __W, __mmask8 __U, __m512i __A) { +static __inline__ __m512d __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_mask_cvtepu64_pd(__m512d __W, __mmask8 __U, __m512i __A) { return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, (__v8df)_mm512_cvtepu64_pd(__A), (__v8df)__W); } -static __inline__ __m512d __DEFAULT_FN_ATTRS512 -_mm512_maskz_cvtepu64_pd (__mmask8 __U, __m512i __A) { +static __inline__ __m512d __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_maskz_cvtepu64_pd(__mmask8 __U, __m512i __A) { return (__m512d)__builtin_ia32_selectpd_512((__mmask8)__U, (__v8df)_mm512_cvtepu64_pd(__A), (__v8df)_mm512_setzero_pd()); diff --git a/clang/lib/Headers/avx512vlintrin.h b/clang/lib/Headers/avx512vlintrin.h index aa186c136bb53..a85c6fdd22e5d 100644 --- a/clang/lib/Headers/avx512vlintrin.h +++ b/clang/lib/Headers/avx512vlintrin.h @@ -1732,57 +1732,57 @@ _mm256_mask_compressstoreu_epi32 (void *__P, __mmask8 __U, __m256i __A) { (__mmask8) __U); } -static __inline__ __m128d __DEFAULT_FN_ATTRS128 -_mm_mask_cvtepi32_pd (__m128d __W, __mmask8 __U, __m128i __A) { +static __inline__ __m128d __DEFAULT_FN_ATTRS128_CONSTEXPR +_mm_mask_c
[clang] [X86] Add MMX/SSE/AVX PHADD/SUB & HADDPS/D intrinsics to be used in constexpr (PR #156822)
https://github.com/RKSimon edited https://github.com/llvm/llvm-project/pull/156822 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Add static methods for resource initialization and constructor from handle (PR #155866)
https://github.com/hekota updated https://github.com/llvm/llvm-project/pull/155866 >From 7a0d3ca684a2d95e0528d5f4ee77bc1306ddfe1d Mon Sep 17 00:00:00 2001 From: Helena Kotas Date: Thu, 28 Aug 2025 08:17:31 -0700 Subject: [PATCH 1/5] [HLSL] Reorder the arguments of handle initialization builtins Reorder the arguments of handle initialization builtins to match the order of the llvm intrinsics, and also to match the arguments on the static create methods for resources (coming soon). --- clang/lib/CodeGen/CGHLSLBuiltins.cpp| 8 clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp | 2 +- clang/lib/Sema/SemaHLSL.cpp | 4 ++-- clang/test/AST/HLSL/ByteAddressBuffers-AST.hlsl | 2 +- clang/test/AST/HLSL/StructuredBuffers-AST.hlsl | 2 +- clang/test/AST/HLSL/TypedBuffers-AST.hlsl | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/clang/lib/CodeGen/CGHLSLBuiltins.cpp b/clang/lib/CodeGen/CGHLSLBuiltins.cpp index 58165185b6711..483920f2392cd 100644 --- a/clang/lib/CodeGen/CGHLSLBuiltins.cpp +++ b/clang/lib/CodeGen/CGHLSLBuiltins.cpp @@ -348,10 +348,10 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID, } case Builtin::BI__builtin_hlsl_resource_handlefromimplicitbinding: { llvm::Type *HandleTy = CGM.getTypes().ConvertType(E->getType()); -Value *SpaceOp = EmitScalarExpr(E->getArg(1)); -Value *RangeOp = EmitScalarExpr(E->getArg(2)); -Value *IndexOp = EmitScalarExpr(E->getArg(3)); -Value *OrderID = EmitScalarExpr(E->getArg(4)); +Value *OrderID = EmitScalarExpr(E->getArg(1)); +Value *SpaceOp = EmitScalarExpr(E->getArg(2)); +Value *RangeOp = EmitScalarExpr(E->getArg(3)); +Value *IndexOp = EmitScalarExpr(E->getArg(4)); Value *Name = EmitScalarExpr(E->getArg(5)); // FIXME: NonUniformResourceIndex bit is not yet implemented // (llvm/llvm-project#135452) diff --git a/clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp b/clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp index 806800cb7b213..7830cdd18c6cd 100644 --- a/clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp +++ b/clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp @@ -670,7 +670,7 @@ BuiltinTypeDeclBuilder::addHandleConstructorFromImplicitBinding() { .addParam("orderId", AST.UnsignedIntTy) .addParam("name", AST.getPointerType(AST.CharTy.withConst())) .callBuiltin("__builtin_hlsl_resource_handlefromimplicitbinding", - HandleType, PH::Handle, PH::_0, PH::_1, PH::_2, PH::_3, + HandleType, PH::Handle, PH::_3, PH::_0, PH::_1, PH::_2, PH::_4) .assign(PH::Handle, PH::LastStmt) .finalize(); diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp index 6a68fa2ed7a8b..c12b35308e127 100644 --- a/clang/lib/Sema/SemaHLSL.cpp +++ b/clang/lib/Sema/SemaHLSL.cpp @@ -2853,8 +2853,8 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { if (SemaRef.checkArgCount(TheCall, 6) || CheckResourceHandle(&SemaRef, TheCall, 0) || CheckArgTypeMatches(&SemaRef, TheCall->getArg(1), AST.UnsignedIntTy) || -CheckArgTypeMatches(&SemaRef, TheCall->getArg(2), AST.IntTy) || -CheckArgTypeMatches(&SemaRef, TheCall->getArg(3), AST.UnsignedIntTy) || +CheckArgTypeMatches(&SemaRef, TheCall->getArg(2), AST.UnsignedIntTy) || +CheckArgTypeMatches(&SemaRef, TheCall->getArg(3), AST.IntTy) || CheckArgTypeMatches(&SemaRef, TheCall->getArg(4), AST.UnsignedIntTy) || CheckArgTypeMatches(&SemaRef, TheCall->getArg(5), AST.getPointerType(AST.CharTy.withConst( diff --git a/clang/test/AST/HLSL/ByteAddressBuffers-AST.hlsl b/clang/test/AST/HLSL/ByteAddressBuffers-AST.hlsl index f85194496942b..90794eb69ef46 100644 --- a/clang/test/AST/HLSL/ByteAddressBuffers-AST.hlsl +++ b/clang/test/AST/HLSL/ByteAddressBuffers-AST.hlsl @@ -97,10 +97,10 @@ RESOURCE Buffer; // CHECK-NEXT: DeclRefExpr {{.*}} '' Function {{.*}} '__builtin_hlsl_resource_handlefromimplicitbinding' // CHECK-NEXT: MemberExpr {{.*}} lvalue .__handle // CHECK-NEXT: CXXThisExpr {{.*}} 'hlsl::[[RESOURCE]]' lvalue implicit this +// CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' ParmVar {{.*}} 'orderId' 'unsigned int' // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' ParmVar {{.*}} 'spaceNo' 'unsigned int' // CHECK-NEXT: DeclRefExpr {{.*}} 'int' ParmVar {{.*}} 'range' 'int' // CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' ParmVar {{.*}} 'index' 'unsigned int' -// CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' ParmVar {{.*}} 'orderId' 'unsigned int' // CHECK-NEXT: DeclRefExpr {{.*}} 'const char *' ParmVar {{.*}} 'name' 'const char *' // CHECK-NEXT: AlwaysInlineAttr diff --git a/clang/test/AST/HLSL/StructuredBuffers-AST.hlsl b/clang/test/AST/HLSL/StructuredBuffers-AST.hlsl index 6ee7145c7e538..e028936e397ac 100644 --- a/clang/test/AST/HLSL/StructuredBuffers-AST.hlsl +++ b/clang/test/AST/HLSL/Struct
[clang] Add uniqueptr accesses to -Wunsafe-buffer-usage (PR #156773)
https://github.com/shreya-jain edited https://github.com/llvm/llvm-project/pull/156773 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][analyzer] Model `strxfrm` (PR #156507)
@@ -2243,6 +2246,102 @@ void CStringChecker::evalStrcpyCommon(CheckerContext &C, const CallEvent &Call, C.addTransition(state); } +void CStringChecker::evalStrxfrm(CheckerContext &C, + const CallEvent &Call) const { + // size_t strxfrm(char *dest, const char *src, size_t n); + CurrentFunctionDescription = "locale transformation function"; + + ProgramStateRef State = C.getState(); + const LocationContext *LCtx = C.getLocationContext(); + SValBuilder &SVB = C.getSValBuilder(); + + // Get arguments + DestinationArgExpr Dest = {{Call.getArgExpr(0), 0}}; + SourceArgExpr Source = {{Call.getArgExpr(1), 1}}; + SizeArgExpr Size = {{Call.getArgExpr(2), 2}}; + + // `src` can never be null + SVal SrcVal = State->getSVal(Source.Expression, LCtx); + State = checkNonNull(C, State, Source, SrcVal); + if (!State) +return; + + // Check overlaps + State = CheckOverlap(C, State, Size, Dest, Source, CK_Regular); + if (!State) +return; + + // The function returns an implementation-defined length needed for + // transformation + SVal RetVal = SVB.conjureSymbolVal(Call, C.blockCount()); + + State = State->BindExpr(Call.getOriginExpr(), LCtx, RetVal); + + // Check if size is zero + SVal SizeVal = State->getSVal(Size.Expression, LCtx); + QualType SizeTy = Size.Expression->getType(); + + auto [StateZeroSize, StateSizeNonZero] = + assumeZero(C, State, SizeVal, SizeTy); + + // If `n` is 0, we just return the implementation defined length + if (StateZeroSize && !StateSizeNonZero) { +C.addTransition(StateZeroSize); +return; + } + + if (!StateSizeNonZero) +return; balazs-benics-sonarsource wrote: This is an evalCall handler, right? And we return here without transitioning to a state where the result value is bound. This comment might also apply to the rest of the return paths below this one. https://github.com/llvm/llvm-project/pull/156507 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [Clang-Tidy] Add google-runtime-float Clang-Tidy check (PR #156763)
https://github.com/brenfwd created https://github.com/llvm/llvm-project/pull/156763 Add a new checker to clang-tidy for use of the `long double` type [per Google style guide](https://google.github.io/styleguide/cppguide.html#Floating-Point_Types). >From 1082254d96f3c427f4cb867fcf964c19655e1876 Mon Sep 17 00:00:00 2001 From: Brenden Forward Date: Tue, 2 Sep 2025 18:16:46 -0700 Subject: [PATCH] Add google-runtime-float Clang-Tidy check --- .../clang-tidy/google/CMakeLists.txt | 1 + .../clang-tidy/google/FloatTypesCheck.cpp | 80 +++ .../clang-tidy/google/FloatTypesCheck.h | 44 ++ .../clang-tidy/google/GoogleTidyModule.cpp| 3 + clang-tools-extra/docs/ReleaseNotes.rst | 6 ++ .../checks/google/runtime-float.rst | 11 +++ .../docs/clang-tidy/checks/list.rst | 3 +- .../checkers/google/runtime-float.cpp | 39 + 8 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 clang-tools-extra/clang-tidy/google/FloatTypesCheck.cpp create mode 100644 clang-tools-extra/clang-tidy/google/FloatTypesCheck.h create mode 100644 clang-tools-extra/docs/clang-tidy/checks/google/runtime-float.rst create mode 100644 clang-tools-extra/test/clang-tidy/checkers/google/runtime-float.cpp diff --git a/clang-tools-extra/clang-tidy/google/CMakeLists.txt b/clang-tools-extra/clang-tidy/google/CMakeLists.txt index 2470c089ef7ca..1d4229ebb7b09 100644 --- a/clang-tools-extra/clang-tidy/google/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/google/CMakeLists.txt @@ -11,6 +11,7 @@ add_clang_library(clangTidyGoogleModule STATIC DefaultArgumentsCheck.cpp ExplicitConstructorCheck.cpp ExplicitMakePairCheck.cpp + FloatTypesCheck.cpp FunctionNamingCheck.cpp GlobalNamesInHeadersCheck.cpp GlobalVariableDeclarationCheck.cpp diff --git a/clang-tools-extra/clang-tidy/google/FloatTypesCheck.cpp b/clang-tools-extra/clang-tidy/google/FloatTypesCheck.cpp new file mode 100644 index 0..b8afe803230d3 --- /dev/null +++ b/clang-tools-extra/clang-tidy/google/FloatTypesCheck.cpp @@ -0,0 +1,80 @@ +//===--===// +// +// 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 "FloatTypesCheck.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/Lex/Lexer.h" + +namespace clang { + +using namespace ast_matchers; + +namespace { + +AST_MATCHER(TypeLoc, isTypeLocValidAndNotInMacro) { + const SourceLocation Loc = Node.getBeginLoc(); + return Loc.isValid() && !Loc.isMacroID(); +} + +AST_MATCHER(FloatingLiteral, isFLValidAndNotInMacro) { + const SourceLocation Loc = Node.getBeginLoc(); + return Loc.isValid() && !Loc.isMacroID(); +} + +AST_MATCHER(TypeLoc, isLongDoubleType) { + TypeLoc TL = Node; + if (auto QualLoc = Node.getAs()) +TL = QualLoc.getUnqualifiedLoc(); + + const auto BuiltinLoc = TL.getAs(); + if (!BuiltinLoc) +return false; + + return BuiltinLoc.getTypePtr()->getKind() == BuiltinType::LongDouble; +} + +AST_MATCHER(FloatingLiteral, isLongDoubleLiteral) { + if (auto *BT = dyn_cast(Node.getType().getTypePtr())) +return BT->getKind() == BuiltinType::LongDouble; + return false; +} + +} // namespace + +namespace tidy::google::runtime { + +void RuntimeFloatCheck::registerMatchers(MatchFinder *Finder) { + Finder->addMatcher(typeLoc(loc(realFloatingPointType()), + isTypeLocValidAndNotInMacro(), isLongDoubleType()) + .bind("longDoubleTypeLoc"), + this); + Finder->addMatcher( + floatLiteral(isFLValidAndNotInMacro(), isLongDoubleLiteral()) + .bind("longDoubleFloatLiteral"), + this); + IdentTable = std::make_unique(getLangOpts()); +} + +void RuntimeFloatCheck::check(const MatchFinder::MatchResult &Result) { + if (const auto *TL = Result.Nodes.getNodeAs("longDoubleTypeLoc")) { +diag(TL->getBeginLoc(), + "consider replacing %0 with a 64-bit or 128-bit float type") +<< TL->getType(); + } + + if (const auto *FL = + Result.Nodes.getNodeAs("longDoubleFloatLiteral")) { +diag(FL->getBeginLoc(), + "%0 type from literal suffix 'L' should not be used") +<< FL->getType(); + } +} + +} // namespace tidy::google::runtime + +} // namespace clang diff --git a/clang-tools-extra/clang-tidy/google/FloatTypesCheck.h b/clang-tools-extra/clang-tidy/google/FloatTypesCheck.h new file mode 100644 index 0..54327b6d7e53b --- /dev/null +++ b/clang-tools-extra/clang-tidy/google/FloatTypesCheck.h @@ -0,0 +1,44 @@ + +//===--===// +// +// Part of the LLVM Project, under the Apache License v2.
[clang] [clang][PAC] Fix builtins that claim address discriminated types are bitwise compatible (PR #154490)
@@ -656,8 +656,7 @@ class ASTContext : public RefCountedBase { bool containsNonRelocatablePointerAuth(QualType T) { if (!isPointerAuthenticationAvailable()) return false; -return findPointerAuthContent(T) == - PointerAuthContent::AddressDiscriminatedData; +return findPointerAuthContent(T) != PointerAuthContent::None; pcc wrote: Since this function and `containsAddressDiscriminatedPointerAuth` now do the same thing, can we remove one of them? https://github.com/llvm/llvm-project/pull/154490 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] Extend test coverage for SVE/SME builtin usage. (PR #156908)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r origin/main...HEAD clang/utils/aarch64_builtins_test_generator.py `` :warning: The reproduction instructions above might return results for more than one PR in a stack if you are using a stacked PR workflow. You can limit the results by changing `origin/main` to the base branch/commit you want to compare against. :warning: View the diff from darker here. ``diff --- aarch64_builtins_test_generator.py 2025-09-04 15:15:53.00 + +++ aarch64_builtins_test_generator.py 2025-09-04 15:20:52.422430 + @@ -24,37 +24,43 @@ from enum import Enum from itertools import product from pathlib import Path from typing import Dict, Iterable, List, Sequence, Tuple + # Are we testing arm_sve.h or arm_sme.h based builtins. class Mode(Enum): SVE = "sve" SME = "sme" + class FunctionType(Enum): NORMAL = "normal" STREAMING = "streaming" STREAMING_COMPATIBLE = "streaming-compatible" + # Builtins are grouped by their required features. @dataclass(frozen=True, order=True, slots=True) class BuiltinContext: guard: str streaming_guard: str flags: tuple[str, ...] def __str__(self) -> str: -return (f'// Properties: ' -f'guard="{self.guard}" ' -f'streaming_guard="{self.streaming_guard}" ' -f'flags="{",".join(self.flags)}"') +return ( +f"// Properties: " +f'guard="{self.guard}" ' +f'streaming_guard="{self.streaming_guard}" ' +f'flags="{",".join(self.flags)}"' +) @classmethod def from_json(cls, obj: dict[str, Any]) -> "BuiltinContext": flags = tuple(p.strip() for p in obj["flags"].split(",") if p.strip()) return cls(obj["guard"], obj["streaming_guard"], flags) + # --- Parsing builtins --- # Captures the full function *declaration* inside the builtin string, e.g.: # "svint16_t svrevd_s16_z(svbool_t, svint16_t);" @@ -63,10 +69,11 @@ FUNC_RE = re.compile(r"^\s*([a-zA-Z_][\w\s\*]*[\w\*])\s*\(\s*([^)]*)\s*\)\s*;\s*$") # Pulls the final word out of the left side (the function name). NAME_RE = re.compile(r"([a-zA-Z_][\w]*)\s*$") + def parse_builtin_declaration(decl: str) -> Tuple[str, List[str]]: """Return (func_name, param_types) from a builtin declaration string. Example: decl = "svint16_t svrevd_s16_z(svbool_t, svint16_t);" @@ -86,13 +93,14 @@ if not params: param_types: List[str] = [] else: # Split by commas respecting no pointers/arrays with commas (not expected here) -param_types = [p.strip() for p in params.split(',') if p.strip()] +param_types = [p.strip() for p in params.split(",") if p.strip()] return func_name, param_types + # --- Variable synthesis - # Pick a safe (ideally non-zero) value for literal types LITERAL_TYPES_MAP: dict[str, str] = { @@ -123,12 +131,13 @@ "ImmCheckShiftLeft": "2", "ImmCheckShiftRightNarrow": "2", "ImmCheckShiftRight": "2", "enum svpattern": "SV_MUL3", "enum svprfop": "SV_PSTL1KEEP", -"void": "" -} +"void": "", +} + def make_arg_for_type(ty: str) -> Tuple[str, str]: """Return (var_decl, var_use) for a parameter type. Literal types return an empty declaration and a value that will be accepted @@ -140,22 +149,25 @@ return "", LITERAL_TYPES_MAP[ty] name = ty.replace(" ", "_").replace("*", "ptr") + "_val" return f"{ty} {name};", name + # NOTE: Parsing is limited to the minimum required for guard strings. # Specifically the expected input is of the form: # feat1,feat2,...(feat3 | feat4 | ...),... -def expand_feature_guard(guard: str, flags: str, base_feature: str = None) -> list[set[str]]: +def expand_feature_guard( +guard: str, flags: str, base_feature: str = None +) -> list[set[str]]: """ Expand a guard expression where ',' = AND and '|' = OR, with parentheses grouping OR-expressions. Returns a list of feature sets. """ if not guard: -return []; - -parts = re.split(r',(?![^(]*\))', guard) +return [] + +parts = re.split(r",(?![^(]*\))", guard) choices_per_part = [] for part in parts: if part.startswith("(") and part.endswith(")"): choices_per_part.append(part[1:-1].split("|")) @@ -183,12 +195,14 @@ if s not in unique: unique.append(s) return unique + def cc1_args_for_features(features: set[str]) -> str: return " ".join("-target-feature +" + s for s in sorted(features)) + def sanitise_guard(s: str) -> str: """Rewrite guard strings in a form more suitable for fil
[clang] [llvm] [WIP] ABI Lowering Library (PR #140112)
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/140112 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [X86] make the set/r/4 intrinsics macros into functions (PR #156819)
https://github.com/RKSimon edited https://github.com/llvm/llvm-project/pull/156819 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][bytecode] Create implicit variables for wider base types (PR #156658)
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/156658 >From f5221110b55a8c23beaf4b4d33f857238faa0de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Wed, 3 Sep 2025 14:45:20 +0200 Subject: [PATCH] [clang][bytecode] Create implicit variables for wider base types If we create an implicit local variable for a derived-to-base cast, we still should allocate enough space for the entire derived type. Fixes #156219 --- clang/lib/AST/ByteCode/Compiler.cpp | 41 +++-- clang/test/AST/ByteCode/cxx03.cpp | 11 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 89ff5d27a4143..3f30e524ab179 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -4191,6 +4191,31 @@ template bool Compiler::delegate(const Expr *E) { return this->Visit(E); } +static const Expr *stripCheckedDerivedToBaseCasts(const Expr *E) { + if (const auto *PE = dyn_cast(E)) +return stripCheckedDerivedToBaseCasts(PE->getSubExpr()); + + if (const auto *CE = dyn_cast(E); + CE && + (CE->getCastKind() == CK_DerivedToBase || CE->getCastKind() == CK_NoOp)) +return stripCheckedDerivedToBaseCasts(CE->getSubExpr()); + + return E; +} + +static const Expr *stripDerivedToBaseCasts(const Expr *E) { + if (const auto *PE = dyn_cast(E)) +return stripDerivedToBaseCasts(PE->getSubExpr()); + + if (const auto *CE = dyn_cast(E); + CE && (CE->getCastKind() == CK_DerivedToBase || + CE->getCastKind() == CK_UncheckedDerivedToBase || + CE->getCastKind() == CK_NoOp)) +return stripDerivedToBaseCasts(CE->getSubExpr()); + + return E; +} + template bool Compiler::visit(const Expr *E) { if (E->getType().isNull()) return false; @@ -4200,7 +4225,7 @@ template bool Compiler::visit(const Expr *E) { // Create local variable to hold the return value. if (!E->isGLValue() && !canClassify(E->getType())) { -UnsignedOrNone LocalIndex = allocateLocal(E); +UnsignedOrNone LocalIndex = allocateLocal(stripDerivedToBaseCasts(E)); if (!LocalIndex) return false; @@ -5078,18 +5103,6 @@ bool Compiler::VisitBuiltinCallExpr(const CallExpr *E, return true; } -static const Expr *stripDerivedToBaseCasts(const Expr *E) { - if (const auto *PE = dyn_cast(E)) -return stripDerivedToBaseCasts(PE->getSubExpr()); - - if (const auto *CE = dyn_cast(E); - CE && - (CE->getCastKind() == CK_DerivedToBase || CE->getCastKind() == CK_NoOp)) -return stripDerivedToBaseCasts(CE->getSubExpr()); - - return E; -} - template bool Compiler::VisitCallExpr(const CallExpr *E) { const FunctionDecl *FuncDecl = E->getDirectCallee(); @@ -5194,7 +5207,7 @@ bool Compiler::VisitCallExpr(const CallExpr *E) { const auto *InstancePtr = MC->getImplicitObjectArgument(); if (isa_and_nonnull(CompilingFunction) || isa_and_nonnull(CompilingFunction)) { -const auto *Stripped = stripDerivedToBaseCasts(InstancePtr); +const auto *Stripped = stripCheckedDerivedToBaseCasts(InstancePtr); if (isa(Stripped)) { FuncDecl = cast(FuncDecl)->getCorrespondingMethodInClass( diff --git a/clang/test/AST/ByteCode/cxx03.cpp b/clang/test/AST/ByteCode/cxx03.cpp index 70ae4134842b5..10e5232b9f873 100644 --- a/clang/test/AST/ByteCode/cxx03.cpp +++ b/clang/test/AST/ByteCode/cxx03.cpp @@ -29,3 +29,14 @@ void LambdaAccessingADummy() { int d; int a9[1] = {[d = 0] = 1}; // both-error {{is not an integral constant expression}} } + +const int p = 10; +struct B { + int a; + void *p; +}; +struct B2 : B { + void *q; +}; +_Static_assert(&(B2().a) == &p, ""); // both-error {{taking the address of a temporary object of type 'int'}} \ + // both-error {{not an integral constant expression}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Polymorphic Cleanup type is moved despite not being POD types (PR #156607)
https://github.com/efriedma-quic approved this pull request. I've reviewed other changes here recently (#152866). The code is playing some weird games with memory allocation, using an std::vector as an arena. Probably there's some better way to write this. Strictly speaking, it's undefined behavior to memmove a polymorphic class. But this is how it works for now. Maybe worth leaving a comment explaining this. Otherwise LGTM https://github.com/llvm/llvm-project/pull/156607 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Rewrite tests relying on shell environment variable features (PR #156904)
@@ -10,7 +8,9 @@ // RUN: echo "@subdir/cfg-s2" > %t/workdir/cfg-1 // RUN: echo "-Wundefined-var-template" > %t/workdir/subdir/cfg-s2 // -// RUN: ( cd %t && %clang --config=workdir/cfg-1 -c -### %s 2>&1 | FileCheck %s -check-prefix CHECK-REL ) +// RUN: pushd %t +// RUN: %clang --config=workdir/cfg-1 -c -### %s 2>&1 | FileCheck %s -check-prefix CHECK-REL +// RUN: popd // // CHECK-REL: Configuration file: {{.*}}/workdir/cfg-1 boomanaiden154 wrote: It's failing due to the FileCheck lines using forward slashes, but Windows using backward slashes by default. (which is what you pointed out here but not something I realized until later). This test also requires symlinks. I'm just going to mark it unsupported since we aren't using any test coverage. https://github.com/llvm/llvm-project/pull/156904 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Allow non-constant sizes for __builtin_assume_dereferenceable. (PR #156929)
https://github.com/philnik777 edited https://github.com/llvm/llvm-project/pull/156929 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL][NFC] Change line endings to LF (PR #156930)
https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/156930 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libunwind] [llvm] [wasm] Toolchain support for `wasm32-wali-linux-musl` target (PR #156087)
@@ -6,6 +6,8 @@ // //===--===// +#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__wasm__) dschuff wrote: `__USING_SJLJ_EXCEPTIONS__` is not just used by wasm. So this is going to affect other platforms, e.g. by adding the definitions below and NO_EXEC_STACK_DIRECTIVE below. Is that intentional? https://github.com/llvm/llvm-project/pull/156087 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libunwind] [llvm] [wasm] Toolchain support for `wasm32-wali-linux-musl` target (PR #156087)
@@ -88,12 +88,20 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public TargetInfo { LongDoubleWidth = LongDoubleAlign = 128; LongDoubleFormat = &llvm::APFloat::IEEEquad(); MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64; -// size_t being unsigned long for both wasm32 and wasm64 makes mangled names -// more consistent between the two. -SizeType = UnsignedLong; -PtrDiffType = SignedLong; -IntPtrType = SignedLong; HasUnalignedAccess = true; +if (T.isWALI()) { + // WALI ABI requires 64-bit longs on both wasm32 and wasm64 dschuff wrote: Can you add a link to the ABI document (minimal as it is) here? Also, you mention wasm64 here but you didn't actually add support or tests for wasm64 in this PR. https://github.com/llvm/llvm-project/pull/156087 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU][gfx1250] Add 128B cooperative atomics (PR #156418)
https://github.com/Pierre-vh closed https://github.com/llvm/llvm-project/pull/156418 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add template argument support for {con,de}structor attributes. (PR #151400)
@@ -234,6 +234,32 @@ static void instantiateDependentAnnotationAttr( } } +template +static void sharedInstantiateConstructorDestructorAttr( +Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs, const Attr *A, +Decl *New, ASTContext &C) { + Expr *tempInstPriority = nullptr; + { +EnterExpressionEvaluationContext Unevaluated( +S, Sema::ExpressionEvaluationContext::Unevaluated); +ExprResult Result = S.SubstExpr(A->getPriority(), TemplateArgs); +if (Result.isInvalid()) + return; +tempInstPriority = Result.get(); +if (std::optional CE = +tempInstPriority->getIntegerConstantExpr(C)) { + // Consistent with non-templated priority arguments, which must fit in a + // 32-bit unsigned integer. + if (!CE->isIntN(32)) { +S.Diag(tempInstPriority->getExprLoc(), diag::err_ice_too_large) +<< toString(*CE, 10, false) << /*Size=*/32 << /*Unsigned=*/1; +return; + } +} + } + New->addAttr(new (C) Attr(C, *A, tempInstPriority)); erichkeane wrote: ```suggestion New->addAttr(Attr::Create(C, *A, tempInstPriority)); ``` Forgot about these, we auto generate 'create' functions for attributes, since we can do automated work in them. We are ... in transition to switching to the 'Create' functions. https://github.com/llvm/llvm-project/pull/151400 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [WPD]: Apply speculative WPD in non-lto mode. (PR #145031)
@@ -5170,7 +5174,7 @@ Execute ``clang-cl /?`` to see a list of supported options: -fstandalone-debug Emit full debug info for all types used by the program -fstrict-aliasing Enable optimizations based on strict aliasing rules -fsyntax-only Run the preprocessor, parser and semantic analysis stages - -fwhole-program-vtables Enables whole-program vtable optimization. Requires -flto + -fwhole-program-vtables Enables whole-program vtable optimization. teresajohnson wrote: gcc has an option called -fdevirtualize-speculatively, that describes what is being enabled here: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fdevirtualize-speculatively How about adding that to clang and using it to enable this instead of -fwhole-program-vtables, which doesn't really make sense as what is being enabled isn't whole program in this case. https://github.com/llvm/llvm-project/pull/145031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Emit initializers for static const/constexpr variables once they're met (PR #156933)
rjmccall wrote: > It seems once codegen meets an odr use of the variable, it doesn't emit the > initializer, only the global variable itself. Then while emitting some > function's body it meets the variable declaration, and if it was a static > variable it adds the initializer via AddInitializerToStaticVarDecl. consteval > function bodies are never handled by CodeGen, hence missing initializers. > This patch makes sure they won't be missing. That makes sense. I think the cleaner way of handling it is probably to just fit it into the existing lazy-emission system, `DeferredDeclsToEmit`. In fact, we should be able to do that for every static local variable with a constant-expression initializer: don't emit them eagerly when we walk the function body, call `addDeferredDeclToEmit` whenever we ODR-use them for the first time, and then make sure `EmitDeferredDecl` does the right thing for them. > Even if a variable is usable in constant expressions? I believe so, yes. Taking the address of an object of static storage duration is generally allowed in constant expressions, and there's no restriction against that being the current declaration or otherwise forming cycles. https://github.com/llvm/llvm-project/pull/156933 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 46a3b4d - [clang] Rewrite tests relying on shell environment variable features
Author: Aiden Grossman Date: 2025-09-04T11:17:53-07:00 New Revision: 46a3b4d5dc6dd9449ec7c0c9065552368cdf41d6 URL: https://github.com/llvm/llvm-project/commit/46a3b4d5dc6dd9449ec7c0c9065552368cdf41d6 DIFF: https://github.com/llvm/llvm-project/commit/46a3b4d5dc6dd9449ec7c0c9065552368cdf41d6.diff LOG: [clang] Rewrite tests relying on shell environment variable features This patch rewrites a couple tsts that fail when running with lit's internal shell enabled due to assumptions about setting environment variables. There were a couple cases where there was an implict env. Most of the cases needed unset swapped for env -u. Toeards #102699. Reviewers: petrhosek, efriedma-quic, Sirraide, carlocab, rnk, ilovepi Reviewed By: carlocab, rnk, ilovepi Pull Request: https://github.com/llvm/llvm-project/pull/156904 Added: Modified: clang/test/Driver/config-file3.c clang/test/Driver/config-zos.c clang/test/Driver/config-zos1.c clang/test/Driver/coverage.c clang/test/Modules/crash-vfs-path-symlink-component.m clang/test/Modules/crash-vfs-path-traversal.m clang/test/Modules/crash-vfs-relative-overlay.m Removed: diff --git a/clang/test/Driver/config-file3.c b/clang/test/Driver/config-file3.c index 395c31ce04b6b..7de77af330f6d 100644 --- a/clang/test/Driver/config-file3.c +++ b/clang/test/Driver/config-file3.c @@ -1,7 +1,7 @@ -// REQUIRES: shell +// Needs symlinks +// UNSUPPORTED: system-windows // REQUIRES: x86-registered-target -// RUN: unset CLANG_NO_DEFAULT_CONFIG // RUN: rm -rf %t && mkdir %t //--- If config file is specified by relative path (workdir/cfg-s2), it is searched for by that path. @@ -10,7 +10,9 @@ // RUN: echo "@subdir/cfg-s2" > %t/workdir/cfg-1 // RUN: echo "-Wundefined-var-template" > %t/workdir/subdir/cfg-s2 // -// RUN: ( cd %t && %clang --config=workdir/cfg-1 -c -### %s 2>&1 | FileCheck %s -check-prefix CHECK-REL ) +// RUN: pushd %t +// RUN: %clang --config=workdir/cfg-1 -c -### %s 2>&1 | FileCheck %s -check-prefix CHECK-REL +// RUN: popd // // CHECK-REL: Configuration file: {{.*}}/workdir/cfg-1 // CHECK-REL: -Wundefined-var-template @@ -51,84 +53,84 @@ // RUN: touch %t/testdmode/clang++.cfg // RUN: touch %t/testdmode/clang-g++.cfg // RUN: touch %t/testdmode/clang.cfg -// RUN: %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' // // FULL1: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang++.cfg //--- -m32 overrides triple. // -// RUN: %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' // // FULL1-I386: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang++.cfg //--- --target= also works for overriding triple. // -// RUN: %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --target=i386-unknown-linux-gnu --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --target=i386-unknown-linux-gnu --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' //--- With --target= + -m64, -m64 takes precedence. // -// RUN: %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --target=i386-unknown-linux-gnu -m64 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' +// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --target=i386-unknown-linux-gnu -m64 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1 --implicit-check-not 'Configuration file:' //--- i386 prefix also works for 32-bit. // -// RUN: %t/testdmode/i386-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386 --implicit-check-not 'Configuration file:' +// RUN: env
[clang] [clang] Rewrite tests relying on shell environment variable features (PR #156904)
https://github.com/boomanaiden154 closed https://github.com/llvm/llvm-project/pull/156904 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][HIP][CUDA] Add `__cluster_dims__` and `__no_cluster__` attribute (PR #156686)
@@ -1557,6 +1557,23 @@ def HIPManaged : InheritableAttr { let Documentation = [HIPManagedAttrDocs]; } +def CUDAClusterDims : InheritableAttr { + let Spellings = [GNU<"cluster_dims">, Declspec<"__cluster_dims__">]; + let Args = [ExprArgument<"X">, ExprArgument<"Y", 1>, ExprArgument<"Z", 1>]; + let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">; + let LangOpts = [CUDA]; + let Documentation = [CUDAClusterDimsAttrDoc]; +} + +def CUDANoCluster : InheritableAttr { + let Spellings = [GNU<"no_cluster">, Declspec<"__no_cluster__">]; + let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">; + let LangOpts = [CUDA]; arsenm wrote: I'd leave it, the fewer arbitrary restrictions the better https://github.com/llvm/llvm-project/pull/156686 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Headers][X86] Allow AVX512 integer min/max mask/maskz variants intrinsics to be used in constexpr (PR #156901)
https://github.com/markbhasawut updated https://github.com/llvm/llvm-project/pull/156901 >From 7147ee319ecbf309042c25b9483ba1fea9161778 Mon Sep 17 00:00:00 2001 From: Bhasawut Singhaphan Date: Thu, 4 Sep 2025 21:41:54 +0700 Subject: [PATCH] [Headers][X86] Allow AVX512 integer min/max mask/maskz variants intrinsics to be used in constexpr Update the AVX512 integer min/max mask/maskz variants intrinsics to be constexpr compatible. This is the last in the 'Allow MMX/SSE/AVX2/AVX512 integer min/max intrinsics to be used in constexpr' series. --- clang/lib/Headers/avx512fintrin.h | 80 +-- clang/test/CodeGen/X86/avx512f-builtins.c | 34 +- 2 files changed, 65 insertions(+), 49 deletions(-) diff --git a/clang/lib/Headers/avx512fintrin.h b/clang/lib/Headers/avx512fintrin.h index 3e285f031ffe8..b9475d3f1d410 100644 --- a/clang/lib/Headers/avx512fintrin.h +++ b/clang/lib/Headers/avx512fintrin.h @@ -1091,17 +1091,15 @@ static __inline __m512i return (__m512i)__builtin_elementwise_max((__v16si)__A, (__v16si)__B); } -static __inline__ __m512i __DEFAULT_FN_ATTRS512 -_mm512_mask_max_epi32 (__m512i __W, __mmask16 __M, __m512i __A, __m512i __B) -{ +static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_mask_max_epi32(__m512i __W, __mmask16 __M, __m512i __A, __m512i __B) { return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, (__v16si)_mm512_max_epi32(__A, __B), (__v16si)__W); } -static __inline__ __m512i __DEFAULT_FN_ATTRS512 -_mm512_maskz_max_epi32 (__mmask16 __M, __m512i __A, __m512i __B) -{ +static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_maskz_max_epi32(__mmask16 __M, __m512i __A, __m512i __B) { return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, (__v16si)_mm512_max_epi32(__A, __B), (__v16si)_mm512_setzero_si512()); @@ -1112,17 +1110,15 @@ _mm512_max_epu32(__m512i __A, __m512i __B) { return (__m512i)__builtin_elementwise_max((__v16su)__A, (__v16su)__B); } -static __inline__ __m512i __DEFAULT_FN_ATTRS512 -_mm512_mask_max_epu32 (__m512i __W, __mmask16 __M, __m512i __A, __m512i __B) -{ +static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_mask_max_epu32(__m512i __W, __mmask16 __M, __m512i __A, __m512i __B) { return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, (__v16si)_mm512_max_epu32(__A, __B), (__v16si)__W); } -static __inline__ __m512i __DEFAULT_FN_ATTRS512 -_mm512_maskz_max_epu32 (__mmask16 __M, __m512i __A, __m512i __B) -{ +static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_maskz_max_epu32(__mmask16 __M, __m512i __A, __m512i __B) { return (__m512i)__builtin_ia32_selectd_512((__mmask16)__M, (__v16si)_mm512_max_epu32(__A, __B), (__v16si)_mm512_setzero_si512()); @@ -1133,17 +1129,15 @@ _mm512_max_epi64(__m512i __A, __m512i __B) { return (__m512i)__builtin_elementwise_max((__v8di)__A, (__v8di)__B); } -static __inline__ __m512i __DEFAULT_FN_ATTRS512 -_mm512_mask_max_epi64 (__m512i __W, __mmask8 __M, __m512i __A, __m512i __B) -{ +static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_mask_max_epi64(__m512i __W, __mmask8 __M, __m512i __A, __m512i __B) { return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, (__v8di)_mm512_max_epi64(__A, __B), (__v8di)__W); } -static __inline__ __m512i __DEFAULT_FN_ATTRS512 -_mm512_maskz_max_epi64 (__mmask8 __M, __m512i __A, __m512i __B) -{ +static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_maskz_max_epi64(__mmask8 __M, __m512i __A, __m512i __B) { return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, (__v8di)_mm512_max_epi64(__A, __B), (__v8di)_mm512_setzero_si512()); @@ -1154,17 +1148,15 @@ _mm512_max_epu64(__m512i __A, __m512i __B) { return (__m512i)__builtin_elementwise_max((__v8du)__A, (__v8du)__B); } -static __inline__ __m512i __DEFAULT_FN_ATTRS512 -_mm512_mask_max_epu64 (__m512i __W, __mmask8 __M, __m512i __A, __m512i __B) -{ +static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR +_mm512_mask_max_epu64(__m512i __W, __mmask8 __M, __m512i __A, __m512i __B) { return (__m512i)__builtin_ia32_selectq_512((__mmask8)__M, (__v8di)_mm512_max_epu64(__A, __B), (__v8di)__W); } -static __inline__ __m512i __DEFAULT_FN_ATTRS512 -_mm512_maskz_max_epu64 (__mmask8 __M, __m512i __A, __m512i __B) -{ +static __inline__ __m512i __DEFAULT_FN_ATTRS512_CONSTEXPR +_m
[clang] [flang] [Driver][LoongArch] Enable linker relaxation by default for loongarch64 (PR #156315)
SixWeining wrote: > Should it be recorded in clang release note? Yes, I think so. https://github.com/llvm/llvm-project/pull/156315 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 36fb493 - [analyzer] Clean up bug types in CallAndMessageChecker (#156073)
Author: Donát Nagy Date: 2025-09-04T15:50:20+02:00 New Revision: 36fb493b8f42b5585acf0a1ffd918eca202e5775 URL: https://github.com/llvm/llvm-project/commit/36fb493b8f42b5585acf0a1ffd918eca202e5775 DIFF: https://github.com/llvm/llvm-project/commit/36fb493b8f42b5585acf0a1ffd918eca202e5775.diff LOG: [analyzer] Clean up bug types in CallAndMessageChecker (#156073) In CallAndMessageChecker the initialization of bug types was highly obfuscated (even compared to other `mutable std::unique_ptr` hacks). This commit cleans up this situation and removes a totally superfluous hidded 'modeling' sub-checker that did not have any role apart from obstructing the normal initialization of bug types. (Note that if we need to reintroduce CallAndMessageModeling in the future, we can do it cleanly within the CheckerFamily framework, so we wouldn't need to re-obfuscate the bug type initialization.) This change is mostly non-functional, the only visible change is the removal of the hidden modeling checker. Added: Modified: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp clang/test/Analysis/analyzer-enabled-checkers.c clang/test/Analysis/std-c-library-functions-arg-enabled-checkers.c Removed: diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td index 8905c62c01e49..c6c856bf7a773 100644 --- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -143,68 +143,49 @@ def BitwiseShiftChecker : Checker<"BitwiseShift">, ]>, Documentation; -def CallAndMessageModeling : Checker<"CallAndMessageModeling">, - HelpText<"Responsible for essential modeling and assumptions after a " - "function/method call. For instance, if we can't reason about the " - "nullability of the implicit this parameter after a method call, " - "this checker conservatively assumes it to be non-null">, - Documentation, - Hidden; - -def CallAndMessageChecker : Checker<"CallAndMessage">, - HelpText<"Check for logical errors for function calls and Objective-C " - "message expressions (e.g., uninitialized arguments, null function " - "pointers)">, - CheckerOptions<[ -CmdLineOption, -CmdLineOption, -CmdLineOption, -CmdLineOption, -CmdLineOption, -CmdLineOption, -CmdLineOption, -CmdLineOption, - ]>, - Documentation, - Dependencies<[CallAndMessageModeling]>; +def CallAndMessageChecker +: Checker<"CallAndMessage">, + HelpText< + "Check for logical errors for function calls and Objective-C " + "message expressions (e.g., uninitialized arguments, null function " + "pointers)">, + CheckerOptions< + [CmdLineOption, + CmdLineOption< + Boolean, "ParameterCount", + "Check whether a function was called with the appropriate " + "number of arguments", + "true", Released>, + CmdLineOption, + CmdLineOption< + Boolean, "CXXDeallocationArg", + "Check whether the argument of operator delete is undefined", + "true", Released>, + CmdLineOption, + CmdLineOption, + CmdLineOption< + Boolean, "NilReceiver", + "Check whether the reciever in the message expression is nil", + "true", Released>, + CmdLineOption< + Boolean, "UndefReceiver", + "Check whether the reciever in the message expression is " + "undefined", + "true", Released>, +]>, + Documentation; def FixedAddressDereferenceChecker : Checker<"FixedAddressDereference">, diff --git a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp index e98710aadacf2..b304350e0a2ef 100644 --- a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp @@ -31,34 +31,38 @@ namespace { class CallAndMessageChecker : public Checker { - mutable std::unique_ptr BT_call_null; - mutable std::unique_ptr BT_call_undef; - mutable std::unique_ptr BT_cxx_call_null; - mutable std::unique_ptr BT_cxx_call_undef; - mutable std::unique_ptr BT_call_arg; - mutable std::unique_ptr BT_cxx_delete_undef; - mutable std::unique_ptr BT_msg_undef; - mutable std::unique_ptr BT_objc_prop_undef; - mutable std::unique_ptr BT_objc_subscript_undef; - mutable std::unique_ptr BT_msg_arg; - mutable std::unique_ptr BT_msg_ret; - mutable std::unique_ptr BT_call_few_args; + const BugType CallNullBug{ + this, "Called function pointer is null (null dereference)"}; + const BugType CallUndefBug{
[clang] [llvm] [HLSL][NFC] Change line endings to LF (PR #156930)
llvmbot wrote: @llvm/pr-subscribers-backend-spir-v Author: Helena Kotas (hekota) Changes Changes line endings in files related to HLSL to LF (`\n`). --- Patch is 550.08 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/156930.diff 92 Files Affected: - (modified) clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp (+273-273) - (modified) clang/lib/CodeGen/HLSLBufferLayoutBuilder.h (+47-47) - (modified) clang/test/AST/HLSL/is_structured_resource_element_compatible_concept.hlsl (+15-15) - (modified) clang/test/AST/HLSL/is_typed_resource_element_compatible_concept.hlsl (+9-9) - (modified) clang/test/CodeGenHLSL/builtins/asint16.hlsl (+60-60) - (modified) clang/test/CodeGenHLSL/builtins/asuint16.hlsl (+60-60) - (modified) clang/test/CodeGenHLSL/builtins/atan2-overloads.hlsl (+123-123) - (modified) clang/test/CodeGenHLSL/builtins/atan2.hlsl (+59-59) - (modified) clang/test/CodeGenHLSL/builtins/cross.hlsl (+37-37) - (modified) clang/test/CodeGenHLSL/builtins/dot2add.hlsl (+175-175) - (modified) clang/test/CodeGenHLSL/builtins/dst.hlsl (+51-51) - (modified) clang/test/CodeGenHLSL/builtins/normalize-overloads.hlsl (+156-156) - (modified) clang/test/CodeGenHLSL/builtins/normalize.hlsl (+85-85) - (modified) clang/test/CodeGenHLSL/builtins/or.hlsl (+80-80) - (modified) clang/test/CodeGenHLSL/builtins/step-overloads.hlsl (+153-153) - (modified) clang/test/CodeGenHLSL/builtins/step.hlsl (+84-84) - (modified) clang/test/CodeGenHLSL/resources/AppendStructuredBuffer-elementtype.hlsl (+54-54) - (modified) clang/test/CodeGenHLSL/resources/ConsumeStructuredBuffer-elementtype.hlsl (+54-54) - (modified) clang/test/CodeGenHLSL/resources/RWStructuredBuffer-elementtype.hlsl (+61-61) - (modified) clang/test/CodeGenHLSL/resources/RasterizerOrderedStructuredBuffer-elementtype.hlsl (+60-60) - (modified) clang/test/CodeGenHLSL/resources/StructuredBuffer-elementtype.hlsl (+61-61) - (modified) clang/test/CodeGenHLSL/resources/StructuredBuffers-subscripts.hlsl (+51-51) - (modified) clang/test/CodeGenHLSL/resources/cbuffer_and_namespaces.hlsl (+54-54) - (modified) clang/test/CodeGenHLSL/resources/cbuffer_with_static_global_and_function.hlsl (+29-29) - (modified) clang/test/CodeGenHLSL/resources/res-array-global-dyn-index.hlsl (+29-29) - (modified) clang/test/CodeGenHLSL/resources/res-array-global-multi-dim.hlsl (+46-46) - (modified) clang/test/CodeGenHLSL/resources/res-array-global-subarray-many.hlsl (+109-109) - (modified) clang/test/CodeGenHLSL/resources/res-array-global-subarray-one.hlsl (+62-62) - (modified) clang/test/CodeGenHLSL/resources/res-array-global.hlsl (+75-75) - (modified) clang/test/CodeGenHLSL/resources/res-array-local-multi-dim.hlsl (+49-49) - (modified) clang/test/CodeGenHLSL/resources/res-array-local1.hlsl (+64-64) - (modified) clang/test/CodeGenHLSL/resources/res-array-local2.hlsl (+37-37) - (modified) clang/test/CodeGenHLSL/resources/res-array-local3.hlsl (+62-62) - (modified) clang/test/Options/Gis.hlsl (+13-13) - (modified) clang/test/ParserHLSL/bitfields.hlsl (+31-31) - (modified) clang/test/ParserHLSL/hlsl_annotations_on_struct_members.hlsl (+21-21) - (modified) clang/test/ParserHLSL/hlsl_contained_type_attr.hlsl (+25-25) - (modified) clang/test/ParserHLSL/hlsl_contained_type_attr_error.hlsl (+28-28) - (modified) clang/test/ParserHLSL/hlsl_is_rov_attr.hlsl (+22-22) - (modified) clang/test/ParserHLSL/hlsl_is_rov_attr_error.hlsl (+20-20) - (modified) clang/test/ParserHLSL/hlsl_raw_buffer_attr.hlsl (+22-22) - (modified) clang/test/ParserHLSL/hlsl_raw_buffer_attr_error.hlsl (+17-17) - (modified) clang/test/ParserHLSL/hlsl_resource_class_attr.hlsl (+37-37) - (modified) clang/test/ParserHLSL/hlsl_resource_class_attr_error.hlsl (+22-22) - (modified) clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl (+19-19) - (modified) clang/test/SemaHLSL/Availability/avail-diag-default-compute.hlsl (+119-119) - (modified) clang/test/SemaHLSL/Availability/avail-diag-default-lib.hlsl (+180-180) - (modified) clang/test/SemaHLSL/Availability/avail-diag-relaxed-compute.hlsl (+119-119) - (modified) clang/test/SemaHLSL/Availability/avail-diag-relaxed-lib.hlsl (+162-162) - (modified) clang/test/SemaHLSL/Availability/avail-diag-strict-compute.hlsl (+129-129) - (modified) clang/test/SemaHLSL/Availability/avail-diag-strict-lib.hlsl (+192-192) - (modified) clang/test/SemaHLSL/Availability/avail-lib-multiple-stages.hlsl (+57-57) - (modified) clang/test/SemaHLSL/BuiltIns/StructuredBuffers.hlsl (+31-31) - (modified) clang/test/SemaHLSL/BuiltIns/asint16-errors.hlsl (+43-43) - (modified) clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl (+52-52) - (modified) clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl (+61-61) - (modified) clang/test/SemaHLSL/BuiltIns/dot2add-errors.hlsl (+13-13) - (modified) clang/test/SemaHLSL/BuiltIns/half-float-only-errors2.hlsl (+13-13) - (modified) clang/test/SemaHLSL/BuiltIns/length-erro
[clang] [Clang] Support includes translated to module imports in -header-include-filtering=direct-per-file (PR #156756)
https://github.com/bob-wilson commented: I have reviewed these changes and they look OK to me. This is a new option and as far as I know, swift-build is the only thing using it. Sina has a change to update swift-build to work with the new format. https://github.com/llvm/llvm-project/pull/156756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL][NFC] Change line endings to LF (PR #156930)
https://github.com/hekota ready_for_review https://github.com/llvm/llvm-project/pull/156930 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [NVPTX] Change the alloca address space in NVPTXLowerAlloca (PR #154814)
@@ -1444,15 +1444,16 @@ void clang::emitBackendOutput(CompilerInstance &CI, CodeGenOptions &CGOpts, // Verify clang's TargetInfo DataLayout against the LLVM TargetMachine's // DataLayout. - if (AsmHelper.TM) { -std::string DLDesc = M->getDataLayout().getStringRepresentation(); -if (DLDesc != TDesc) { + if (AsmHelper.TM) +if (!AsmHelper.TM->isCompatibleDataLayout(M->getDataLayout()) || +!AsmHelper.TM->isCompatibleDataLayout(DataLayout(TDesc))) { + std::string DLDesc = M->getDataLayout().getStringRepresentation(); AlexMaclean wrote: I don't think it is a good idea to create a situation in which the datalayout does not match the expected/actual AS of alloca instructions. One potential issue with having an `A0` datalayout and addrspace 5 allocas could be that various passes (including SDAG Legalization) could insert addrspace 0 allocas based on the datalayout while our current lowering would expect them to be in addrspace 5. One way to avoid this kind of inconsistency is to update the datalayout in the pass that updates the allocas (as you did originally). @efriedma-quic pointed out that this is pretty weird and uncommon, but it didn't seem to create any practical issues. Another option is to completely update everywhere to use A5. This isn't totally new ground since this seems to be what AMDGPU does but it is a really big change that I'm not sure what all the implications would be, especially for out-of-tree uses. It seems like both options had pros/cons but I would recommend that we choose either over a datalayout which doesn't match the actual allocas. https://github.com/llvm/llvm-project/pull/154814 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Allow non-constant sizes for __builtin_assume_dereferenceable. (PR #156929)
https://github.com/rjmccall approved this pull request. https://github.com/llvm/llvm-project/pull/156929 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Add support for discrete bit-field (PR #156085)
https://github.com/Andres-Salamanca updated https://github.com/llvm/llvm-project/pull/156085 >From 9e25e8058e50d81b629bfb6a4ca7ca822f0529b7 Mon Sep 17 00:00:00 2001 From: Andres Salamanca Date: Fri, 29 Aug 2025 13:44:22 -0500 Subject: [PATCH 1/4] [CIR] Add support for discrete bit-field ABI --- .../clang/CIR/Dialect/IR/CIRDataLayout.h | 12 .../CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp | 50 +- clang/test/CIR/CodeGen/mms-bitfields.c| 65 +++ 3 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 clang/test/CIR/CodeGen/mms-bitfields.c diff --git a/clang/include/clang/CIR/Dialect/IR/CIRDataLayout.h b/clang/include/clang/CIR/Dialect/IR/CIRDataLayout.h index ecc681ee310e3..4da435e0ea8f7 100644 --- a/clang/include/clang/CIR/Dialect/IR/CIRDataLayout.h +++ b/clang/include/clang/CIR/Dialect/IR/CIRDataLayout.h @@ -68,6 +68,18 @@ class CIRDataLayout { return llvm::alignTo(getTypeStoreSize(ty), getABITypeAlign(ty).value()); } + /// Returns the offset in bits between successive objects of the + /// specified type, including alignment padding; always a multiple of 8. + /// + /// If Ty is a scalable vector type, the scalable property will be set and + /// the runtime size will be a positive integer multiple of the base size. + /// + /// This is the amount that alloca reserves for this type. For example, + /// returns 96 or 128 for x86_fp80, depending on alignment. + llvm::TypeSize getTypeAllocSizeInBits(mlir::Type ty) const { +return 8 * getTypeAllocSize(ty); + } + llvm::TypeSize getTypeSizeInBits(mlir::Type ty) const; }; diff --git a/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp b/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp index 6c7cf75aa2c99..9ebcf39190f45 100644 --- a/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp @@ -108,6 +108,16 @@ struct CIRRecordLowering final { // not the primary vbase of some base class. bool hasOwnStorage(const CXXRecordDecl *decl, const CXXRecordDecl *query); + /// The Microsoft bitfield layout rule allocates discrete storage + /// units of the field's formal type and only combines adjacent + /// fields of the same formal type. We want to emit a layout with + /// these discrete storage units instead of combining them into a + /// continuous run. + bool isDiscreteBitFieldABI() { +return astContext.getTargetInfo().getCXXABI().isMicrosoft() || + recordDecl->isMsStruct(astContext); + } + CharUnits bitsToCharUnits(uint64_t bitOffset) { return astContext.toCharUnitsFromBits(bitOffset); } @@ -323,7 +333,45 @@ void CIRRecordLowering::fillOutputFields() { RecordDecl::field_iterator CIRRecordLowering::accumulateBitFields(RecordDecl::field_iterator field, RecordDecl::field_iterator fieldEnd) { - assert(!cir::MissingFeatures::isDiscreteBitFieldABI()); + if (isDiscreteBitFieldABI()) { +// run stores the first element of the current run of bitfields. fieldEnd is +// used as a special value to note that we don't have a current run. A +// bitfield run is a contiguous collection of bitfields that can be stored +// in the same storage block. Zero-sized bitfields and bitfields that would +// cross an alignment boundary break a run and start a new one. +RecordDecl::field_iterator run = fieldEnd; +// tail is the offset of the first bit off the end of the current run. It's +// used to determine if the ASTRecordLayout is treating these two bitfields +// as contiguous. StartBitOffset is offset of the beginning of the Run. +uint64_t startBitOffset, tail = 0; +for (; field != fieldEnd && field->isBitField(); ++field) { + // Zero-width bitfields end runs. + if (field->isZeroLengthBitField()) { +run = fieldEnd; +continue; + } + uint64_t bitOffset = getFieldBitOffset(*field); + mlir::Type type = cirGenTypes.convertTypeForMem(field->getType()); + // If we don't have a run yet, or don't live within the previous run's + // allocated storage then we allocate some storage and start a new run. + if (run == fieldEnd || bitOffset >= tail) { +run = field; +startBitOffset = bitOffset; +tail = startBitOffset + dataLayout.getTypeAllocSizeInBits(type); +// Add the storage member to the record. This must be added to the +// record before the bitfield members so that it gets laid out before +// the bitfields it contains get laid out. +members.push_back( +makeStorageInfo(bitsToCharUnits(startBitOffset), type)); + } + // Bitfields get the offset of their storage but come afterward and remain + // there after a stable sort. + members.push_back(MemberInfo(bitsToCharUnits(startBitOffset), + MemberInfo::InfoKind::Field, nullptr, +
[clang] [llvm] [DirectX] Add isinf f16 emulation for SM6.8 and lower (PR #156932)
llvmbot wrote: @llvm/pr-subscribers-clang-driver Author: Farzon Lotfi (farzonl) Changes fixes #156068 - We needed to add a new sub arch to the target tripple so we can test that emulation does not happen when targeting SM6.9 - The HLSL toolchain needed to be updated to handle the conversion of strings to enums for the new sub arch. - The emulation is done in DXILIntrinsicExpansion.cpp and needs to be able to convert both llvm.is.fpclass and lvm.dx.isinf to the proper emulation - test updates in TargetParser/TripleTest.cpp, isinf.ll, and is_fpclass.ll --- Full diff: https://github.com/llvm/llvm-project/pull/156932.diff 7 Files Affected: - (modified) clang/lib/Driver/ToolChains/HLSL.cpp (+3) - (modified) llvm/include/llvm/TargetParser/Triple.h (+2-1) - (modified) llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp (+42-1) - (modified) llvm/lib/TargetParser/Triple.cpp (+8-1) - (modified) llvm/test/CodeGen/DirectX/is_fpclass.ll (+19-2) - (modified) llvm/test/CodeGen/DirectX/isinf.ll (+37-6) - (modified) llvm/unittests/TargetParser/TripleTest.cpp (+13) ``diff diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp b/clang/lib/Driver/ToolChains/HLSL.cpp index 660661945d62a..559af32dc3808 100644 --- a/clang/lib/Driver/ToolChains/HLSL.cpp +++ b/clang/lib/Driver/ToolChains/HLSL.cpp @@ -132,6 +132,9 @@ std::optional tryParseProfile(StringRef Profile) { case 8: SubArch = llvm::Triple::DXILSubArch_v1_8; break; + case 9: +SubArch = llvm::Triple::DXILSubArch_v1_9; +break; case OfflineLibMinor: // Always consider minor version x as the latest supported DXIL version SubArch = llvm::Triple::LatestDXILSubArch; diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h index f85984ed4f328..8e12c6852075d 100644 --- a/llvm/include/llvm/TargetParser/Triple.h +++ b/llvm/include/llvm/TargetParser/Triple.h @@ -180,7 +180,8 @@ class Triple { DXILSubArch_v1_6, DXILSubArch_v1_7, DXILSubArch_v1_8, -LatestDXILSubArch = DXILSubArch_v1_8, +DXILSubArch_v1_9, +LatestDXILSubArch = DXILSubArch_v1_9, }; enum VendorType { UnknownVendor, diff --git a/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp b/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp index ee1db54446cb8..7966e3f1d6f3d 100644 --- a/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp +++ b/llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp @@ -51,6 +51,42 @@ static bool resourceAccessNeeds64BitExpansion(Module *M, Type *OverloadTy, return ScalarTy->isDoubleTy() || ScalarTy->isIntegerTy(64); } + static Value* expand16BitIsInf(CallInst *Orig) { +Module* M = Orig->getModule(); +if(M->getTargetTriple().getDXILVersion() >= VersionTuple(1, 9)) + return nullptr; + +Value *Val = Orig->getOperand(0); +Type* ValTy = Val->getType(); +if (!(ValTy->isHalfTy() || + (ValTy->isVectorTy() && + cast(ValTy)->getElementType()->isHalfTy( +return nullptr; + +IRBuilder<> Builder(Orig); +Type *IType = Type::getInt16Ty(M->getContext()); +Constant *PosInf = ValTy->isVectorTy() + ? ConstantVector::getSplat( + ElementCount::getFixed( + cast(ValTy)->getNumElements()), + ConstantInt::get(IType, 0x7c00)) + : ConstantInt::get(IType, 0x7c00); + +Constant *NegInf = ValTy->isVectorTy() + ? ConstantVector::getSplat( + ElementCount::getFixed( + cast(ValTy)->getNumElements()), + ConstantInt::get(IType, 0xfc00)) + : ConstantInt::get(IType, 0xfc00); + + +Value *IVal = Builder.CreateBitCast(Val, PosInf->getType()); +Value *B1 = Builder.CreateICmpEQ(IVal, PosInf); +Value *B2 = Builder.CreateICmpEQ(IVal, NegInf); +Value *B3 = Builder.CreateOr(B1, B2); +return B3; + } + static bool isIntrinsicExpansion(Function &F) { switch (F.getIntrinsicID()) { case Intrinsic::abs: @@ -68,6 +104,7 @@ static bool isIntrinsicExpansion(Function &F) { case Intrinsic::dx_sclamp: case Intrinsic::dx_nclamp: case Intrinsic::dx_degrees: + case Intrinsic::dx_isinf: case Intrinsic::dx_lerp: case Intrinsic::dx_normalize: case Intrinsic::dx_fdot: @@ -301,9 +338,10 @@ static Value *expandIsFPClass(CallInst *Orig) { auto *TCI = dyn_cast(T); // These FPClassTest cases have DXIL opcodes, so they will be handled in - // DXIL Op Lowering instead. + // DXIL Op Lowering instead for all non f16 cases. switch (TCI->getZExtValue()) { case FPClassTest::fcInf: +return expand16BitIsInf(Orig); case FPClassTest::fcNan: case FPClassTest::fcNormal: case FPClassTest::fcFinite: @@ -873,6 +911,9 @@ static bool expandIntrinsic(Function &F, CallInst *Orig) { case Intrinsic::dx_degrees: Result = expandDegreesIntrinsic
[clang] [clang-format] Add BreakAfterOpenBracket* and BreakBeforeCloseBracket* (PR #108332)
@@ -543,21 +543,17 @@ TEST(ConfigParseTest, ParsesConfiguration) { CHECK_PARSE("EnumTrailingComma: Remove", EnumTrailingComma, FormatStyle::ETC_Remove); - Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign; - CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket, - FormatStyle::BAS_Align); - CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket, - FormatStyle::BAS_DontAlign); + Style.AlignAfterOpenBracket = false; + CHECK_PARSE("AlignAfterOpenBracket: Align", AlignAfterOpenBracket, true); + CHECK_PARSE("AlignAfterOpenBracket: DontAlign", AlignAfterOpenBracket, false); // For backward compatibility: CHECK_PARSE("AlignAfterOpenBracket: AlwaysBreak", AlignAfterOpenBracket, - FormatStyle::BAS_Align); - CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket, - FormatStyle::BAS_DontAlign); + true); + CHECK_PARSE("AlignAfterOpenBracket: false", AlignAfterOpenBracket, false); CHECK_PARSE("AlignAfterOpenBracket: BlockIndent", AlignAfterOpenBracket, - FormatStyle::BAS_Align); - Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign; - CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket, - FormatStyle::BAS_Align); + true); + Style.AlignAfterOpenBracket = false; + CHECK_PARSE("AlignAfterOpenBracket: true", AlignAfterOpenBracket, true); HazardyKnusperkeks wrote: I'd be nice if you could parse at least one of your new options and check, that it overwrites `AlignAfterOpenBracket`, even if it comes before in the yaml. https://github.com/llvm/llvm-project/pull/108332 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL][NFC] Change line endings to LF (PR #156930)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Helena Kotas (hekota) Changes Changes line endings in files related to HLSL to LF (`\n`). --- Patch is 550.08 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/156930.diff 92 Files Affected: - (modified) clang/lib/CodeGen/HLSLBufferLayoutBuilder.cpp (+273-273) - (modified) clang/lib/CodeGen/HLSLBufferLayoutBuilder.h (+47-47) - (modified) clang/test/AST/HLSL/is_structured_resource_element_compatible_concept.hlsl (+15-15) - (modified) clang/test/AST/HLSL/is_typed_resource_element_compatible_concept.hlsl (+9-9) - (modified) clang/test/CodeGenHLSL/builtins/asint16.hlsl (+60-60) - (modified) clang/test/CodeGenHLSL/builtins/asuint16.hlsl (+60-60) - (modified) clang/test/CodeGenHLSL/builtins/atan2-overloads.hlsl (+123-123) - (modified) clang/test/CodeGenHLSL/builtins/atan2.hlsl (+59-59) - (modified) clang/test/CodeGenHLSL/builtins/cross.hlsl (+37-37) - (modified) clang/test/CodeGenHLSL/builtins/dot2add.hlsl (+175-175) - (modified) clang/test/CodeGenHLSL/builtins/dst.hlsl (+51-51) - (modified) clang/test/CodeGenHLSL/builtins/normalize-overloads.hlsl (+156-156) - (modified) clang/test/CodeGenHLSL/builtins/normalize.hlsl (+85-85) - (modified) clang/test/CodeGenHLSL/builtins/or.hlsl (+80-80) - (modified) clang/test/CodeGenHLSL/builtins/step-overloads.hlsl (+153-153) - (modified) clang/test/CodeGenHLSL/builtins/step.hlsl (+84-84) - (modified) clang/test/CodeGenHLSL/resources/AppendStructuredBuffer-elementtype.hlsl (+54-54) - (modified) clang/test/CodeGenHLSL/resources/ConsumeStructuredBuffer-elementtype.hlsl (+54-54) - (modified) clang/test/CodeGenHLSL/resources/RWStructuredBuffer-elementtype.hlsl (+61-61) - (modified) clang/test/CodeGenHLSL/resources/RasterizerOrderedStructuredBuffer-elementtype.hlsl (+60-60) - (modified) clang/test/CodeGenHLSL/resources/StructuredBuffer-elementtype.hlsl (+61-61) - (modified) clang/test/CodeGenHLSL/resources/StructuredBuffers-subscripts.hlsl (+51-51) - (modified) clang/test/CodeGenHLSL/resources/cbuffer_and_namespaces.hlsl (+54-54) - (modified) clang/test/CodeGenHLSL/resources/cbuffer_with_static_global_and_function.hlsl (+29-29) - (modified) clang/test/CodeGenHLSL/resources/res-array-global-dyn-index.hlsl (+29-29) - (modified) clang/test/CodeGenHLSL/resources/res-array-global-multi-dim.hlsl (+46-46) - (modified) clang/test/CodeGenHLSL/resources/res-array-global-subarray-many.hlsl (+109-109) - (modified) clang/test/CodeGenHLSL/resources/res-array-global-subarray-one.hlsl (+62-62) - (modified) clang/test/CodeGenHLSL/resources/res-array-global.hlsl (+75-75) - (modified) clang/test/CodeGenHLSL/resources/res-array-local-multi-dim.hlsl (+49-49) - (modified) clang/test/CodeGenHLSL/resources/res-array-local1.hlsl (+64-64) - (modified) clang/test/CodeGenHLSL/resources/res-array-local2.hlsl (+37-37) - (modified) clang/test/CodeGenHLSL/resources/res-array-local3.hlsl (+62-62) - (modified) clang/test/Options/Gis.hlsl (+13-13) - (modified) clang/test/ParserHLSL/bitfields.hlsl (+31-31) - (modified) clang/test/ParserHLSL/hlsl_annotations_on_struct_members.hlsl (+21-21) - (modified) clang/test/ParserHLSL/hlsl_contained_type_attr.hlsl (+25-25) - (modified) clang/test/ParserHLSL/hlsl_contained_type_attr_error.hlsl (+28-28) - (modified) clang/test/ParserHLSL/hlsl_is_rov_attr.hlsl (+22-22) - (modified) clang/test/ParserHLSL/hlsl_is_rov_attr_error.hlsl (+20-20) - (modified) clang/test/ParserHLSL/hlsl_raw_buffer_attr.hlsl (+22-22) - (modified) clang/test/ParserHLSL/hlsl_raw_buffer_attr_error.hlsl (+17-17) - (modified) clang/test/ParserHLSL/hlsl_resource_class_attr.hlsl (+37-37) - (modified) clang/test/ParserHLSL/hlsl_resource_class_attr_error.hlsl (+22-22) - (modified) clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl (+19-19) - (modified) clang/test/SemaHLSL/Availability/avail-diag-default-compute.hlsl (+119-119) - (modified) clang/test/SemaHLSL/Availability/avail-diag-default-lib.hlsl (+180-180) - (modified) clang/test/SemaHLSL/Availability/avail-diag-relaxed-compute.hlsl (+119-119) - (modified) clang/test/SemaHLSL/Availability/avail-diag-relaxed-lib.hlsl (+162-162) - (modified) clang/test/SemaHLSL/Availability/avail-diag-strict-compute.hlsl (+129-129) - (modified) clang/test/SemaHLSL/Availability/avail-diag-strict-lib.hlsl (+192-192) - (modified) clang/test/SemaHLSL/Availability/avail-lib-multiple-stages.hlsl (+57-57) - (modified) clang/test/SemaHLSL/BuiltIns/StructuredBuffers.hlsl (+31-31) - (modified) clang/test/SemaHLSL/BuiltIns/asint16-errors.hlsl (+43-43) - (modified) clang/test/SemaHLSL/BuiltIns/asuint16-errors.hlsl (+52-52) - (modified) clang/test/SemaHLSL/BuiltIns/cross-errors.hlsl (+61-61) - (modified) clang/test/SemaHLSL/BuiltIns/dot2add-errors.hlsl (+13-13) - (modified) clang/test/SemaHLSL/BuiltIns/half-float-only-errors2.hlsl (+13-13) - (modified) clang/test/SemaHLSL/BuiltIns/length-errors.hlsl (
[clang-tools-extra] bcb3bd0 - [clang-tidy] Raise minimum standard level for several checks from C++98 to C++11 (#152401)
Author: Victor Chernyakin Date: 2025-09-04T10:32:56-07:00 New Revision: bcb3bd09275f833a76d1122f59d4b49b52c8d299 URL: https://github.com/llvm/llvm-project/commit/bcb3bd09275f833a76d1122f59d4b49b52c8d299 DIFF: https://github.com/llvm/llvm-project/commit/bcb3bd09275f833a76d1122f59d4b49b52c8d299.diff LOG: [clang-tidy] Raise minimum standard level for several checks from C++98 to C++11 (#152401) `modernize-replace-auto-ptr`, `modernize-use-equals-delete`, and `modernize-use-auto` use `std::unique_ptr`, `= delete`, and `auto` respectively, which are all C++11 features. The interesting bit is `modernize-use-nullptr`'s tests: - Some relied on int-to-pointer conversions that were removed in C++11. There are two variations here. First, tests like this, which become ill-formed: ```cpp const int null = 0; void * ptr = null; ``` I just deleted these cases; if they're ill-formed, we're not losing anything, right? Second, tests like this: ```cpp float * ptr = (float *)int(0.f); ``` These don't become ill-formed, but start generating a different AST. In C++98, they are `NullToPointer` conversions, but in C++11, they become generic `IntegralToPointer` conversions. I deleted these cases too, though I'm less sure here. - Folded `struct Bar` into `class A`, because those both suffer from the same false negatives. Added: Modified: clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h clang-tools-extra/clang-tidy/modernize/UseAutoCheck.h clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.h clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h clang-tools-extra/test/clang-tidy/checkers/modernize/use-nullptr-basic.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h b/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h index 636481300d730..c91f5f580c524 100644 --- a/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h +++ b/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.h @@ -42,7 +42,7 @@ class ReplaceAutoPtrCheck : public ClangTidyCheck { public: ReplaceAutoPtrCheck(StringRef Name, ClangTidyContext *Context); bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { -return LangOpts.CPlusPlus; +return LangOpts.CPlusPlus11; } void storeOptions(ClangTidyOptions::OptionMap &Opts) override; void registerMatchers(ast_matchers::MatchFinder *Finder) override; diff --git a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.h b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.h index 76c52b2d28139..7a9bbbe1cdf77 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.h +++ b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.h @@ -17,7 +17,7 @@ class UseAutoCheck : public ClangTidyCheck { public: UseAutoCheck(StringRef Name, ClangTidyContext *Context); bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { -return LangOpts.CPlusPlus; +return LangOpts.CPlusPlus11; } void storeOptions(ClangTidyOptions::OptionMap &Opts) override; void registerMatchers(ast_matchers::MatchFinder *Finder) override; diff --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.h b/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.h index 64f60351c0657..dc3e712482c21 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.h +++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.h @@ -23,7 +23,7 @@ class UseEqualsDeleteCheck : public ClangTidyCheck { public: UseEqualsDeleteCheck(StringRef Name, ClangTidyContext *Context); bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { -return LangOpts.CPlusPlus; +return LangOpts.CPlusPlus11; } void storeOptions(ClangTidyOptions::OptionMap &Opts) override; void registerMatchers(ast_matchers::MatchFinder *Finder) override; diff --git a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h index f1591bae44657..4c02f8ccdf303 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h +++ b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.h @@ -17,9 +17,7 @@ class UseNullptrCheck : public ClangTidyCheck { public: UseNullptrCheck(StringRef Name, ClangTidyContext *Context); bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { -// FIXME this should be CPlusPlus11 but that causes test cases to -// erroneously fail. -return LangOpts.CPlusPlus || LangOpts.C23; +return LangOpts.CPlusPlus11 || LangOpts.C23; } void storeOptions(ClangTidyOptions::OptionMap &Opts) override; void registerMatchers(ast_matchers::MatchFinder *Finder) override; diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-nullptr-basic.cpp b/clang-tools-extra/test/clang-tidy/checkers
[clang-tools-extra] [clang-tidy] Raise minimum standard level for several checks from C++98 to C++11 (PR #152401)
https://github.com/localspook closed https://github.com/llvm/llvm-project/pull/152401 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add [system] label to modules from resource headers (PR #156934)
llvmbot wrote: @llvm/pr-subscribers-backend-x86 Author: Cyndy Ishida (cyndyishida) Changes Since resource headers are installed, commonly as system dependencies, they should have `[system]` on them. Fix up the ones missing. --- Full diff: https://github.com/llvm/llvm-project/pull/156934.diff 1 Files Affected: - (modified) clang/lib/Headers/module.modulemap (+2-2) ``diff diff --git a/clang/lib/Headers/module.modulemap b/clang/lib/Headers/module.modulemap index a72828625a629..bdf5119ba4607 100644 --- a/clang/lib/Headers/module.modulemap +++ b/clang/lib/Headers/module.modulemap @@ -329,13 +329,13 @@ module _Builtin_unwind [system] { } // End -fbuiltin-headers-in-system-modules affected modules -module opencl_c { +module opencl_c [system] { requires opencl header "opencl-c.h" header "opencl-c-base.h" } -module ptrauth { +module ptrauth [system] { header "ptrauth.h" export * } `` https://github.com/llvm/llvm-project/pull/156934 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Emit initializers for static const/constexpr variables once they're met (PR #156933)
https://github.com/rjmccall commented: Initializers can be self-referential, so doing this eagerly might be problematic. Why does this help with initializing things in consteval functions? https://github.com/llvm/llvm-project/pull/156933 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] add modernize-use-constexpr check (PR #146553)
@@ -0,0 +1,972 @@ +//===--- UseConstexprCheck.cpp - clang-tidy===// +// +// 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 "UseConstexprCheck.h" +#include "../utils/ASTUtils.h" +#include "../utils/LexerUtils.h" +#include "clang/AST/ASTContext.h" +#include "clang/AST/ASTTypeTraits.h" +#include "clang/AST/Decl.h" +#include "clang/AST/DeclBase.h" HerrCai0907 wrote: I think the guideline is for the header we actually don't need it. For this cases, e.g. include Decl.h implicitly included DeclBase.h. I think it is depends on the intellisense. clangd will add this header automatically and I think it is quiet a lot of additional effort for developer to avoid this cases. https://github.com/llvm/llvm-project/pull/146553 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20][Modules] Add a test for field info assertion failure. (PR #155948)
mpark wrote: > I think we need to merge it. Why do you think we don't need to merge it? oh goodness... I only just realized now that you meant that the decls should be merged. At the time I thought you were saying we should merge the PR 😂 https://github.com/llvm/llvm-project/pull/155948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 6030416 - [C++20] [Modules] Add the abbrev number for coro-await-elidable calls
Author: Chuanqi Xu Date: 2025-09-05T14:58:05+08:00 New Revision: 60304161ce44c25dec7b87dd6a593d09eea5545a URL: https://github.com/llvm/llvm-project/commit/60304161ce44c25dec7b87dd6a593d09eea5545a DIFF: https://github.com/llvm/llvm-project/commit/60304161ce44c25dec7b87dd6a593d09eea5545a.diff LOG: [C++20] [Modules] Add the abbrev number for coro-await-elidable calls The root cause of the issue is that we forgot to update the abbrev number correctly. The test would crash before. Added: clang/test/Modules/coro-await-elidable.cppm Modified: clang/lib/Serialization/ASTWriterStmt.cpp Removed: diff --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp index e36d83fe4559b..dda81557cb22f 100644 --- a/clang/lib/Serialization/ASTWriterStmt.cpp +++ b/clang/lib/Serialization/ASTWriterStmt.cpp @@ -979,7 +979,8 @@ void ASTStmtWriter::VisitCallExpr(CallExpr *E) { Record.push_back(E->getFPFeatures().getAsOpaqueInt()); if (!E->hasStoredFPFeatures() && !static_cast(E->getADLCallKind()) && - !E->usesMemberSyntax() && E->getStmtClass() == Stmt::CallExprClass) + !E->isCoroElideSafe() && !E->usesMemberSyntax() && + E->getStmtClass() == Stmt::CallExprClass) AbbrevToUse = Writer.getCallExprAbbrev(); Code = serialization::EXPR_CALL; @@ -1712,7 +1713,8 @@ void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) { Record.push_back(E->getOperator()); Record.AddSourceLocation(E->BeginLoc); - if (!E->hasStoredFPFeatures() && !static_cast(E->getADLCallKind())) + if (!E->hasStoredFPFeatures() && !static_cast(E->getADLCallKind()) && + !E->isCoroElideSafe() && !E->usesMemberSyntax()) AbbrevToUse = Writer.getCXXOperatorCallExprAbbrev(); Code = serialization::EXPR_CXX_OPERATOR_CALL; @@ -1721,7 +1723,8 @@ void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) { void ASTStmtWriter::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) { VisitCallExpr(E); - if (!E->hasStoredFPFeatures() && !static_cast(E->getADLCallKind())) + if (!E->hasStoredFPFeatures() && !static_cast(E->getADLCallKind()) && + !E->isCoroElideSafe() && !E->usesMemberSyntax()) AbbrevToUse = Writer.getCXXMemberCallExprAbbrev(); Code = serialization::EXPR_CXX_MEMBER_CALL; diff --git a/clang/test/Modules/coro-await-elidable.cppm b/clang/test/Modules/coro-await-elidable.cppm new file mode 100644 index 0..2d635c6efa88b --- /dev/null +++ b/clang/test/Modules/coro-await-elidable.cppm @@ -0,0 +1,200 @@ +// RUN: rm -rf %t +// RUN: split-file %s %t + +// RUN: %clang_cc1 -std=c++20 %t/task.cppm -I%t -emit-reduced-module-interface -o %t/task.pcm +// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/user.cpp -verify -fsyntax-only + +//--- coroutine.h + +namespace std { + +template struct coroutine_traits { +using promise_type = typename R::promise_type; +}; + +template struct coroutine_handle; + +template <> struct coroutine_handle { +static coroutine_handle from_address(void *addr) noexcept { +coroutine_handle me; +me.ptr = addr; +return me; +} +void operator()() { resume(); } +void *address() const noexcept { return ptr; } +void resume() const { __builtin_coro_resume(ptr); } +void destroy() const { __builtin_coro_destroy(ptr); } +bool done() const { return __builtin_coro_done(ptr); } +coroutine_handle &operator=(decltype(nullptr)) { +ptr = nullptr; +return *this; +} +coroutine_handle(decltype(nullptr)) : ptr(nullptr) {} +coroutine_handle() : ptr(nullptr) {} +// void reset() { ptr = nullptr; } // add to P0057? +explicit operator bool() const { return ptr; } + +protected: +void *ptr; +}; + +template struct coroutine_handle : coroutine_handle<> { +using coroutine_handle<>::operator=; + +static coroutine_handle from_address(void *addr) noexcept { +coroutine_handle me; +me.ptr = addr; +return me; +} + +Promise &promise() const { +return *reinterpret_cast( +__builtin_coro_promise(ptr, alignof(Promise), false)); +} +static coroutine_handle from_promise(Promise &promise) { +coroutine_handle p; +p.ptr = __builtin_coro_promise(&promise, alignof(Promise), true); +return p; +} +}; + +template +bool operator==(coroutine_handle<_PromiseT> const &_Left, +coroutine_handle<_PromiseT> const &_Right) noexcept { +return _Left.address() == _Right.address(); +} + +template +bool operator!=(coroutine_handle<_PromiseT> const &_Left, +coroutine_handle<_PromiseT> const &_Right) noexcept { +return !(_Left == _Right); +} + +struct noop_coroutine_promise {}; + +template <> +struct coroutine_handle { +operator coroutine_handle<>() const noexcept { +return coroutine_handle<>::from_address(address()); +} + +constexpr explicit operator bool() const noex
[clang] [clang] fix definition data not being propagated to all redecls (PR #157019)
@@ -2107,6 +2107,8 @@ void ASTDeclMerger::MergeDefinitionData( auto *Def = DD.Definition; DD = std::move(MergeDD); DD.Definition = Def; +for (auto *TD : Def->redecls()) ChuanqiXu9 wrote: Oh, I misremembered it. It'll be good to add a such API. https://github.com/llvm/llvm-project/pull/157019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-shlib] Fix linking libclang-cpp on Haiku (PR #156401)
https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/156401 >From 2f560a0209bc69546beb0709bb80f4824647d6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Mon, 1 Sep 2025 23:26:14 -0400 Subject: [PATCH] [clang-shlib] Fix linking libclang-cpp on Haiku Haiku requires linking in libnetwork. --- clang/tools/clang-shlib/CMakeLists.txt | 4 1 file changed, 4 insertions(+) diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt index 945076e1ad810..a4d0aa5779a7e 100644 --- a/clang/tools/clang-shlib/CMakeLists.txt +++ b/clang/tools/clang-shlib/CMakeLists.txt @@ -41,6 +41,10 @@ if (CLANG_LINK_CLANG_DYLIB) set(INSTALL_WITH_TOOLCHAIN INSTALL_WITH_TOOLCHAIN) endif() +if (HAIKU) + list(APPEND _DEPS network) +endif() + add_clang_library(clang-cpp SHARED ${INSTALL_WITH_TOOLCHAIN} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix incorrect array initialization with string literal (fixes #112189) (PR #156846)
awson wrote: Hmm, now one test is failing, namely [these aren't warnings anymore](https://github.com/llvm/llvm-project/blob/ffbd6162103041697ce7387029f321d3a466ca34/clang/test/Sema/string-concat.c#L49-L50). I have absolutely no idea how to approach this. https://github.com/llvm/llvm-project/pull/156846 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Remove experimental from Zicfilp and Zicfiss (PR #157015)
llvmbot wrote: @llvm/pr-subscribers-backend-risc-v Author: Jim Lin (tclin914) Changes These extensions were ratified in June 2024. --- Patch is 27.74 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/157015.diff 23 Files Affected: - (modified) clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c (+4-4) - (modified) clang/test/Driver/print-enabled-extensions/riscv-sifive-x390.c (+2-2) - (modified) clang/test/Driver/print-supported-extensions-riscv.c (+2-2) - (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+4-4) - (modified) llvm/test/CodeGen/RISCV/attributes.ll (+2-2) - (modified) llvm/test/CodeGen/RISCV/calls.ll (+1-1) - (modified) llvm/test/CodeGen/RISCV/features-info.ll (+2-2) - (modified) llvm/test/CodeGen/RISCV/jumptable-swguarded.ll (+2-2) - (modified) llvm/test/CodeGen/RISCV/lpad.ll (+4-4) - (modified) llvm/test/CodeGen/RISCV/nest-register.ll (+2-2) - (modified) llvm/test/CodeGen/RISCV/rv64-trampoline-cfi.ll (+2-2) - (modified) llvm/test/CodeGen/RISCV/shadowcallstack.ll (+2-2) - (modified) llvm/test/CodeGen/RISCV/tail-calls.ll (+1-1) - (modified) llvm/test/CodeGen/RISCV/zicfilp-indirect-branch.ll (+1-1) - (modified) llvm/test/MC/RISCV/attribute-arch-invalid.s (+2-2) - (modified) llvm/test/MC/RISCV/compressed-zicfiss.s (+6-6) - (modified) llvm/test/MC/RISCV/option-arch.s (+1-1) - (modified) llvm/test/MC/RISCV/tail-call.s (+4-4) - (modified) llvm/test/MC/RISCV/zicfilp-invalid.s (+2-2) - (modified) llvm/test/MC/RISCV/zicfilp-valid.s (+6-6) - (modified) llvm/test/MC/RISCV/zicfiss-invalid.s (+2-2) - (modified) llvm/test/MC/RISCV/zicfiss-valid.s (+6-6) - (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+8-8) ``diff diff --git a/clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c b/clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c index cabff7e598eb0..1a7671d16f342 100644 --- a/clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c +++ b/clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-zicfiss -emit-llvm -o - %s -fcf-protection=return | FileCheck %s -// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-zicfiss -emit-llvm -o - %s | FileCheck -check-prefix=NOSHADOWSTACK %s -// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zicfiss -emit-llvm -o - %s -fcf-protection=return | FileCheck %s -// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zicfiss -emit-llvm -o - %s | FileCheck -check-prefix=NOSHADOWSTACK %s +// RUN: %clang_cc1 -triple riscv64 -target-feature +zicfiss -emit-llvm -o - %s -fcf-protection=return | FileCheck %s +// RUN: %clang_cc1 -triple riscv64 -target-feature +zicfiss -emit-llvm -o - %s | FileCheck -check-prefix=NOSHADOWSTACK %s +// RUN: %clang_cc1 -triple riscv32 -target-feature +zicfiss -emit-llvm -o - %s -fcf-protection=return | FileCheck %s +// RUN: %clang_cc1 -triple riscv32 -target-feature +zicfiss -emit-llvm -o - %s | FileCheck -check-prefix=NOSHADOWSTACK %s int foo(int *a) { return *a; } diff --git a/clang/test/Driver/print-enabled-extensions/riscv-sifive-x390.c b/clang/test/Driver/print-enabled-extensions/riscv-sifive-x390.c index aa038a18693e0..f488347ee35b8 100644 --- a/clang/test/Driver/print-enabled-extensions/riscv-sifive-x390.c +++ b/clang/test/Driver/print-enabled-extensions/riscv-sifive-x390.c @@ -17,6 +17,8 @@ // CHECK-NEXT: ziccamoa 1.0 'Ziccamoa' (Main Memory Supports All Atomics in A) // CHECK-NEXT: ziccif 1.0 'Ziccif' (Main Memory Supports Instruction Fetch with Atomicity Requirement) // CHECK-NEXT: ziccrse 1.0 'Ziccrse' (Main Memory Supports Forward Progress on LR/SC Sequences) +// CHECK-NEXT: zicfilp 1.0 'Zicfilp' (Landing pad) +// CHECK-NEXT: zicfiss 1.0 'Zicfiss' (Shadow stack) // CHECK-NEXT: zicntr 2.0 'Zicntr' (Base Counters and Timers) // CHECK-NEXT: zicond 1.0 'Zicond' (Integer Conditional Operations) // CHECK-NEXT: zicsr2.0 'Zicsr' (CSRs) @@ -65,7 +67,5 @@ // CHECK-NEXT: xsifivecflushdlone 1.0 'XSiFivecflushdlone' (SiFive sf.cflush.d.l1 Instruction) // CHECK-EMPTY: // CHECK-NEXT: Experimental extensions -// CHECK-NEXT: zicfilp 1.0 'Zicfilp' (Landing pad) -// CHECK-NEXT: zicfiss 1.0 'Zicfiss' (Shadow stack) // CHECK-EMPTY: // CHECK-NEXT: ISA String: rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_b1p0_v1p0_zic64b1p0_zicbom1p0_zicbop1p0_zicboz1p0_ziccamoa1p0_ziccif1p0_ziccrse1p0_zicfilp1p0_zicfiss1p0_zicntr2p0_zicond1p0_zicsr2p0_zifencei2p0_zihintntl1p0_zihintpause2p0_zihpm2p0_zimop1p0_zmmul1p0_za64rs1p0_zaamo1p0_zalrsc1p0_zawrs1p0_zfa1p0_zfbfmin1p0_zfh1p0_zfhmin1p0_zca1p0_zcb1p0_zcd1p0_zcmop1p0_zba1p0_zbb1p0_zbs1p0_zkr1p0_zkt1p0_zvbb1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvfbfmin1p0_zv
[clang] [RISCV] Implement Clang Builtins for XCVmac Extension in CV32E40P (PR #110623)
https://github.com/realqhc updated https://github.com/llvm/llvm-project/pull/110623 >From 890fea1216ca40a1d591723c8e2c30524772e8fa Mon Sep 17 00:00:00 2001 From: Qihan Cai Date: Tue, 1 Oct 2024 12:14:15 +1000 Subject: [PATCH 1/4] [RISCV] Implement Clang Builtins for XCVmac Extension in CV32E40P This commit adds the Clang Builtins, C API header and relevant tests for XCVmac extension. Spec: https://github.com/openhwgroup/core-v-sw/blob/master/specifications/corev-builtin-spec.md Contributor: @PaoloS02 --- clang/include/clang/Basic/BuiltinsRISCVXCV.td | 38 ++ clang/lib/Headers/CMakeLists.txt | 1 + clang/lib/Headers/riscv_corev_mac.h | 109 ++ clang/test/CodeGen/RISCV/riscv-xcvmac-c-api.c | 343 ++ clang/test/CodeGen/RISCV/riscv-xcvmac.c | 309 5 files changed, 800 insertions(+) create mode 100644 clang/lib/Headers/riscv_corev_mac.h create mode 100644 clang/test/CodeGen/RISCV/riscv-xcvmac-c-api.c create mode 100644 clang/test/CodeGen/RISCV/riscv-xcvmac.c diff --git a/clang/include/clang/Basic/BuiltinsRISCVXCV.td b/clang/include/clang/Basic/BuiltinsRISCVXCV.td index 65eb52b198775..3ff8866bc5358 100644 --- a/clang/include/clang/Basic/BuiltinsRISCVXCV.td +++ b/clang/include/clang/Basic/BuiltinsRISCVXCV.td @@ -38,4 +38,42 @@ def alu_subN : RISCVXCVBuiltin<"int(int, int, unsigned int)", "xcvalu">; def alu_subuN : RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", "xcvalu">; def alu_subRN : RISCVXCVBuiltin<"int(int, int, unsigned int)", "xcvalu">; def alu_subuRN : RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", "xcvalu">; + +//===--===// +// XCVmac extension. +//===--===// +def mac_mac : RISCVXCVBuiltin<"int(int, int, int)", "xcvmac">; +def mac_msu : RISCVXCVBuiltin<"int(int, int, int)", "xcvmac">; +def mac_muluN: RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_mulhhuN : RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_mulsN: RISCVXCVBuiltin<"int(unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_mulhhsN : RISCVXCVBuiltin<"int(unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_muluRN : RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_mulhhuRN : RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_mulsRN : RISCVXCVBuiltin<"int(unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_mulhhsRN : RISCVXCVBuiltin<"int(unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_macuN: RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_machhuN : RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_macsN: RISCVXCVBuiltin<"int(unsigned int, unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_machhsN : RISCVXCVBuiltin<"int(unsigned int, unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_macuRN : RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int, unsigned int)", +"xcvmac">; +def mac_machhuRN : RISCVXCVBuiltin<"unsigned int(unsigned int, unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_macsRN : RISCVXCVBuiltin<"int(unsigned int, unsigned int, unsigned int, unsigned int)", + "xcvmac">; +def mac_machhsRN : RISCVXCVBuiltin<"int(unsigned int, unsigned int, unsigned int, unsigned int)", + "xcvmac">; } // Attributes = [NoThrow, Const] diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt index dd52498bbef4c..6dabab5559a39 100644 --- a/clang/lib/Headers/CMakeLists.txt +++ b/clang/lib/Headers/CMakeLists.txt @@ -126,6 +126,7 @@ set(ppc_htm_files set(riscv_files riscv_bitmanip.h riscv_corev_alu.h + riscv_corev_mac.h riscv_crypto.h riscv_nds.h riscv_ntlh.h diff --git a/clang/lib/Headers/riscv_corev_mac.h b/clang/lib/Headers/riscv_corev_mac.h new file mode 100644 index 0..9863162647606 --- /dev/null +++ b/clang/lib/Headers/riscv_corev_mac.h @@ -0,0 +1,109 @@ +/*=== riscv_corev_mac.h - CORE-V multiply accumulat
[clang] [llvm] [RISCV] Remove experimental from Zicfilp and Zicfiss (PR #157015)
https://github.com/tclin914 created https://github.com/llvm/llvm-project/pull/157015 These extensions were ratified in June 2024. >From 930c01ca71be448e290de81e47bb36cc3ca19795 Mon Sep 17 00:00:00 2001 From: Jim Lin Date: Tue, 2 Sep 2025 14:52:44 +0800 Subject: [PATCH] [RISCV] Remove experimental from Zicfilp and Zicfiss These extensions were ratified in June 2024. --- clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c | 8 .../print-enabled-extensions/riscv-sifive-x390.c | 4 ++-- .../Driver/print-supported-extensions-riscv.c| 4 ++-- llvm/lib/Target/RISCV/RISCVFeatures.td | 8 llvm/test/CodeGen/RISCV/attributes.ll| 4 ++-- llvm/test/CodeGen/RISCV/calls.ll | 2 +- llvm/test/CodeGen/RISCV/features-info.ll | 4 ++-- llvm/test/CodeGen/RISCV/jumptable-swguarded.ll | 4 ++-- llvm/test/CodeGen/RISCV/lpad.ll | 8 llvm/test/CodeGen/RISCV/nest-register.ll | 4 ++-- llvm/test/CodeGen/RISCV/rv64-trampoline-cfi.ll | 4 ++-- llvm/test/CodeGen/RISCV/shadowcallstack.ll | 4 ++-- llvm/test/CodeGen/RISCV/tail-calls.ll| 2 +- .../CodeGen/RISCV/zicfilp-indirect-branch.ll | 2 +- llvm/test/MC/RISCV/attribute-arch-invalid.s | 4 ++-- llvm/test/MC/RISCV/compressed-zicfiss.s | 12 ++-- llvm/test/MC/RISCV/option-arch.s | 2 +- llvm/test/MC/RISCV/tail-call.s | 8 llvm/test/MC/RISCV/zicfilp-invalid.s | 4 ++-- llvm/test/MC/RISCV/zicfilp-valid.s | 12 ++-- llvm/test/MC/RISCV/zicfiss-invalid.s | 4 ++-- llvm/test/MC/RISCV/zicfiss-valid.s | 12 ++-- llvm/unittests/TargetParser/RISCVISAInfoTest.cpp | 16 23 files changed, 68 insertions(+), 68 deletions(-) diff --git a/clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c b/clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c index cabff7e598eb0..1a7671d16f342 100644 --- a/clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c +++ b/clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-zicfiss -emit-llvm -o - %s -fcf-protection=return | FileCheck %s -// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-zicfiss -emit-llvm -o - %s | FileCheck -check-prefix=NOSHADOWSTACK %s -// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zicfiss -emit-llvm -o - %s -fcf-protection=return | FileCheck %s -// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zicfiss -emit-llvm -o - %s | FileCheck -check-prefix=NOSHADOWSTACK %s +// RUN: %clang_cc1 -triple riscv64 -target-feature +zicfiss -emit-llvm -o - %s -fcf-protection=return | FileCheck %s +// RUN: %clang_cc1 -triple riscv64 -target-feature +zicfiss -emit-llvm -o - %s | FileCheck -check-prefix=NOSHADOWSTACK %s +// RUN: %clang_cc1 -triple riscv32 -target-feature +zicfiss -emit-llvm -o - %s -fcf-protection=return | FileCheck %s +// RUN: %clang_cc1 -triple riscv32 -target-feature +zicfiss -emit-llvm -o - %s | FileCheck -check-prefix=NOSHADOWSTACK %s int foo(int *a) { return *a; } diff --git a/clang/test/Driver/print-enabled-extensions/riscv-sifive-x390.c b/clang/test/Driver/print-enabled-extensions/riscv-sifive-x390.c index aa038a18693e0..f488347ee35b8 100644 --- a/clang/test/Driver/print-enabled-extensions/riscv-sifive-x390.c +++ b/clang/test/Driver/print-enabled-extensions/riscv-sifive-x390.c @@ -17,6 +17,8 @@ // CHECK-NEXT: ziccamoa 1.0 'Ziccamoa' (Main Memory Supports All Atomics in A) // CHECK-NEXT: ziccif 1.0 'Ziccif' (Main Memory Supports Instruction Fetch with Atomicity Requirement) // CHECK-NEXT: ziccrse 1.0 'Ziccrse' (Main Memory Supports Forward Progress on LR/SC Sequences) +// CHECK-NEXT: zicfilp 1.0 'Zicfilp' (Landing pad) +// CHECK-NEXT: zicfiss 1.0 'Zicfiss' (Shadow stack) // CHECK-NEXT: zicntr 2.0 'Zicntr' (Base Counters and Timers) // CHECK-NEXT: zicond 1.0 'Zicond' (Integer Conditional Operations) // CHECK-NEXT: zicsr2.0 'Zicsr' (CSRs) @@ -65,7 +67,5 @@ // CHECK-NEXT: xsifivecflushdlone 1.0 'XSiFivecflushdlone' (SiFive sf.cflush.d.l1 Instruction) // CHECK-EMPTY: // CHECK-NEXT: Experimental extensions -// CHECK-NEXT: zicfilp 1.0 'Zicfilp' (Landing pad) -// CHECK-NEXT: zicfiss 1.0 'Zicfiss' (Shadow stack) // CHECK-EMPTY: // CHECK-NEXT: ISA String: rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_b1p0_v1p0_zic64b1p0_zicbom1p0_zicbop1p0_zicboz1p0_ziccamoa1p0_ziccif1p0_ziccrse1p0_zicfilp1p0_zicfiss1p0_zicntr2p0_zicond1p0_zicsr2p0_zifencei2p0_zihintntl1p0_zihintpause2p0_zihpm2p0_zimop1p0_zmmul1p0_za64rs1p0_zaamo1p0_zalrsc1p0_zawrs1p0_zfa1p0_zfbfmin1p0_zfh1p0_zfhmin1p0_zca1p0_zcb1p0_zcd1p0_zcm
[clang] [clang][bytecode] Print 8 bit integers as 32 bit in Function::dump() (PR #156858)
tbaederr wrote: This only changes debugging output so there are no tests for it. https://github.com/llvm/llvm-project/pull/156858 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libunwind] [llvm] [wasm] Toolchain support for `wasm32-wali-linux-musl` target (PR #156087)
@@ -199,6 +199,7 @@ class Triple { SUSE, OpenEmbedded, Intel, +WALI, arjunr2 wrote: @aheejin `cfg` is how feature gating based on targets is performed at Rust. This is fully independent of the LLVM target backend, so we can make the host environment whatever we want here. The PR changes are specifically the WALI ABI. Musl is just the only currently supported environment backend https://github.com/llvm/llvm-project/pull/156087 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add option AllowShortRecordOnASingleLine (PR #154580)
=?utf-8?q?Tomáš?= Slanina , =?utf-8?q?Tomáš?= Slanina , =?utf-8?q?Tomáš?= Slanina , =?utf-8?q?Tomáš?= Slanina , =?utf-8?q?Tomáš?= Slanina , =?utf-8?q?Tomáš?= Slanina , =?utf-8?q?Tomáš?= Slanina , =?utf-8?q?Tomáš?= Slanina , =?utf-8?q?Tomáš?= Slanina , =?utf-8?q?Tomáš?= Slanina , =?utf-8?q?Tomáš?= Slanina Message-ID: In-Reply-To: https://github.com/owenca edited https://github.com/llvm/llvm-project/pull/154580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add option AllowShortRecordOnASingleLine (PR #154580)
=?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina Message-ID: In-Reply-To: https://github.com/owenca commented: Also, please update the release notes as this is a top-level option. https://github.com/llvm/llvm-project/pull/154580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Add option AllowShortRecordOnASingleLine (PR #154580)
=?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina , =?utf-8?q?Tom=C3=A1=C5=A1?= Slanina Message-ID: In-Reply-To: @@ -928,9 +952,15 @@ class LineJoiner { return 0; Limit -= 2; unsigned MergedLines = 0; - if (Style.AllowShortBlocksOnASingleLine != FormatStyle::SBS_Never || - (I[1]->First == I[1]->Last && I + 2 != E && - I[2]->First->is(tok::r_brace))) { + + bool TryMergeBlock = + Style.AllowShortBlocksOnASingleLine != FormatStyle::SBS_Never; + bool TryMergeRecord = + Style.AllowShortRecordOnASingleLine == FormatStyle::SRS_Always; + bool NextIsEmptyBlock = I[1]->First == I[1]->Last && I + 2 != E && owenca wrote: Please make them `const`. https://github.com/llvm/llvm-project/pull/154580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Implement MC support for Zvfofp8min extension (PR #157014)
https://github.com/tclin914 created https://github.com/llvm/llvm-project/pull/157014 This patch adds MC support for Zvfofp8min https://github.com/aswaterman/riscv-misc/blob/main/isa/zvfofp8min.adoc. >From 721e751af29178cbff29a21af9dec5b33254eecd Mon Sep 17 00:00:00 2001 From: Jim Lin Date: Fri, 29 Aug 2025 13:16:29 +0800 Subject: [PATCH] [RISCV] Implement MC support for Zvfofp8min extension This patch adds MC support for Zvfofp8min https://github.com/aswaterman/riscv-misc/blob/main/isa/zvfofp8min.adoc. --- .../Driver/print-supported-extensions-riscv.c | 1 + .../test/Preprocessor/riscv-target-features.c | 9 + llvm/docs/RISCVUsage.rst | 1 + llvm/docs/ReleaseNotes.md | 1 + llvm/lib/Target/RISCV/RISCVFeatures.td| 19 -- llvm/lib/Target/RISCV/RISCVInstrInfo.td | 1 + llvm/lib/Target/RISCV/RISCVInstrInfoZvfbf.td | 3 +- .../Target/RISCV/RISCVInstrInfoZvfofp8min.td | 26 ++ llvm/lib/TargetParser/RISCVTargetParser.cpp | 2 +- llvm/test/CodeGen/RISCV/attributes.ll | 4 +++ llvm/test/CodeGen/RISCV/features-info.ll | 1 + llvm/test/MC/RISCV/attribute-arch.s | 3 ++ llvm/test/MC/RISCV/rvv/zvfbfmin.s | 8 ++--- llvm/test/MC/RISCV/rvv/zvfofp8min.s | 36 +++ .../TargetParser/RISCVISAInfoTest.cpp | 1 + 15 files changed, 107 insertions(+), 9 deletions(-) create mode 100644 llvm/lib/Target/RISCV/RISCVInstrInfoZvfofp8min.td create mode 100644 llvm/test/MC/RISCV/rvv/zvfofp8min.s diff --git a/clang/test/Driver/print-supported-extensions-riscv.c b/clang/test/Driver/print-supported-extensions-riscv.c index 3fa5ef9afd143..b8e7724a9602a 100644 --- a/clang/test/Driver/print-supported-extensions-riscv.c +++ b/clang/test/Driver/print-supported-extensions-riscv.c @@ -216,6 +216,7 @@ // CHECK-NEXT: zalasr 0.1 'Zalasr' (Load-Acquire and Store-Release Instructions) // CHECK-NEXT: zvbc32e 0.7 'Zvbc32e' (Vector Carryless Multiplication with 32-bits elements) // CHECK-NEXT: zvfbfa 0.1 'Zvfbfa' (Additional BF16 vector compute support) +// CHECK-NEXT: zvfofp8min 0.21 'Zvfofp8min' (Vector OFP8 Converts) // CHECK-NEXT: zvkgs0.7 'Zvkgs' (Vector-Scalar GCM instructions for Cryptography) // CHECK-NEXT: zvqdotq 0.0 'Zvqdotq' (Vector quad widening 4D Dot Product) // CHECK-NEXT: svukte 0.3 'Svukte' (Address-Independent Latency of User-Mode Faults to Supervisor Addresses) diff --git a/clang/test/Preprocessor/riscv-target-features.c b/clang/test/Preprocessor/riscv-target-features.c index 204c9851e680c..962375de398dc 100644 --- a/clang/test/Preprocessor/riscv-target-features.c +++ b/clang/test/Preprocessor/riscv-target-features.c @@ -178,6 +178,7 @@ // CHECK-NOT: __riscv_ztso {{.*$}} // CHECK-NOT: __riscv_zvbc32e {{.*$}} // CHECK-NOT: __riscv_zvfbfa {{.*$}} +// CHECK-NOT: __riscv_zvfofp8min {{.*$}} // CHECK-NOT: __riscv_zvfbfmin {{.*$}} // CHECK-NOT: __riscv_zvfbfwma {{.*$}} // CHECK-NOT: __riscv_zvkgs {{.*$}} @@ -1560,6 +1561,14 @@ // RUN: -o - | FileCheck --check-prefix=CHECK-ZVFBFA-EXT %s // CHECK-ZVFBFA-EXT: __riscv_zvfbfa 1000{{$}} +// RUN: %clang --target=riscv32 -menable-experimental-extensions \ +// RUN: -march=rv32ifzvfofp8min0p21 -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZVFOFP8MIN-EXT %s +// RUN: %clang --target=riscv64 -menable-experimental-extensions \ +// RUN: -march=rv64ifzvfofp8min0p21 -E -dM %s \ +// RUN: -o - | FileCheck --check-prefix=CHECK-ZVFOFP8MIN-EXT %s +// CHECK-ZVFOFP8MIN-EXT: __riscv_zvfofp8min 21000{{$}} + // RUN: %clang --target=riscv32 -menable-experimental-extensions \ // RUN: -march=rv32i_zve32x_zvbc32e0p7 -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZVBC32E-EXT %s diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst index d6c7b46485ccf..5d2824d797182 100644 --- a/llvm/docs/RISCVUsage.rst +++ b/llvm/docs/RISCVUsage.rst @@ -236,6 +236,7 @@ on support follow. ``Zvfbfwma`` Supported ``Zvfh`` Supported ``Zvfhmin`` Supported + ``Zvfofp8min``Assembly Support ``Zvkb`` Supported ``Zvkg`` Supported (`See note <#riscv-vector-crypto-note>`__) ``Zvkn`` Supported (`See note <#riscv-vector-crypto-note>`__) diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md index ff92d7390ecfd..84d68691b33de 100644 --- a/llvm/docs/ReleaseNotes.md +++ b/llvm/docs/ReleaseNotes.md @@ -120,6 +120,7 @@ Changes to the RISC-V Backend using `$x` with an architecture string suffix is not yet supported. * Ssctr and Smctr extensions are no longer experimental. * Add support for Zvfbfa (Additional BF16 vector compute support) +* Add support for Zvfofp8min (OFP8 conversion extension) Changes to the WebAssembly Backend
[clang] [clang] fix definition data not being propagated to all redecls (PR #157019)
https://github.com/mizvekov created https://github.com/llvm/llvm-project/pull/157019 This fixes the workaround added in 8a63989, so that when a fake definition data is corrected, all redeclarations are also updated to point to it. Since this regression was never released, there are no release notes. Fixes #154840 >From 45e25ed459b07f14342b02a33fc5589d0ccb8d50 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Mon, 1 Sep 2025 17:14:19 -0300 Subject: [PATCH] [clang] fix definition data not being propagated to all redecls This fixes the workaround added in 8a63989, so that when a fake definition data is corrected, all redeclarations are also updated to point to it. Since this regression was never released, there are no release notes. Fixes #154840 --- clang/lib/Serialization/ASTReaderDecl.cpp | 2 + clang/test/Modules/GH154840.cpp | 97 +++ 2 files changed, 99 insertions(+) create mode 100644 clang/test/Modules/GH154840.cpp diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 6b35b205079e5..7e0f782aa98f1 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -2107,6 +2107,8 @@ void ASTDeclMerger::MergeDefinitionData( auto *Def = DD.Definition; DD = std::move(MergeDD); DD.Definition = Def; +for (auto *TD : Def->redecls()) + cast(TD)->DefinitionData = ⅅ return; } diff --git a/clang/test/Modules/GH154840.cpp b/clang/test/Modules/GH154840.cpp new file mode 100644 index 0..afeb39acb5484 --- /dev/null +++ b/clang/test/Modules/GH154840.cpp @@ -0,0 +1,97 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: split-file %s %t +// RUN: cd %t +// +// RUN: %clang_cc1 -fmodule-name=A -fno-cxx-modules -emit-module -fmodules -xc++ A.cppmap -o A.pcm +// RUN: %clang_cc1 -fmodule-name=B -fno-cxx-modules -emit-module -fmodules -xc++ B.cppmap -o B.pcm -fmodule-file=A.pcm +// RUN: %clang_cc1 -fmodule-name=C -fno-cxx-modules -emit-module -fmodules -xc++ C.cppmap -o C.pcm -fmodule-file=A.pcm +// RUN: %clang_cc1 -fmodule-name=D -fno-cxx-modules -emit-module -fmodules -xc++ D.cppmap -o D.pcm -fmodule-file=A.pcm +// RUN: %clang_cc1 -fmodule-name=E -fno-cxx-modules -emit-module -fmodules -xc++ E.cppmap -o E.pcm -fmodule-file=D.pcm -fmodule-file=B.pcm -fmodule-file=C.pcm +// RUN: %clang_cc1 -fno-cxx-modules -fmodules -fmodule-file=B.pcm -fmodule-file=E.pcm -emit-llvm -o /dev/null S.cpp + +//--- A.h +namespace std { + +template void zz(T); + +template struct vec { + struct w {}; + struct xx {}; + + vec(vec &) { init(); } + constexpr vec &operator=(const vec &); + template constexpr void pb(U); + constexpr void init(); + + w s; +}; + +template constexpr void vec::init() { + xx yy; + zz(yy); +} + +template constexpr vec &vec::operator=(const vec &) { + pb(s); + return *this; +} + +template template constexpr void vec::pb(U) { init(); } +} // namespace std + +//--- A.cppmap +module "A" { + header "A.h" +} + +//--- X.h +#pragma clang module import A + +namespace project { + class thing : std::vec {}; +} // namespace project + +//--- B.h +#include "X.h" + +//--- B.cppmap +module "B" { + header "B.h" +} + +//--- C.h +#include "X.h" + +//--- C.cppmap +module "C" { + header "C.h" +} + +//--- D.h +#include "X.h" + +//--- D.cppmap +module "D" { + header "D.h" +} + +//--- Y.h +#include "X.h" +struct other { + other() : data(data) {} + std::vec data; +}; + +//--- E.h +#include "Y.h" + +//--- E.cppmap +module "E" { + header "E.h" +} + +//--- S.cpp +#pragma clang module import A +#pragma clang module import E +void func(std::vec *a, std::vec *b) { *a = *b; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Enable outline atomics for Haiku and Managarm aarch64 (PR #156299)
brad0 wrote: cc @no92 https://github.com/llvm/llvm-project/pull/156299 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Remove experimental from Zicfilp and Zicfiss (PR #157015)
https://github.com/tclin914 updated https://github.com/llvm/llvm-project/pull/157015 >From 930c01ca71be448e290de81e47bb36cc3ca19795 Mon Sep 17 00:00:00 2001 From: Jim Lin Date: Tue, 2 Sep 2025 14:52:44 +0800 Subject: [PATCH 1/2] [RISCV] Remove experimental from Zicfilp and Zicfiss These extensions were ratified in June 2024. --- clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c | 8 .../print-enabled-extensions/riscv-sifive-x390.c | 4 ++-- .../Driver/print-supported-extensions-riscv.c| 4 ++-- llvm/lib/Target/RISCV/RISCVFeatures.td | 8 llvm/test/CodeGen/RISCV/attributes.ll| 4 ++-- llvm/test/CodeGen/RISCV/calls.ll | 2 +- llvm/test/CodeGen/RISCV/features-info.ll | 4 ++-- llvm/test/CodeGen/RISCV/jumptable-swguarded.ll | 4 ++-- llvm/test/CodeGen/RISCV/lpad.ll | 8 llvm/test/CodeGen/RISCV/nest-register.ll | 4 ++-- llvm/test/CodeGen/RISCV/rv64-trampoline-cfi.ll | 4 ++-- llvm/test/CodeGen/RISCV/shadowcallstack.ll | 4 ++-- llvm/test/CodeGen/RISCV/tail-calls.ll| 2 +- .../CodeGen/RISCV/zicfilp-indirect-branch.ll | 2 +- llvm/test/MC/RISCV/attribute-arch-invalid.s | 4 ++-- llvm/test/MC/RISCV/compressed-zicfiss.s | 12 ++-- llvm/test/MC/RISCV/option-arch.s | 2 +- llvm/test/MC/RISCV/tail-call.s | 8 llvm/test/MC/RISCV/zicfilp-invalid.s | 4 ++-- llvm/test/MC/RISCV/zicfilp-valid.s | 12 ++-- llvm/test/MC/RISCV/zicfiss-invalid.s | 4 ++-- llvm/test/MC/RISCV/zicfiss-valid.s | 12 ++-- llvm/unittests/TargetParser/RISCVISAInfoTest.cpp | 16 23 files changed, 68 insertions(+), 68 deletions(-) diff --git a/clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c b/clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c index cabff7e598eb0..1a7671d16f342 100644 --- a/clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c +++ b/clang/test/CodeGen/RISCV/attr-hw-shadow-stack.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-zicfiss -emit-llvm -o - %s -fcf-protection=return | FileCheck %s -// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-zicfiss -emit-llvm -o - %s | FileCheck -check-prefix=NOSHADOWSTACK %s -// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zicfiss -emit-llvm -o - %s -fcf-protection=return | FileCheck %s -// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zicfiss -emit-llvm -o - %s | FileCheck -check-prefix=NOSHADOWSTACK %s +// RUN: %clang_cc1 -triple riscv64 -target-feature +zicfiss -emit-llvm -o - %s -fcf-protection=return | FileCheck %s +// RUN: %clang_cc1 -triple riscv64 -target-feature +zicfiss -emit-llvm -o - %s | FileCheck -check-prefix=NOSHADOWSTACK %s +// RUN: %clang_cc1 -triple riscv32 -target-feature +zicfiss -emit-llvm -o - %s -fcf-protection=return | FileCheck %s +// RUN: %clang_cc1 -triple riscv32 -target-feature +zicfiss -emit-llvm -o - %s | FileCheck -check-prefix=NOSHADOWSTACK %s int foo(int *a) { return *a; } diff --git a/clang/test/Driver/print-enabled-extensions/riscv-sifive-x390.c b/clang/test/Driver/print-enabled-extensions/riscv-sifive-x390.c index aa038a18693e0..f488347ee35b8 100644 --- a/clang/test/Driver/print-enabled-extensions/riscv-sifive-x390.c +++ b/clang/test/Driver/print-enabled-extensions/riscv-sifive-x390.c @@ -17,6 +17,8 @@ // CHECK-NEXT: ziccamoa 1.0 'Ziccamoa' (Main Memory Supports All Atomics in A) // CHECK-NEXT: ziccif 1.0 'Ziccif' (Main Memory Supports Instruction Fetch with Atomicity Requirement) // CHECK-NEXT: ziccrse 1.0 'Ziccrse' (Main Memory Supports Forward Progress on LR/SC Sequences) +// CHECK-NEXT: zicfilp 1.0 'Zicfilp' (Landing pad) +// CHECK-NEXT: zicfiss 1.0 'Zicfiss' (Shadow stack) // CHECK-NEXT: zicntr 2.0 'Zicntr' (Base Counters and Timers) // CHECK-NEXT: zicond 1.0 'Zicond' (Integer Conditional Operations) // CHECK-NEXT: zicsr2.0 'Zicsr' (CSRs) @@ -65,7 +67,5 @@ // CHECK-NEXT: xsifivecflushdlone 1.0 'XSiFivecflushdlone' (SiFive sf.cflush.d.l1 Instruction) // CHECK-EMPTY: // CHECK-NEXT: Experimental extensions -// CHECK-NEXT: zicfilp 1.0 'Zicfilp' (Landing pad) -// CHECK-NEXT: zicfiss 1.0 'Zicfiss' (Shadow stack) // CHECK-EMPTY: // CHECK-NEXT: ISA String: rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_b1p0_v1p0_zic64b1p0_zicbom1p0_zicbop1p0_zicboz1p0_ziccamoa1p0_ziccif1p0_ziccrse1p0_zicfilp1p0_zicfiss1p0_zicntr2p0_zicond1p0_zicsr2p0_zifencei2p0_zihintntl1p0_zihintpause2p0_zihpm2p0_zimop1p0_zmmul1p0_za64rs1p0_zaamo1p0_zalrsc1p0_zawrs1p0_zfa1p0_zfbfmin1p0_zfh1p0_zfhmin1p0_zca1p0_zcb1p0_zcd1p0_zcmop1p0_zba1p0_zbb1p0_zbs1p0_zkr1p0_zkt1p0_z
[clang] [clang] fix definition data not being propagated to all redecls (PR #157019)
https://github.com/ChuanqiXu9 approved this pull request. The change itself looks good and makes sense. https://github.com/llvm/llvm-project/pull/157019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 83da177 - [CIR] Add support for delegating constructor initialization (#156757)
Author: Andy Kaylor Date: 2025-09-04T14:00:31-07:00 New Revision: 83da177dba86eece8b19d55857ad842f92ced30e URL: https://github.com/llvm/llvm-project/commit/83da177dba86eece8b19d55857ad842f92ced30e DIFF: https://github.com/llvm/llvm-project/commit/83da177dba86eece8b19d55857ad842f92ced30e.diff LOG: [CIR] Add support for delegating constructor initialization (#156757) This adds support for zero-initialization during delegating constructor processing. Note, this also adds code to skip emitting constructors that are trivial and default to match the classic codegen behavior. The incubator does not skip these constructors, but I have found a case where this results in a call to a default constructor that is never defined. Added: clang/test/CIR/CodeGen/delegating-ctor.cpp Modified: clang/lib/CIR/CodeGen/CIRGenExpr.cpp clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp clang/test/CIR/CodeGen/new.cpp clang/test/CIR/CodeGen/vbase.cpp Removed: diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp index aec60d01fc238..d8c7903a4888d 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp @@ -1966,15 +1966,23 @@ void CIRGenFunction::emitCXXConstructExpr(const CXXConstructExpr *e, // constructor, emit the zero initialization now, unless destination is // already zeroed. if (e->requiresZeroInitialization() && !dest.isZeroed()) { -cgm.errorNYI(e->getSourceRange(), - "emitCXXConstructExpr: requires initialization"); -return; +switch (e->getConstructionKind()) { +case CXXConstructionKind::Delegating: +case CXXConstructionKind::Complete: + emitNullInitialization(getLoc(e->getSourceRange()), dest.getAddress(), + e->getType()); + break; +case CXXConstructionKind::VirtualBase: +case CXXConstructionKind::NonVirtualBase: + cgm.errorNYI(e->getSourceRange(), + "emitCXXConstructExpr: base requires initialization"); + break; +} } - // If this is a call to a trivial default constructor: - // In LLVM: do nothing. - // In CIR: emit as a regular call, other later passes should lower the - // ctor call into trivial initialization. + // If this is a call to a trivial default constructor, do nothing. + if (cd->isTrivial() && cd->isDefaultConstructor()) +return; // Elide the constructor if we're constructing from a temporary if (getLangOpts().ElideConstructors && e->isElidable()) { diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp index 3b76c0981fe80..ee9f58c829ca9 100644 --- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp +++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp @@ -1368,6 +1368,15 @@ mlir::LogicalResult CIRToLLVMConstantOpLowering::matchAndRewrite( rewriter.replaceOp(op, lowerCirAttrAsValue(op, op.getValue(), rewriter, getTypeConverter())); return mlir::success(); + } else if (auto recTy = mlir::dyn_cast(op.getType())) { +if (mlir::isa(attr)) { + mlir::Value initVal = + lowerCirAttrAsValue(op, attr, rewriter, typeConverter); + rewriter.replaceOp(op, initVal); + return mlir::success(); +} +return op.emitError() << "unsupported lowering for record constant type " + << op.getType(); } else if (auto complexTy = mlir::dyn_cast(op.getType())) { mlir::Type complexElemTy = complexTy.getElementType(); mlir::Type complexElemLLVMTy = typeConverter->convertType(complexElemTy); diff --git a/clang/test/CIR/CodeGen/delegating-ctor.cpp b/clang/test/CIR/CodeGen/delegating-ctor.cpp new file mode 100644 index 0..a9cfc5d02173d --- /dev/null +++ b/clang/test/CIR/CodeGen/delegating-ctor.cpp @@ -0,0 +1,72 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir +// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll +// RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll +// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG + +struct Delegating { + Delegating(); + Delegating(int); +}; + +// Check that the constructor being delegated to is called with the correct +// arguments. +Delegating::Delegating() : Delegating(0) {} + +// CIR: cir.func {{.*}} @_ZN10DelegatingC2Ev(%[[THIS_ARG:.*]]: !cir.ptr {{.*}}) +// CIR: %[[THIS_ADDR:.*]] = cir.alloca !cir.ptr, !cir.ptr>, ["this", init] +// CIR: cir.store{{.*}} %[[THIS_ARG]], %[[THIS_ADDR]] +// CIR: %[[THIS:.*]] = cir.load %[[THIS_ADDR]] +// CIR: %[[ZERO:.*]] = cir.const #cir.int<0> : !s32i +// CIR: cir.call @_ZN10Del
[clang] [clang-tools-extra] [compiler-rt] [flang] [libcxx] [libcxxabi] [lld] [lldb] [llvm] [Inclusive Language] migrate "sanity" checks to "soundness" checks (PR #156995)
j2kun wrote: Maybe "spot check" instead of "sanity check", though "spot" is not a replacement for "sanity" generally https://github.com/llvm/llvm-project/pull/156995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [flang] [libcxx] [libcxxabi] [lld] [lldb] [llvm] [Inclusive Language] migrate "sanity" checks to "soundness" checks (PR #156995)
https://github.com/vanvoorden edited https://github.com/llvm/llvm-project/pull/156995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [flang] [libcxx] [libcxxabi] [lld] [lldb] [llvm] [Inclusive Language] migrate "sanity" checks to "soundness" checks (PR #156995)
https://github.com/vanvoorden edited https://github.com/llvm/llvm-project/pull/156995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [flang] [libcxx] [libcxxabi] [lld] [lldb] [llvm] [Inclusive Language] migrate "sanity" checks to "soundness" checks (PR #156995)
https://github.com/vanvoorden edited https://github.com/llvm/llvm-project/pull/156995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Support includes translated to module imports in -header-include-filtering=direct-per-file (PR #156756)
https://github.com/sina-mahdavi updated https://github.com/llvm/llvm-project/pull/156756 >From 8ab5647fc5c51b42bb67ca46a063fa9815ea46f4 Mon Sep 17 00:00:00 2001 From: Sina Mahdavi Date: Wed, 3 Sep 2025 14:17:27 -0700 Subject: [PATCH 1/3] [Clang] Support includes translated to module imports in -header-include-filtering=direct-per-file --- clang/lib/Frontend/HeaderIncludeGen.cpp | 73 - 1 file changed, 60 insertions(+), 13 deletions(-) diff --git a/clang/lib/Frontend/HeaderIncludeGen.cpp b/clang/lib/Frontend/HeaderIncludeGen.cpp index 8ab335905f9f2..8de8d61b6262c 100644 --- a/clang/lib/Frontend/HeaderIncludeGen.cpp +++ b/clang/lib/Frontend/HeaderIncludeGen.cpp @@ -112,11 +112,17 @@ class HeaderIncludesJSONCallback : public PPCallbacks { /// an array of separate entries, one for each non-system source file used in /// the compilation showing only the direct includes and imports from that file. class HeaderIncludesDirectPerFileCallback : public PPCallbacks { + struct HeaderIncludeInfo { +SourceLocation location; +FileEntryRef file; +const Module *importedModule; + }; + SourceManager &SM; HeaderSearch &HSI; raw_ostream *OutputFile; bool OwnsOutputFile; - using DependencyMap = llvm::DenseMap>; + using DependencyMap = llvm::DenseMap>; DependencyMap Dependencies; public: @@ -390,18 +396,43 @@ void HeaderIncludesDirectPerFileCallback::EndOfMainFile() { std::string Str; llvm::raw_string_ostream OS(Str); llvm::json::OStream JOS(OS); - JOS.array([&] { -for (auto S = SourceFiles.begin(), SE = SourceFiles.end(); S != SE; ++S) { - JOS.object([&] { -SmallVector &Deps = Dependencies[*S]; -JOS.attribute("source", S->getName().str()); -JOS.attributeArray("includes", [&] { - for (unsigned I = 0, N = Deps.size(); I != N; ++I) -JOS.value(Deps[I].getName().str()); + JOS.object([&] { +JOS.attribute("version", "2.0.0"); +JOS.attributeArray("dependencies", [&] { + for (auto S = SourceFiles.begin(), SE = SourceFiles.end(); S != SE; ++S) { +JOS.object([&] { + SmallVector &Deps = Dependencies[*S]; + JOS.attribute("source", S->getName().str()); + JOS.attributeArray("includes", [&] { +for (unsigned I = 0, N = Deps.size(); I != N; ++I) { + if (!Deps[I].importedModule) { +JOS.object([&] { + PresumedLoc PLoc = SM.getPresumedLoc(Deps[I].location); + std::string locationStr = PLoc.isInvalid() ? "" : std::to_string(PLoc.getLine()) + ":" + std::to_string(PLoc.getColumn()); + JOS.attribute("location", locationStr); + JOS.attribute("file", Deps[I].file.getName()); +}); + } +} + }); + JOS.attributeArray("imports", [&] { +for (unsigned I = 0, N = Deps.size(); I != N; ++I) { + if (Deps[I].importedModule) { +JOS.object([&] { + PresumedLoc PLoc = SM.getPresumedLoc(Deps[I].location); + std::string locationStr = PLoc.isInvalid() ? "" : std::to_string(PLoc.getLine()) + ":" + std::to_string(PLoc.getColumn()); + JOS.attribute("location", locationStr); + JOS.attribute("module", Deps[I].importedModule->getTopLevelModuleName()); + JOS.attribute("file", Deps[I].file.getName()); +}); + } +} + }); }); - }); -} + } +}); }); + OS << "\n"; if (OutputFile->get_kind() == raw_ostream::OStreamKind::OK_FDStream) { @@ -427,7 +458,19 @@ void HeaderIncludesDirectPerFileCallback::InclusionDirective( if (!FromFile) return; - Dependencies[*FromFile].push_back(*File); + FileEntryRef headerOrModule = *File; + if (ModuleImported && SuggestedModule) { +OptionalFileEntryRef ModuleMapFile = HSI.getModuleMap().getModuleMapFileForUniquing(SuggestedModule); +if (ModuleMapFile) { + headerOrModule = *ModuleMapFile; +} + } + + Dependencies[*FromFile].push_back({ +.location = Loc, +.file = headerOrModule, +.importedModule = (ModuleImported ? SuggestedModule : nullptr) + }); } void HeaderIncludesDirectPerFileCallback::moduleImport(SourceLocation ImportLoc, @@ -448,5 +491,9 @@ void HeaderIncludesDirectPerFileCallback::moduleImport(SourceLocation ImportLoc, if (!ModuleMapFile) return; - Dependencies[*FromFile].push_back(*ModuleMapFile); + Dependencies[*FromFile].push_back({ +.location = Loc, +.file = *ModuleMapFile, +.importedModule = Imported + }); } >From c4405abf5830ed6f858d1ec17817e24418c62e81 Mon Sep 17 00:00:00 2001 From: Sina Mahdavi Date: Thu, 4 Sep 2025 17:34:18 -0700 Subject: [PATCH 2/3] [Clang] Include source location file name in include tracing output and fixing syntax --- clang/lib/Frontend/HeaderIncludeGen.cpp | 51 +++
[clang-tools-extra] [clangd] [C++20 Modules] Try to use prebuilt modules (PR #155360)
https://github.com/ChuanqiXu9 closed https://github.com/llvm/llvm-project/pull/155360 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Driver][LoongArch] Enable linker relaxation by default for loongarch64 (PR #156315)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `clang-armv8-quick` running on `linaro-clang-armv8-quick` while building `clang,flang` at step 5 "ninja check 1". Full details are available at: https://lab.llvm.org/buildbot/#/builders/154/builds/21106 Here is the relevant piece of the build log for the reference ``` Step 5 (ninja check 1) failure: stage 1 checked (failure) TEST 'Clangd Unit Tests :: ./ClangdTests/245/332' FAILED Script(shard): -- GTEST_OUTPUT=json:/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/clangd/unittests/./ClangdTests-Clangd Unit Tests-3491162-245-332.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=332 GTEST_SHARD_INDEX=245 /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/clangd/unittests/./ClangdTests -- Note: This is test shard 246 of 332. [==] Running 4 tests from 4 test suites. [--] Global test environment set-up. [--] 1 test from CompletionStringTest [ RUN ] CompletionStringTest.GetDeclCommentBadUTF8 Built preamble of size 341764 for file /clangd-test/TestTU.cpp version null in 1.60 seconds [ OK ] CompletionStringTest.GetDeclCommentBadUTF8 (3681 ms) [--] 1 test from CompletionStringTest (3681 ms total) [--] 1 test from FuzzyMatch [ RUN ] FuzzyMatch.Scoring [ OK ] FuzzyMatch.Scoring (50 ms) [--] 1 test from FuzzyMatch (50 ms total) [--] 1 test from CrossFileRenameTests [ RUN ] CrossFileRenameTests.WithUpToDateIndex ASTWorker building file /clangd-test/foo.h version null with command [/clangd-test] clang -xobjective-c++ /clangd-test/foo.h Driver produced command: cc1 -cc1 -triple armv8a-unknown-linux-gnueabihf -fsyntax-only -disable-free -clear-ast-before-backend -main-file-name foo.h -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -target-feature +read-tp-tpidruro -target-feature +vfp2 -target-feature +vfp2sp -target-feature +vfp3 -target-feature +vfp3d16 -target-feature +vfp3d16sp -target-feature +vfp3sp -target-feature +fp16 -target-feature +vfp4 -target-feature +vfp4d16 -target-feature +vfp4d16sp -target-feature +vfp4sp -target-feature +fp-armv8 -target-feature +fp-armv8d16 -target-feature +fp-armv8d16sp -target-feature +fp-armv8sp -target-feature -fullfp16 -target-feature +fp64 -target-feature +d32 -target-feature +sha2 -target-feature +aes -target-feature -fp16fml -target-feature +neon -target-abi aapcs-linux -mfloat-abi hard -debugger-tuning=gdb -fdebug-compilation-dir=/clangd-test -fcoverage-compilation-dir=/clangd-test -resource-dir lib/clang/22 -internal-isystem lib/clang/22/include -internal-isystem /usr/local/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fobjc-runtime=gcc -fobjc-encode-cxx-class-template-spec -fobjc-exceptions -fcxx-exceptions -fexceptions -no-round-trip-args -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x objective-c++ /clangd-test/foo.h Building first preamble for /clangd-test/foo.h version null Built preamble of size 420812 for file /clangd-test/foo.h version null in 0.15 seconds indexed preamble AST for /clangd-test/foo.h version null: symbol slab: 0 symbols, 68 bytes ref slab: 0 symbols, 0 refs, 72 bytes relations slab: 0 relations, 12 bytes indexed file AST for /clangd-test/foo.h version null: symbol slab: 3 symbols, 4584 bytes ref slab: 3 symbols, 5 refs, 4232 bytes relations slab: 0 relations, 12 bytes Build dynamic index for main-file symbols with estimated memory usage of 11148 bytes ASTWorker building file /clangd-test/foo.cc version null with command [/clangd-test] clang -xobjective-c++ /clangd-test/foo.cc Driver produced command: cc1 -cc1 -triple armv8a-unknown-linux-gnueabihf -fsyntax-only -disable-free -clear-ast-before-backend -main-file-name foo.cc -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -target-feature +read-tp-tpidruro -target-feature +vfp2 -target-feature +vfp2sp -target-feature +vfp3 -target-feature +vfp3d16 -target-feature +vfp3d16sp -target-feature +vfp3sp -target-feature +fp16 -target-feature +vfp4 -target-feature +vfp4d16 -target-feature +vfp4d16sp -target-feature +vfp4sp -target-feature +fp-armv8 -target-feature +fp-armv8d16 -target-feature +fp-armv8d16sp -target-feature +fp-armv8sp -target-feature -fullfp16 -target-feature +fp64 -target-feature +d32 -target-feature +sha2 -target-feature +aes -target-feature -fp16fml -target-feature +neon -target-abi aapcs-linux -mfloat-abi hard -debugger-tuning=gdb -fdebug-compilation-dir=/clangd-test -fcoverage-compilation-dir=/clangd-test -resource-dir lib/clang/22 -internal-isystem l
[clang] 0d490ae - [clang] fix definition data not being propagated to all redecls (#157019)
Author: Matheus Izvekov Date: 2025-09-05T03:36:57-03:00 New Revision: 0d490ae55f3ef60c3b9c18873567eeef47be30ed URL: https://github.com/llvm/llvm-project/commit/0d490ae55f3ef60c3b9c18873567eeef47be30ed DIFF: https://github.com/llvm/llvm-project/commit/0d490ae55f3ef60c3b9c18873567eeef47be30ed.diff LOG: [clang] fix definition data not being propagated to all redecls (#157019) This fixes the workaround added in 8a63989, so that when a fake definition data is corrected, all redeclarations are also updated to point to it. Since this regression was never released, there are no release notes. Fixes #154840 Added: clang/test/Modules/GH154840.cpp Modified: clang/lib/Serialization/ASTReaderDecl.cpp Removed: diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 6b35b205079e5..44b8ba6f4c984 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -2107,6 +2107,8 @@ void ASTDeclMerger::MergeDefinitionData( auto *Def = DD.Definition; DD = std::move(MergeDD); DD.Definition = Def; +while ((Def = Def->getPreviousDecl())) + cast(Def)->DefinitionData = ⅅ return; } diff --git a/clang/test/Modules/GH154840.cpp b/clang/test/Modules/GH154840.cpp new file mode 100644 index 0..afeb39acb5484 --- /dev/null +++ b/clang/test/Modules/GH154840.cpp @@ -0,0 +1,97 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: split-file %s %t +// RUN: cd %t +// +// RUN: %clang_cc1 -fmodule-name=A -fno-cxx-modules -emit-module -fmodules -xc++ A.cppmap -o A.pcm +// RUN: %clang_cc1 -fmodule-name=B -fno-cxx-modules -emit-module -fmodules -xc++ B.cppmap -o B.pcm -fmodule-file=A.pcm +// RUN: %clang_cc1 -fmodule-name=C -fno-cxx-modules -emit-module -fmodules -xc++ C.cppmap -o C.pcm -fmodule-file=A.pcm +// RUN: %clang_cc1 -fmodule-name=D -fno-cxx-modules -emit-module -fmodules -xc++ D.cppmap -o D.pcm -fmodule-file=A.pcm +// RUN: %clang_cc1 -fmodule-name=E -fno-cxx-modules -emit-module -fmodules -xc++ E.cppmap -o E.pcm -fmodule-file=D.pcm -fmodule-file=B.pcm -fmodule-file=C.pcm +// RUN: %clang_cc1 -fno-cxx-modules -fmodules -fmodule-file=B.pcm -fmodule-file=E.pcm -emit-llvm -o /dev/null S.cpp + +//--- A.h +namespace std { + +template void zz(T); + +template struct vec { + struct w {}; + struct xx {}; + + vec(vec &) { init(); } + constexpr vec &operator=(const vec &); + template constexpr void pb(U); + constexpr void init(); + + w s; +}; + +template constexpr void vec::init() { + xx yy; + zz(yy); +} + +template constexpr vec &vec::operator=(const vec &) { + pb(s); + return *this; +} + +template template constexpr void vec::pb(U) { init(); } +} // namespace std + +//--- A.cppmap +module "A" { + header "A.h" +} + +//--- X.h +#pragma clang module import A + +namespace project { + class thing : std::vec {}; +} // namespace project + +//--- B.h +#include "X.h" + +//--- B.cppmap +module "B" { + header "B.h" +} + +//--- C.h +#include "X.h" + +//--- C.cppmap +module "C" { + header "C.h" +} + +//--- D.h +#include "X.h" + +//--- D.cppmap +module "D" { + header "D.h" +} + +//--- Y.h +#include "X.h" +struct other { + other() : data(data) {} + std::vec data; +}; + +//--- E.h +#include "Y.h" + +//--- E.cppmap +module "E" { + header "E.h" +} + +//--- S.cpp +#pragma clang module import A +#pragma clang module import E +void func(std::vec *a, std::vec *b) { *a = *b; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [Driver][LoongArch] Enable linker relaxation by default for loongarch64 (PR #156315)
https://github.com/zhaoqi5 closed https://github.com/llvm/llvm-project/pull/156315 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang-Repl] Sinking RemoteJITUtils into Interpreter class(Refactoring) (PR #155140)
@@ -115,31 +116,60 @@ class Interpreter { /// An optional compiler instance for CUDA offloading std::unique_ptr DeviceCI; +public: + struct OutOfProcessJITConfig { +/// Indicates whether out-of-process JIT execution is enabled. +bool IsOutOfProcess; kr-2003 wrote: I have the initialisation in the constructor of the class. https://github.com/llvm/llvm-project/pull/155140 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Add template argument support for {con,de}structor attributes. (PR #151400)
https://github.com/tynasello updated https://github.com/llvm/llvm-project/pull/151400 >From e7c6ad6a7642c90414da78073c29695fe5ea036f Mon Sep 17 00:00:00 2001 From: tynasello Date: Tue, 29 Jul 2025 23:41:09 + Subject: [PATCH 1/5] [Clang] Add template argument support for {con,de}structor attributes. Fixes: https://github.com/llvm/llvm-project/issues/67154 --- clang/include/clang/Basic/Attr.td | 12 +- clang/lib/CodeGen/CodeGenModule.cpp | 14 ++- clang/lib/Sema/SemaDeclAttr.cpp | 39 +-- clang/test/AST/ast-dump-attr.cpp | 3 +- clang/test/CodeGenCXX/constructor-attr.cpp| 15 +++ clang/test/CodeGenCXX/destructor-attr.cpp | 23 +++ ...-attribute.c => constructor-attribute.cpp} | 4 +- 7 files changed, 92 insertions(+), 18 deletions(-) create mode 100644 clang/test/CodeGenCXX/destructor-attr.cpp rename clang/test/Sema/{constructor-attribute.c => constructor-attribute.cpp} (77%) diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 224cb6a32af28..c67aaeda9be70 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -1463,9 +1463,13 @@ def ConstInit : InheritableAttr { def Constructor : InheritableAttr { let Spellings = [GCC<"constructor">]; - let Args = [DefaultIntArgument<"Priority", 65535>]; + let Args = [ExprArgument<"Priority", 1>]; let Subjects = SubjectList<[Function]>; + let TemplateDependent = 1; let Documentation = [CtorDtorDocs]; + let AdditionalMembers = [{ +static constexpr unsigned int DefaultPriority = 65535; + }]; } def CPUSpecific : InheritableAttr { @@ -1797,9 +1801,13 @@ def Deprecated : InheritableAttr { def Destructor : InheritableAttr { let Spellings = [GCC<"destructor">]; - let Args = [DefaultIntArgument<"Priority", 65535>]; + let Args = [ExprArgument<"Priority", 1>]; let Subjects = SubjectList<[Function]>; + let TemplateDependent = 1; let Documentation = [CtorDtorDocs]; + let AdditionalMembers = [{ +static constexpr unsigned int DefaultPriority = 65535; + }]; } def EmptyBases : InheritableAttr, TargetSpecificAttr { diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 834b1c067d84c..1bd6998ca3c75 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -6324,10 +6324,20 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD, SetLLVMFunctionAttributesForDefinition(D, Fn); + auto getPriority = [this](auto *Attr) -> int { +int priority = Attr->DefaultPriority; +Expr *E = Attr->getPriority(); +if (E) { + if (auto CE = E->getIntegerConstantExpr(this->getContext())) +priority = CE->getExtValue(); +} +return priority; + }; + if (const ConstructorAttr *CA = D->getAttr()) -AddGlobalCtor(Fn, CA->getPriority()); +AddGlobalCtor(Fn, getPriority(CA)); if (const DestructorAttr *DA = D->getAttr()) -AddGlobalDtor(Fn, DA->getPriority(), true); +AddGlobalDtor(Fn, getPriority(DA), true); if (getLangOpts().OpenMP && D->hasAttr()) getOpenMPRuntime().emitDeclareTargetFunction(D, GV); } diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 16b18bcb6a2a0..e03ba4c49e328 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2152,29 +2152,44 @@ static void handleUnusedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { D->addAttr(::new (S.Context) UnusedAttr(S.Context, AL)); } +static std::optional sharedGetConstructorDestructorAttrExpr(Sema &S, const ParsedAttr &AL) { + Expr *E = nullptr; + if (AL.getNumArgs() == 1) { +E = AL.getArgAsExpr(0); +if (E->isValueDependent()) { + if (!E->isTypeDependent() && !E->getType()->isIntegerType()) { +S.Diag(AL.getLoc(), diag::err_attribute_argument_type) +<< AL << AANT_ArgumentIntegerConstant << E->getSourceRange(); +return std::nullopt; + } +} else { + uint32_t priority; + if (!S.checkUInt32Argument(AL, AL.getArgAsExpr(0), priority)) { +return std::nullopt; + } +} + } + return E; +} + static void handleConstructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { - uint32_t priority = ConstructorAttr::DefaultPriority; if (S.getLangOpts().HLSL && AL.getNumArgs()) { S.Diag(AL.getLoc(), diag::err_hlsl_init_priority_unsupported); return; } - if (AL.getNumArgs() && - !S.checkUInt32Argument(AL, AL.getArgAsExpr(0), priority)) + auto E = sharedGetConstructorDestructorAttrExpr(S, AL); + if (!E.has_value()) return; - S.Diag(D->getLocation(), diag::warn_global_constructor) - << D->getSourceRange(); - - D->addAttr(::new (S.Context) ConstructorAttr(S.Context, AL, priority)); + S.Diag(D->getLocation(), diag::warn_global_constructor) << D->getSourceRange(); + D->addAttr(::new (S.Context) ConstructorAttr(S.Context, AL, E.va
[clang] [Clang] Add template argument support for {con,de}structor attributes. (PR #151400)
https://github.com/tynasello updated https://github.com/llvm/llvm-project/pull/151400 >From e7c6ad6a7642c90414da78073c29695fe5ea036f Mon Sep 17 00:00:00 2001 From: tynasello Date: Tue, 29 Jul 2025 23:41:09 + Subject: [PATCH 1/5] [Clang] Add template argument support for {con,de}structor attributes. Fixes: https://github.com/llvm/llvm-project/issues/67154 --- clang/include/clang/Basic/Attr.td | 12 +- clang/lib/CodeGen/CodeGenModule.cpp | 14 ++- clang/lib/Sema/SemaDeclAttr.cpp | 39 +-- clang/test/AST/ast-dump-attr.cpp | 3 +- clang/test/CodeGenCXX/constructor-attr.cpp| 15 +++ clang/test/CodeGenCXX/destructor-attr.cpp | 23 +++ ...-attribute.c => constructor-attribute.cpp} | 4 +- 7 files changed, 92 insertions(+), 18 deletions(-) create mode 100644 clang/test/CodeGenCXX/destructor-attr.cpp rename clang/test/Sema/{constructor-attribute.c => constructor-attribute.cpp} (77%) diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 224cb6a32af28..c67aaeda9be70 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -1463,9 +1463,13 @@ def ConstInit : InheritableAttr { def Constructor : InheritableAttr { let Spellings = [GCC<"constructor">]; - let Args = [DefaultIntArgument<"Priority", 65535>]; + let Args = [ExprArgument<"Priority", 1>]; let Subjects = SubjectList<[Function]>; + let TemplateDependent = 1; let Documentation = [CtorDtorDocs]; + let AdditionalMembers = [{ +static constexpr unsigned int DefaultPriority = 65535; + }]; } def CPUSpecific : InheritableAttr { @@ -1797,9 +1801,13 @@ def Deprecated : InheritableAttr { def Destructor : InheritableAttr { let Spellings = [GCC<"destructor">]; - let Args = [DefaultIntArgument<"Priority", 65535>]; + let Args = [ExprArgument<"Priority", 1>]; let Subjects = SubjectList<[Function]>; + let TemplateDependent = 1; let Documentation = [CtorDtorDocs]; + let AdditionalMembers = [{ +static constexpr unsigned int DefaultPriority = 65535; + }]; } def EmptyBases : InheritableAttr, TargetSpecificAttr { diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 834b1c067d84c..1bd6998ca3c75 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -6324,10 +6324,20 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD, SetLLVMFunctionAttributesForDefinition(D, Fn); + auto getPriority = [this](auto *Attr) -> int { +int priority = Attr->DefaultPriority; +Expr *E = Attr->getPriority(); +if (E) { + if (auto CE = E->getIntegerConstantExpr(this->getContext())) +priority = CE->getExtValue(); +} +return priority; + }; + if (const ConstructorAttr *CA = D->getAttr()) -AddGlobalCtor(Fn, CA->getPriority()); +AddGlobalCtor(Fn, getPriority(CA)); if (const DestructorAttr *DA = D->getAttr()) -AddGlobalDtor(Fn, DA->getPriority(), true); +AddGlobalDtor(Fn, getPriority(DA), true); if (getLangOpts().OpenMP && D->hasAttr()) getOpenMPRuntime().emitDeclareTargetFunction(D, GV); } diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 16b18bcb6a2a0..e03ba4c49e328 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2152,29 +2152,44 @@ static void handleUnusedAttr(Sema &S, Decl *D, const ParsedAttr &AL) { D->addAttr(::new (S.Context) UnusedAttr(S.Context, AL)); } +static std::optional sharedGetConstructorDestructorAttrExpr(Sema &S, const ParsedAttr &AL) { + Expr *E = nullptr; + if (AL.getNumArgs() == 1) { +E = AL.getArgAsExpr(0); +if (E->isValueDependent()) { + if (!E->isTypeDependent() && !E->getType()->isIntegerType()) { +S.Diag(AL.getLoc(), diag::err_attribute_argument_type) +<< AL << AANT_ArgumentIntegerConstant << E->getSourceRange(); +return std::nullopt; + } +} else { + uint32_t priority; + if (!S.checkUInt32Argument(AL, AL.getArgAsExpr(0), priority)) { +return std::nullopt; + } +} + } + return E; +} + static void handleConstructorAttr(Sema &S, Decl *D, const ParsedAttr &AL) { - uint32_t priority = ConstructorAttr::DefaultPriority; if (S.getLangOpts().HLSL && AL.getNumArgs()) { S.Diag(AL.getLoc(), diag::err_hlsl_init_priority_unsupported); return; } - if (AL.getNumArgs() && - !S.checkUInt32Argument(AL, AL.getArgAsExpr(0), priority)) + auto E = sharedGetConstructorDestructorAttrExpr(S, AL); + if (!E.has_value()) return; - S.Diag(D->getLocation(), diag::warn_global_constructor) - << D->getSourceRange(); - - D->addAttr(::new (S.Context) ConstructorAttr(S.Context, AL, priority)); + S.Diag(D->getLocation(), diag::warn_global_constructor) << D->getSourceRange(); + D->addAttr(::new (S.Context) ConstructorAttr(S.Context, AL, E.va
[clang] [Clang-Repl] Sinking RemoteJITUtils into Interpreter class(Refactoring) (PR #155140)
@@ -115,31 +116,60 @@ class Interpreter { /// An optional compiler instance for CUDA offloading std::unique_ptr DeviceCI; +public: + struct OutOfProcessJITConfig { +/// Indicates whether out-of-process JIT execution is enabled. +bool IsOutOfProcess; +/// Path to the out-of-process JIT executor. +std::string OOPExecutor; +std::string OOPExecutorConnect; +/// Indicates whether to use shared memory for communication. +bool UseSharedMemory; kr-2003 wrote: I have the initialisation in the constructor of the class. https://github.com/llvm/llvm-project/pull/155140 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Override generic symbol using llvm-link --override flag instead of using weak linkage (PR #156778)
https://github.com/frasercrmck approved this pull request. Nice find, thanks. It might mean it's harder to move away from using LLVM tools (like `llvm-link`) and towards something more like the other runtimes libraries do (using clang), though. I don't know if that's on the roadmap or not. https://github.com/llvm/llvm-project/pull/156778 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix definition data not being propagated to all redecls (PR #157019)
@@ -2107,6 +2107,8 @@ void ASTDeclMerger::MergeDefinitionData( auto *Def = DD.Definition; DD = std::move(MergeDD); DD.Definition = Def; +for (auto *TD : Def->redecls()) ChuanqiXu9 wrote: I am not sure if we should use `noload_redecls()` since redecls may trigger loading. https://github.com/llvm/llvm-project/pull/157019 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix typo in comment (PR #156962)
https://github.com/benwu25 updated https://github.com/llvm/llvm-project/pull/156962 >From be9d9a9cddb5cd1a2cb40017fdbd93d53c09a310 Mon Sep 17 00:00:00 2001 From: benwu25 Date: Thu, 4 Sep 2025 13:17:58 -0700 Subject: [PATCH] [clang] Fix typo in comment --- clang/lib/Basic/Builtins.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Basic/Builtins.cpp b/clang/lib/Basic/Builtins.cpp index 885abdc152e3a..acd98fe84adf5 100644 --- a/clang/lib/Basic/Builtins.cpp +++ b/clang/lib/Basic/Builtins.cpp @@ -165,7 +165,7 @@ static bool builtinIsSupported(const llvm::StringTable &Strings, /* OpenCLC Unsupported */ if (!LangOpts.OpenCL && (BuiltinInfo.Langs & ALL_OCL_LANGUAGES)) return false; - /* OopenCL GAS Unsupported */ + /* OpenCL GAS Unsupported */ if (!LangOpts.OpenCLGenericAddressSpace && (BuiltinInfo.Langs & OCL_GAS)) return false; /* OpenCL Pipe Unsupported */ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CodeComplete] Omit ExplicitObject when completing code (PR #92743)
https://github.com/HighCommander4 closed https://github.com/llvm/llvm-project/pull/92743 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [OpenMP 5.2] New syntax for 'uses_allocators' clause (PR #157025)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Urvi Rav (ravurvi20) Changes This patch updates the parsing changes to handle the new syntax of the `uses_allocators` clause as defined in OpenMP 5.2(Section 6.8). ``` // Case 1: Allocator without traits // < 5.2 → error // ≥ 5.2 → OK, empty traits set #pragma omp target teams uses_allocators(cgroup_alloc) // Case 2: Allocator with traits // Old syntax (< 5.2): #pragma omp target teams uses_allocators(cgroup_alloc(cgroup_traits)) // New syntax (≥ 5.2): #pragma omp target teams uses_allocators(traits(cgroup_traits) : cgroup_alloc) // Case 3: Multiple allocators // Old syntax (< 5.2), comma-separated: #pragma omp target teams uses_allocators(cgroup_alloc(cgroup_traits), aligned_alloc(aligned_traits)) // New syntax (≥ 5.2), semicolon-separated: #pragma omp target teams uses_allocators(traits(cgroup_traits) : cgroup_alloc; traits(aligned_traits) : aligned_alloc) ``` --- Full diff: https://github.com/llvm/llvm-project/pull/157025.diff 4 Files Affected: - (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+5) - (modified) clang/lib/Parse/ParseOpenMP.cpp (+71) - (modified) clang/lib/Sema/SemaOpenMP.cpp (+2) - (modified) clang/test/OpenMP/target_uses_allocators_messages.cpp (+23-4) ``diff diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index bc7a6e231d93c..44c3d07bf6027 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1497,6 +1497,11 @@ def err_omp_multiple_step_or_linear_modifier : Error< "multiple %select{'step size'|'linear modifier'}0 found in linear clause">; def err_omp_deprecate_old_syntax: Error< "old syntax '%0' on '%1' clause was deprecated, use new syntax '%2'">; +def warn_omp_deprecate_old_syntax: Warning< + "old syntax '%0' on '%1' clause was deprecated, use new syntax '%2'">, + InGroup; +def err_omp_allocator_comma_separator : + Error<"',' not allowed as separator in 'uses_allocators' clause, use ';' instead">; def warn_omp_future_directive_spelling: Warning< "directive spelling '%0' is introduced in a later OpenMP version">, InGroup; diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 5db2f2e2ccf86..92abc7084bed0 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2959,6 +2959,69 @@ OMPClause *Parser::ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind) { return nullptr; SmallVector Data; do { +// Parse 'traits(expr) : Allocator' for >=5.2 +if (getLangOpts().OpenMP >= 52 && +Tok.is(tok::identifier) && +Tok.getIdentifierInfo()->getName() == "traits") { + + SemaOpenMP::UsesAllocatorsData &D = Data.emplace_back(); + + ConsumeToken(); + + // Parse '(' ')' + BalancedDelimiterTracker TraitParens(*this, tok::l_paren, tok::annot_pragma_openmp_end); + TraitParens.consumeOpen(); + ExprResult AllocatorTraits = + getLangOpts().CPlusPlus ? ParseCXXIdExpression() : ParseExpression(); + TraitParens.consumeClose(); + + if (AllocatorTraits.isInvalid()) { +SkipUntil({tok::comma, tok::semi, tok::r_paren, tok::annot_pragma_openmp_end}, + StopBeforeMatch); +break; + } + + // Expect ':' + if (Tok.isNot(tok::colon)) { +Diag(Tok, diag::err_expected) << tok::colon; +SkipUntil({tok::comma, tok::semi, tok::r_paren, tok::annot_pragma_openmp_end}, + StopBeforeMatch); +continue; + } + ConsumeToken(); + + CXXScopeSpec SS; + Token Replacement; + ExprResult AllocatorExpr = + getLangOpts().CPlusPlus + ? ParseCXXIdExpression() + : tryParseCXXIdExpression(SS, /*isAddressOfOperand=*/false, Replacement); + + if (AllocatorExpr.isInvalid()) { +SkipUntil({tok::comma, tok::semi, tok::r_paren, tok::annot_pragma_openmp_end}, + StopBeforeMatch); +break; + } + + D.Allocator = AllocatorExpr.get(); + D.AllocatorTraits = AllocatorTraits.get(); + D.LParenLoc = TraitParens.getOpenLocation(); + D.RParenLoc = TraitParens.getCloseLocation(); + + // Separator handling(;) + if (Tok.is(tok::comma)) { +// In 5.2, comma is invalid +Diag(Tok.getLocation(), diag::err_omp_allocator_comma_separator) +<< FixItHint::CreateReplacement(Tok.getLocation(), ";"); +ConsumeAnyToken(); + } else if (Tok.is(tok::semi)) { +ConsumeAnyToken(); // valid separator + } + + continue; +} + +// Parse 'Allocator(expr)' for <5.2 CXXScopeSpec SS; Token Replacement; ExprResult Allocator = @@ -2988,6 +3051,14 @@ OMPClause *Parser::ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind) { D.AllocatorTraits = AllocatorTraits.get(); D.LParenLoc = T.getOpenLocati
[clang] [OpenMP 5.2] New syntax for 'uses_allocators' clause (PR #157025)
https://github.com/ravurvi20 created https://github.com/llvm/llvm-project/pull/157025 This patch updates the parsing changes to handle the new syntax of the `uses_allocators` clause as defined in OpenMP 5.2(Section 6.8). ``` // Case 1: Allocator without traits // < 5.2 → error // ≥ 5.2 → OK, empty traits set #pragma omp target teams uses_allocators(cgroup_alloc) // Case 2: Allocator with traits // Old syntax (< 5.2): #pragma omp target teams uses_allocators(cgroup_alloc(cgroup_traits)) // New syntax (≥ 5.2): #pragma omp target teams uses_allocators(traits(cgroup_traits) : cgroup_alloc) // Case 3: Multiple allocators // Old syntax (< 5.2), comma-separated: #pragma omp target teams uses_allocators(cgroup_alloc(cgroup_traits), aligned_alloc(aligned_traits)) // New syntax (≥ 5.2), semicolon-separated: #pragma omp target teams uses_allocators(traits(cgroup_traits) : cgroup_alloc; traits(aligned_traits) : aligned_alloc) ``` >From 1efc6c0d9418d5aa4299595b5008b4b580e556b1 Mon Sep 17 00:00:00 2001 From: urvi-rav Date: Thu, 4 Sep 2025 04:47:06 -0500 Subject: [PATCH 1/2] Implement new syntax for uses_allocators clause --- .../clang/Basic/DiagnosticParseKinds.td | 5 ++ clang/lib/Parse/ParseOpenMP.cpp | 71 +++ .../target_uses_allocators_messages.cpp | 25 +-- 3 files changed, 97 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index bc7a6e231d93c..44c3d07bf6027 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1497,6 +1497,11 @@ def err_omp_multiple_step_or_linear_modifier : Error< "multiple %select{'step size'|'linear modifier'}0 found in linear clause">; def err_omp_deprecate_old_syntax: Error< "old syntax '%0' on '%1' clause was deprecated, use new syntax '%2'">; +def warn_omp_deprecate_old_syntax: Warning< + "old syntax '%0' on '%1' clause was deprecated, use new syntax '%2'">, + InGroup; +def err_omp_allocator_comma_separator : + Error<"',' not allowed as separator in 'uses_allocators' clause, use ';' instead">; def warn_omp_future_directive_spelling: Warning< "directive spelling '%0' is introduced in a later OpenMP version">, InGroup; diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 5db2f2e2ccf86..92abc7084bed0 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2959,6 +2959,69 @@ OMPClause *Parser::ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind) { return nullptr; SmallVector Data; do { +// Parse 'traits(expr) : Allocator' for >=5.2 +if (getLangOpts().OpenMP >= 52 && +Tok.is(tok::identifier) && +Tok.getIdentifierInfo()->getName() == "traits") { + + SemaOpenMP::UsesAllocatorsData &D = Data.emplace_back(); + + ConsumeToken(); + + // Parse '(' ')' + BalancedDelimiterTracker TraitParens(*this, tok::l_paren, tok::annot_pragma_openmp_end); + TraitParens.consumeOpen(); + ExprResult AllocatorTraits = + getLangOpts().CPlusPlus ? ParseCXXIdExpression() : ParseExpression(); + TraitParens.consumeClose(); + + if (AllocatorTraits.isInvalid()) { +SkipUntil({tok::comma, tok::semi, tok::r_paren, tok::annot_pragma_openmp_end}, + StopBeforeMatch); +break; + } + + // Expect ':' + if (Tok.isNot(tok::colon)) { +Diag(Tok, diag::err_expected) << tok::colon; +SkipUntil({tok::comma, tok::semi, tok::r_paren, tok::annot_pragma_openmp_end}, + StopBeforeMatch); +continue; + } + ConsumeToken(); + + CXXScopeSpec SS; + Token Replacement; + ExprResult AllocatorExpr = + getLangOpts().CPlusPlus + ? ParseCXXIdExpression() + : tryParseCXXIdExpression(SS, /*isAddressOfOperand=*/false, Replacement); + + if (AllocatorExpr.isInvalid()) { +SkipUntil({tok::comma, tok::semi, tok::r_paren, tok::annot_pragma_openmp_end}, + StopBeforeMatch); +break; + } + + D.Allocator = AllocatorExpr.get(); + D.AllocatorTraits = AllocatorTraits.get(); + D.LParenLoc = TraitParens.getOpenLocation(); + D.RParenLoc = TraitParens.getCloseLocation(); + + // Separator handling(;) + if (Tok.is(tok::comma)) { +// In 5.2, comma is invalid +Diag(Tok.getLocation(), diag::err_omp_allocator_comma_separator) +<< FixItHint::CreateReplacement(Tok.getLocation(), ";"); +ConsumeAnyToken(); + } else if (Tok.is(tok::semi)) { +ConsumeAnyToken(); // valid separator + } + + continue; +} + +// Parse 'Allocator(expr)' for <5.2 CXXScopeSpec SS; Token Replacement; ExprResult Allocator = @@ -2988,6 +3051,14 @@ OMPClause *Parser::ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind) {
[clang] [OpenMP 5.2] New syntax for 'uses_allocators' clause (PR #157025)
https://github.com/ravurvi20 updated https://github.com/llvm/llvm-project/pull/157025 >From 1efc6c0d9418d5aa4299595b5008b4b580e556b1 Mon Sep 17 00:00:00 2001 From: urvi-rav Date: Thu, 4 Sep 2025 04:47:06 -0500 Subject: [PATCH 1/2] Implement new syntax for uses_allocators clause --- .../clang/Basic/DiagnosticParseKinds.td | 5 ++ clang/lib/Parse/ParseOpenMP.cpp | 71 +++ .../target_uses_allocators_messages.cpp | 25 +-- 3 files changed, 97 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td index bc7a6e231d93c..44c3d07bf6027 100644 --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1497,6 +1497,11 @@ def err_omp_multiple_step_or_linear_modifier : Error< "multiple %select{'step size'|'linear modifier'}0 found in linear clause">; def err_omp_deprecate_old_syntax: Error< "old syntax '%0' on '%1' clause was deprecated, use new syntax '%2'">; +def warn_omp_deprecate_old_syntax: Warning< + "old syntax '%0' on '%1' clause was deprecated, use new syntax '%2'">, + InGroup; +def err_omp_allocator_comma_separator : + Error<"',' not allowed as separator in 'uses_allocators' clause, use ';' instead">; def warn_omp_future_directive_spelling: Warning< "directive spelling '%0' is introduced in a later OpenMP version">, InGroup; diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index 5db2f2e2ccf86..92abc7084bed0 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -2959,6 +2959,69 @@ OMPClause *Parser::ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind) { return nullptr; SmallVector Data; do { +// Parse 'traits(expr) : Allocator' for >=5.2 +if (getLangOpts().OpenMP >= 52 && +Tok.is(tok::identifier) && +Tok.getIdentifierInfo()->getName() == "traits") { + + SemaOpenMP::UsesAllocatorsData &D = Data.emplace_back(); + + ConsumeToken(); + + // Parse '(' ')' + BalancedDelimiterTracker TraitParens(*this, tok::l_paren, tok::annot_pragma_openmp_end); + TraitParens.consumeOpen(); + ExprResult AllocatorTraits = + getLangOpts().CPlusPlus ? ParseCXXIdExpression() : ParseExpression(); + TraitParens.consumeClose(); + + if (AllocatorTraits.isInvalid()) { +SkipUntil({tok::comma, tok::semi, tok::r_paren, tok::annot_pragma_openmp_end}, + StopBeforeMatch); +break; + } + + // Expect ':' + if (Tok.isNot(tok::colon)) { +Diag(Tok, diag::err_expected) << tok::colon; +SkipUntil({tok::comma, tok::semi, tok::r_paren, tok::annot_pragma_openmp_end}, + StopBeforeMatch); +continue; + } + ConsumeToken(); + + CXXScopeSpec SS; + Token Replacement; + ExprResult AllocatorExpr = + getLangOpts().CPlusPlus + ? ParseCXXIdExpression() + : tryParseCXXIdExpression(SS, /*isAddressOfOperand=*/false, Replacement); + + if (AllocatorExpr.isInvalid()) { +SkipUntil({tok::comma, tok::semi, tok::r_paren, tok::annot_pragma_openmp_end}, + StopBeforeMatch); +break; + } + + D.Allocator = AllocatorExpr.get(); + D.AllocatorTraits = AllocatorTraits.get(); + D.LParenLoc = TraitParens.getOpenLocation(); + D.RParenLoc = TraitParens.getCloseLocation(); + + // Separator handling(;) + if (Tok.is(tok::comma)) { +// In 5.2, comma is invalid +Diag(Tok.getLocation(), diag::err_omp_allocator_comma_separator) +<< FixItHint::CreateReplacement(Tok.getLocation(), ";"); +ConsumeAnyToken(); + } else if (Tok.is(tok::semi)) { +ConsumeAnyToken(); // valid separator + } + + continue; +} + +// Parse 'Allocator(expr)' for <5.2 CXXScopeSpec SS; Token Replacement; ExprResult Allocator = @@ -2988,6 +3051,14 @@ OMPClause *Parser::ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind) { D.AllocatorTraits = AllocatorTraits.get(); D.LParenLoc = T.getOpenLocation(); D.RParenLoc = T.getCloseLocation(); + + // Deprecation diagnostic in >= 5.2 + if (getLangOpts().OpenMP >= 52) { +Diag(Loc, diag::warn_omp_deprecate_old_syntax) +<< "allocator(expr)" // %0: old form +<< "uses_allocators" // %1: clause name +<< "traits(expr): alloc"; // %2: suggested new form + } } if (Tok.isNot(tok::comma) && Tok.isNot(tok::r_paren)) Diag(Tok, diag::err_omp_expected_punc) << "uses_allocators" << 0; diff --git a/clang/test/OpenMP/target_uses_allocators_messages.cpp b/clang/test/OpenMP/target_uses_allocators_messages.cpp index b145c4d9501cf..da9392dc8fd71 100644 --- a/clang/test/OpenMP/target_uses_allocators_messages.cpp +++ b/clang/test/OpenMP/ta
[clang] a4f4d5e - [Driver][LoongArch] Enable linker relaxation by default for loongarch64 (#156315)
Author: ZhaoQi Date: 2025-09-05T14:14:21+08:00 New Revision: a4f4d5ed94cb2cf8082d02f0b39d08fd5ccb33ba URL: https://github.com/llvm/llvm-project/commit/a4f4d5ed94cb2cf8082d02f0b39d08fd5ccb33ba DIFF: https://github.com/llvm/llvm-project/commit/a4f4d5ed94cb2cf8082d02f0b39d08fd5ccb33ba.diff LOG: [Driver][LoongArch] Enable linker relaxation by default for loongarch64 (#156315) Added: Modified: clang/docs/ReleaseNotes.rst clang/lib/Driver/ToolChains/Arch/LoongArch.cpp clang/test/Driver/loongarch-features.c clang/test/Driver/loongarch-march.c clang/test/Driver/loongarch-relax-features.c flang/test/Driver/target-cpu-features.f90 Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index bec001bf8e353..780e8a31cae6d 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -391,6 +391,7 @@ Windows Support LoongArch Support ^ +- Enable linker relaxation by default for loongarch64. RISC-V Support ^^ diff --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp index ee7b0d10c24ba..156ea03045569 100644 --- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp +++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp @@ -134,22 +134,19 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D, (!Args.hasArgNoClaim(clang::driver::options::OPT_march_EQ))) Features.push_back("+lsx"); - // FIXME: Now we must use -mrelax to enable relax, maybe -mrelax will be set - // as default in the future. - if (const Arg *A = - Args.getLastArg(options::OPT_mrelax, options::OPT_mno_relax)) { -if (A->getOption().matches(options::OPT_mrelax)) { - Features.push_back("+relax"); - // -gsplit-dwarf -mrelax requires DW_AT_high_pc/DW_AT_ranges/... indexing - // into .debug_addr, which is currently not implemented. - Arg *A; - if (getDebugFissionKind(D, Args, A) != DwarfFissionKind::None) -D.Diag( -clang::diag::err_drv_loongarch_unsupported_with_linker_relaxation) -<< A->getAsString(Args); -} else { - Features.push_back("-relax"); -} + // -mrelax is default, unless -mno-relax is specified. + // FIXME: Only for loongarch64, loongarch32 has not been fully verified. + if (Args.hasFlag(options::OPT_mrelax, options::OPT_mno_relax, + Triple.isLoongArch64() ? true : false)) { +Features.push_back("+relax"); +// -gsplit-dwarf -mrelax requires DW_AT_high_pc/DW_AT_ranges/... indexing +// into .debug_addr, which is currently not implemented. +Arg *A; +if (getDebugFissionKind(D, Args, A) != DwarfFissionKind::None) + D.Diag(clang::diag::err_drv_loongarch_unsupported_with_linker_relaxation) + << A->getAsString(Args); + } else if (Args.getLastArg(options::OPT_mno_relax)) { +Features.push_back("-relax"); } std::string ArchName; diff --git a/clang/test/Driver/loongarch-features.c b/clang/test/Driver/loongarch-features.c index 90634bbcf0035..6f40ed71c2c0e 100644 --- a/clang/test/Driver/loongarch-features.c +++ b/clang/test/Driver/loongarch-features.c @@ -2,7 +2,7 @@ // RUN: %clang --target=loongarch64 -S -emit-llvm %s -o - | FileCheck %s --check-prefix=LA64 // LA32: "target-features"="+32bit" -// LA64: "target-features"="+64bit,+d,+f,+lsx,+ual" +// LA64: "target-features"="+64bit,+d,+f,+lsx,+relax,+ual" int foo(void) { return 3; diff --git a/clang/test/Driver/loongarch-march.c b/clang/test/Driver/loongarch-march.c index b52cdb330716f..87cdffd8d3a02 100644 --- a/clang/test/Driver/loongarch-march.c +++ b/clang/test/Driver/loongarch-march.c @@ -21,39 +21,39 @@ // CC1-LOONGARCH64: "-target-cpu" "loongarch64" // CC1-LOONGARCH64-NOT: "-target-feature" -// CC1-LOONGARCH64: "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "+d" "-target-feature" "+ual" +// CC1-LOONGARCH64: "-target-feature" "+relax" "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "+d" "-target-feature" "+ual" // CC1-LOONGARCH64-NOT: "-target-feature" // CC1-LOONGARCH64: "-target-abi" "lp64d" // CC1-LA464: "-target-cpu" "la464" // CC1-LA464-NOT: "-target-feature" -// CC1-LA464: "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "+d" "-target-feature" "+lsx" "-target-feature" "+lasx" "-target-feature" "+ual" +// CC1-LA464: "-target-feature" "+relax" "-target-feature" "+64bit" "-target-feature" "+f" "-target-feature" "+d" "-target-feature" "+lsx" "-target-feature" "+lasx" "-target-feature" "+ual" // CC1-LA464-NOT: "-target-feature" // CC1-LA464: "-target-abi" "lp64d" // CC1-LA64V1P0: "-target-cpu" "loongarch64" // CC1-LA64V1P0-NOT: "-target-feature" -// CC1-LA64V1P0: "-target-feature" "+64bit" "-target-feature" "+d" "-target-feature" "+lsx" "-target-feature" "+ual" +// CC1-LA64V1P0: "-target-featu
[clang] [Clang-Repl] Sinking RemoteJITUtils into Interpreter class(Refactoring) (PR #155140)
@@ -521,6 +618,23 @@ llvm::Error Interpreter::CreateExecutor() { return llvm::make_error("Operation failed. " "No code generator available", std::error_code()); +#ifndef _WIN32 vgvassilev wrote: We must check the target triple, not an ifdef because we can be cross compiling. https://github.com/llvm/llvm-project/pull/155140 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang-Repl] Sinking RemoteJITUtils into Interpreter class(Refactoring) (PR #155140)
@@ -115,31 +116,60 @@ class Interpreter { /// An optional compiler instance for CUDA offloading std::unique_ptr DeviceCI; +public: + struct OutOfProcessJITConfig { +/// Indicates whether out-of-process JIT execution is enabled. +bool IsOutOfProcess; +/// Path to the out-of-process JIT executor. +std::string OOPExecutor; +std::string OOPExecutorConnect; +/// Indicates whether to use shared memory for communication. +bool UseSharedMemory; vgvassilev wrote: It's probably clearer to initialize it here too. https://github.com/llvm/llvm-project/pull/155140 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix definition data not being propagated to all redecls (PR #157019)
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/157019 >From c086682815e47b4fb863bb475eb5b02156aa6172 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Mon, 1 Sep 2025 17:14:19 -0300 Subject: [PATCH] [clang] fix definition data not being propagated to all redecls This fixes the workaround added in 8a63989, so that when a fake definition data is corrected, all redeclarations are also updated to point to it. Since this regression was never released, there are no release notes. Fixes #154840 --- clang/lib/Serialization/ASTReaderDecl.cpp | 2 + clang/test/Modules/GH154840.cpp | 97 +++ 2 files changed, 99 insertions(+) create mode 100644 clang/test/Modules/GH154840.cpp diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 6b35b205079e5..44b8ba6f4c984 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -2107,6 +2107,8 @@ void ASTDeclMerger::MergeDefinitionData( auto *Def = DD.Definition; DD = std::move(MergeDD); DD.Definition = Def; +while ((Def = Def->getPreviousDecl())) + cast(Def)->DefinitionData = ⅅ return; } diff --git a/clang/test/Modules/GH154840.cpp b/clang/test/Modules/GH154840.cpp new file mode 100644 index 0..afeb39acb5484 --- /dev/null +++ b/clang/test/Modules/GH154840.cpp @@ -0,0 +1,97 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: split-file %s %t +// RUN: cd %t +// +// RUN: %clang_cc1 -fmodule-name=A -fno-cxx-modules -emit-module -fmodules -xc++ A.cppmap -o A.pcm +// RUN: %clang_cc1 -fmodule-name=B -fno-cxx-modules -emit-module -fmodules -xc++ B.cppmap -o B.pcm -fmodule-file=A.pcm +// RUN: %clang_cc1 -fmodule-name=C -fno-cxx-modules -emit-module -fmodules -xc++ C.cppmap -o C.pcm -fmodule-file=A.pcm +// RUN: %clang_cc1 -fmodule-name=D -fno-cxx-modules -emit-module -fmodules -xc++ D.cppmap -o D.pcm -fmodule-file=A.pcm +// RUN: %clang_cc1 -fmodule-name=E -fno-cxx-modules -emit-module -fmodules -xc++ E.cppmap -o E.pcm -fmodule-file=D.pcm -fmodule-file=B.pcm -fmodule-file=C.pcm +// RUN: %clang_cc1 -fno-cxx-modules -fmodules -fmodule-file=B.pcm -fmodule-file=E.pcm -emit-llvm -o /dev/null S.cpp + +//--- A.h +namespace std { + +template void zz(T); + +template struct vec { + struct w {}; + struct xx {}; + + vec(vec &) { init(); } + constexpr vec &operator=(const vec &); + template constexpr void pb(U); + constexpr void init(); + + w s; +}; + +template constexpr void vec::init() { + xx yy; + zz(yy); +} + +template constexpr vec &vec::operator=(const vec &) { + pb(s); + return *this; +} + +template template constexpr void vec::pb(U) { init(); } +} // namespace std + +//--- A.cppmap +module "A" { + header "A.h" +} + +//--- X.h +#pragma clang module import A + +namespace project { + class thing : std::vec {}; +} // namespace project + +//--- B.h +#include "X.h" + +//--- B.cppmap +module "B" { + header "B.h" +} + +//--- C.h +#include "X.h" + +//--- C.cppmap +module "C" { + header "C.h" +} + +//--- D.h +#include "X.h" + +//--- D.cppmap +module "D" { + header "D.h" +} + +//--- Y.h +#include "X.h" +struct other { + other() : data(data) {} + std::vec data; +}; + +//--- E.h +#include "Y.h" + +//--- E.cppmap +module "E" { + header "E.h" +} + +//--- S.cpp +#pragma clang module import A +#pragma clang module import E +void func(std::vec *a, std::vec *b) { *a = *b; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libunwind] [llvm] [wasm] Toolchain support for `wasm32-wali-linux-musl` target (PR #156087)
@@ -199,6 +199,7 @@ class Triple { SUSE, OpenEmbedded, Intel, +WALI, arjunr2 wrote: I think for consistency it makes sense to have it described as a vendor here as well. It should be a simple to update the target later if necessary. https://github.com/llvm/llvm-project/pull/156087 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libcxx] [lldb] [llvm] [mlir] [openmp] Fix typos and spelling errors across codebase (PR #156270)
https://github.com/HerrCai0907 approved this pull request. clang-tools-extra/clang-tidy part LGTM https://github.com/llvm/llvm-project/pull/156270 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [flang] [libcxx] [libcxxabi] [lld] [lldb] [llvm] [Inclusive Language] migrate "sanity" checks to "soundness" checks (PR #156995)
https://github.com/vanvoorden edited https://github.com/llvm/llvm-project/pull/156995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [compiler-rt] [flang] [libcxx] [libcxxabi] [lld] [lldb] [llvm] [Inclusive Language] migrate "sanity" checks to "soundness" checks (PR #156995)
https://github.com/vanvoorden edited https://github.com/llvm/llvm-project/pull/156995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits