[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)
https://github.com/chrisnc updated https://github.com/llvm/llvm-project/pull/91870 >From 16a00f4cf511e6dd96202d3013b41873f8dcba6b Mon Sep 17 00:00:00 2001 From: Chris Copeland Date: Sat, 11 May 2024 00:15:50 -0700 Subject: [PATCH] [ARM][clang] Fix warning for VFP function calls from interrupts. This warning has two issues: - The interrupt attribute doesn't only change how volatile registers are treated; it also causes the function to return using an exception return instruction. This warning allows calls from one function with the interrupt attribute to another, and the diagnostic text suggests that not having the attribute on the callee is the problem. Actually making such a call will lead to a double exception return, which is unpredictable according to the ARM architecture manual section B9.1.1, "Restrictions on exception return instructions". Even on machines where an exception return from user/system mode is tolerated, if the callee's interrupt type is anything other than a supervisor call or secure monitor call, it will also return to a different address than a normal function would. For example, returning from an "IRQ" handler will return to lr - 4, which will generally result in calling the same function again. - It is part of the -Wextra diagnostic group and can't be individually disabled when using -Wextra, which also means the diagnostic text of this specific warning appears in the documentation of -Wextra. This change addresses both issues. Rather than check that the callee has the interrupt attribute, check that it uses the soft-float feature, which will prevent use of VFP state. The warning is also given its own diagnostic group. Closes #34876. --- clang/docs/ReleaseNotes.rst | 11 +++ clang/include/clang/Basic/Attr.td | 7 +++ .../clang/Basic/DiagnosticSemaKinds.td| 7 --- clang/lib/Sema/SemaExpr.cpp | 19 ++- clang/test/Sema/arm-interrupt-attr.c | 14 +++--- 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 148ff05008552..bcf1fd723273c 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -409,6 +409,11 @@ Modified Compiler Flags evaluating to ``true`` and an empty body such as ``while(1);``) are considered infinite, even when the ``-ffinite-loop`` flag is set. +- Removed "arm interrupt calling convention" warning that was included in + ``-Wextra`` without its own flag. + +- Added ``-Warm-interrupt-vfp-clobber``, with its own warning group. + Removed Compiler Flags - @@ -569,6 +574,12 @@ Improvements to Clang's diagnostics - Clang no longer emits a "declared here" note for a builtin function that has no declaration in source. Fixes #GH93369. +- For the ARM target, Clang no longer suggests adding ``__attribute__((interrupt))`` to + functions that are called from interrupt handlers to prevent clobbering VFP registers + as part of ``-Wextra`` (#GH34876). Following this suggestion leads to unpredictable + behavior. Instead, a new warning, ``-Warm-interrupt-vfp-clobber`` will detect cases + where calling a function from an interrupt handler may clobber VFP state. + Improvements to Clang's time-trace -- diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index b70b0c8b836a5..197defb410194 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -3121,6 +3121,13 @@ def Target : InheritableAttr { } } +bool hasFeature(StringRef Feature) const { + StringRef Features = getFeaturesStr(); + SmallVector AttrFeatures; + Features.split(AttrFeatures, ","); + return Features.contains(Feature); +} + bool isDefaultVersion() const { return getFeaturesStr() == "default"; } }]; } diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 193eae3bc41d6..7ea47e2f3eee2 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -336,9 +336,10 @@ def warn_anyx86_excessive_regsave : Warning< " with attribute 'no_caller_saved_registers'" " or be compiled with '-mgeneral-regs-only'">, InGroup>; -def warn_arm_interrupt_calling_convention : Warning< - "call to function without interrupt attribute could clobber interruptee's VFP registers">, - InGroup; +def warn_arm_interrupt_vfp_clobber : Warning< + "calling a function from an interrupt handler could clobber the " + "interruptee's VFP registers if the callee also uses VFP">, + InGroup>; def warn_interrupt_attribute_invalid : Warning< "%select{MIPS|MSP430|RISC-V}0 'interrupt' attribute only applies to " "functions that have %select{no parameters|a 'void' return
[clang] [llvm] [Offload][CUDA] Allow CUDA kernels to use LLVM/Offload (PR #94549)
https://github.com/jdoerfert updated https://github.com/llvm/llvm-project/pull/94549 >From 094dbf3e01a62136db6be1afd6194f1d84ca8494 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Wed, 12 Jun 2024 02:14:32 -0700 Subject: [PATCH 1/3] [Offload][AMDGPU] Impose more restrictions for implicit kernel arguments COV3 is not supported anymore, thus we can just use ArgsSize we read from the kernel to determine how many argument bytes we need and if implicit kernel arguments are used. --- offload/plugins-nextgen/amdgpu/src/rtl.cpp | 27 -- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/offload/plugins-nextgen/amdgpu/src/rtl.cpp b/offload/plugins-nextgen/amdgpu/src/rtl.cpp index 663cfdc5fdf01..26bca4a3674bd 100644 --- a/offload/plugins-nextgen/amdgpu/src/rtl.cpp +++ b/offload/plugins-nextgen/amdgpu/src/rtl.cpp @@ -3267,9 +3267,10 @@ Error AMDGPUKernelTy::launchImpl(GenericDeviceTy , uint32_t NumThreads, uint64_t NumBlocks, KernelArgsTy , void *Args, AsyncInfoWrapperTy ) const { - const uint32_t KernelArgsSize = KernelArgs.NumArgs * sizeof(void *); + const uint32_t LaunchParamsSize = KernelArgs.NumArgs * sizeof(void *); - if (ArgsSize < KernelArgsSize) + if (ArgsSize != LaunchParamsSize && + ArgsSize != LaunchParamsSize + getImplicitArgsSize()) return Plugin::error("Mismatch of kernel arguments size"); AMDGPUPluginTy = @@ -3292,20 +3293,21 @@ Error AMDGPUKernelTy::launchImpl(GenericDeviceTy , if (auto Err = GenericDevice.getDeviceStackSize(StackSize)) return Err; - // Initialize implicit arguments. - utils::AMDGPUImplicitArgsTy *ImplArgs = - reinterpret_cast( - advanceVoidPtr(AllArgs, KernelArgsSize)); + utils::AMDGPUImplicitArgsTy *ImplArgs = nullptr; + if (ArgsSize == LaunchParamsSize + getImplicitArgsSize()) { +// Initialize implicit arguments. +ImplArgs = reinterpret_cast( +advanceVoidPtr(AllArgs, LaunchParamsSize)); - // Initialize the implicit arguments to zero. - std::memset(ImplArgs, 0, ImplicitArgsSize); +// Initialize the implicit arguments to zero. +std::memset(ImplArgs, 0, getImplicitArgsSize()); + } // Copy the explicit arguments. // TODO: We should expose the args memory manager alloc to the common part as // alternative to copying them twice. - if (KernelArgs.NumArgs) -std::memcpy(AllArgs, *static_cast(Args), -sizeof(void *) * KernelArgs.NumArgs); + if (LaunchParamsSize) +std::memcpy(AllArgs, *static_cast(Args), LaunchParamsSize); AMDGPUDeviceTy = static_cast(GenericDevice); @@ -3318,7 +3320,8 @@ Error AMDGPUKernelTy::launchImpl(GenericDeviceTy , Stream->setRPCServer(GenericDevice.getRPCServer()); // Only COV5 implicitargs needs to be set. COV4 implicitargs are not used. - if (getImplicitArgsSize() == sizeof(utils::AMDGPUImplicitArgsTy)) { + if (ImplArgs && + getImplicitArgsSize() == sizeof(utils::AMDGPUImplicitArgsTy)) { ImplArgs->BlockCountX = NumBlocks; ImplArgs->BlockCountY = 1; ImplArgs->BlockCountZ = 1; >From 9fa161e4a5448ecaa5a862c27a61e3fbd3da8651 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Tue, 11 Jun 2024 01:49:34 -0700 Subject: [PATCH 2/3] [Offload] Use flat array for cuLaunchKernel We already used a flat array of kernel launch parameters for the AMD GPU launch but now we also use this scheme for the NVIDIA GPU launch. The only remaining/required use of the indirection is the host plugin (due ot ffi). This allows to us simplify the use for non-OpenMP kernel launch. --- offload/include/Shared/APITypes.h | 10 +++ offload/plugins-nextgen/amdgpu/src/rtl.cpp| 27 + .../common/include/PluginInterface.h | 14 + .../common/src/PluginInterface.cpp| 28 +- offload/plugins-nextgen/cuda/src/rtl.cpp | 29 --- offload/plugins-nextgen/host/src/rtl.cpp | 5 ++-- 6 files changed, 69 insertions(+), 44 deletions(-) diff --git a/offload/include/Shared/APITypes.h b/offload/include/Shared/APITypes.h index a84b685eeedce..5b22bbaac144f 100644 --- a/offload/include/Shared/APITypes.h +++ b/offload/include/Shared/APITypes.h @@ -116,6 +116,16 @@ static_assert(sizeof(KernelArgsTy) == (8 * sizeof(int32_t) + 3 * sizeof(int64_t) + 4 * sizeof(void **) + 2 * sizeof(int64_t *)), "Invalid struct size"); + +/// Flat array of kernel launch parameters and their total size. +struct KernelLaunchParamsTy { + /// Size of the Data array. + size_t Size = 0; + /// Flat array of kernel parameters. + void *Data = nullptr; + /// Ptrs to the Data entries. Only strictly required for the host plugin. + void **Ptrs = nullptr; +}; } #endif // OMPTARGET_SHARED_API_TYPES_H diff --git a/offload/plugins-nextgen/amdgpu/src/rtl.cpp
[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)
chrisnc wrote: I've rebased, updated the warning text and release notes, and created https://github.com/llvm/llvm-project/issues/95359 for the future improvement to warn about calling interrupt handlers. https://github.com/llvm/llvm-project/pull/91870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)
https://github.com/chrisnc updated https://github.com/llvm/llvm-project/pull/91870 >From a67b6703d384eb63b947e75c13d6421a5f961f6c Mon Sep 17 00:00:00 2001 From: Chris Copeland Date: Sat, 11 May 2024 00:15:50 -0700 Subject: [PATCH] [ARM][clang] Fix warning for VFP function calls from interrupts. This warning has two issues: - The interrupt attribute doesn't only change how volatile registers are treated; it also causes the function to return using an exception return instruction. This warning allows calls from one function with the interrupt attribute to another, and the diagnostic text suggests that not having the attribute on the callee is the problem. Actually making such a call will lead to a double exception return, which is unpredictable according to the ARM architecture manual section B9.1.1, "Restrictions on exception return instructions". Even on machines where an exception return from user/system mode is tolerated, if the callee's interrupt type is anything other than a supervisor call or secure monitor call, it will also return to a different address than a normal function would. For example, returning from an "IRQ" handler will return to lr - 4, which will generally result in calling the same function again. - It is part of the -Wextra diagnostic group and can't be individually disabled when using -Wextra, which also means the diagnostic text of this specific warning appears in the documentation of -Wextra. This change addresses both issues. Rather than check that the callee has the interrupt attribute, check that it uses the soft-float feature, which will prevent use of VFP state. The warning is also given its own diagnostic group. Closes #34876. --- clang/docs/ReleaseNotes.rst | 11 +++ clang/include/clang/Basic/Attr.td | 7 +++ .../clang/Basic/DiagnosticSemaKinds.td| 7 --- clang/lib/Sema/SemaExpr.cpp | 19 ++- clang/test/Sema/arm-interrupt-attr.c | 14 +++--- 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 148ff05008552..bcf1fd723273c 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -409,6 +409,11 @@ Modified Compiler Flags evaluating to ``true`` and an empty body such as ``while(1);``) are considered infinite, even when the ``-ffinite-loop`` flag is set. +- Removed "arm interrupt calling convention" warning that was included in + ``-Wextra`` without its own flag. + +- Added ``-Warm-interrupt-vfp-clobber``, with its own warning group. + Removed Compiler Flags - @@ -569,6 +574,12 @@ Improvements to Clang's diagnostics - Clang no longer emits a "declared here" note for a builtin function that has no declaration in source. Fixes #GH93369. +- For the ARM target, Clang no longer suggests adding ``__attribute__((interrupt))`` to + functions that are called from interrupt handlers to prevent clobbering VFP registers + as part of ``-Wextra`` (#GH34876). Following this suggestion leads to unpredictable + behavior. Instead, a new warning, ``-Warm-interrupt-vfp-clobber`` will detect cases + where calling a function from an interrupt handler may clobber VFP state. + Improvements to Clang's time-trace -- diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index b70b0c8b836a5..197defb410194 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -3121,6 +3121,13 @@ def Target : InheritableAttr { } } +bool hasFeature(StringRef Feature) const { + StringRef Features = getFeaturesStr(); + SmallVector AttrFeatures; + Features.split(AttrFeatures, ","); + return Features.contains(Feature); +} + bool isDefaultVersion() const { return getFeaturesStr() == "default"; } }]; } diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 193eae3bc41d6..7ea47e2f3eee2 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -336,9 +336,10 @@ def warn_anyx86_excessive_regsave : Warning< " with attribute 'no_caller_saved_registers'" " or be compiled with '-mgeneral-regs-only'">, InGroup>; -def warn_arm_interrupt_calling_convention : Warning< - "call to function without interrupt attribute could clobber interruptee's VFP registers">, - InGroup; +def warn_arm_interrupt_vfp_clobber : Warning< + "calling a function from an interrupt handler could clobber the " + "interruptee's VFP registers if the callee also uses VFP">, + InGroup>; def warn_interrupt_attribute_invalid : Warning< "%select{MIPS|MSP430|RISC-V}0 'interrupt' attribute only applies to " "functions that have %select{no parameters|a 'void' return
[clang-tools-extra] [clang-doc] Add basic e2e test (PR #93928)
PeterChou1 wrote: I think this finally works i think we could also shelve https://github.com/llvm/llvm-project/pull/94717 since I wrote that pr to get around the fact that we can't copy assets https://github.com/llvm/llvm-project/pull/93928 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)
owenca wrote: @Erich-Reitz you were on the right track. See #95354. https://github.com/llvm/llvm-project/pull/94776 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Don't over-indent comment below unbraced body (PR #95354)
llvmbot wrote: @llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) Changes Fixes #45002. --- Full diff: https://github.com/llvm/llvm-project/pull/95354.diff 3 Files Affected: - (modified) clang/lib/Format/UnwrappedLineParser.cpp (+5) - (modified) clang/lib/Format/UnwrappedLineParser.h (+3) - (modified) clang/unittests/Format/FormatTestComments.cpp (+30) ``diff diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 08387d2e08ee0..899e68eadf70e 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -112,6 +112,7 @@ class ScopedLineState { Parser.Line->PPLevel = PreBlockLine->PPLevel; Parser.Line->InPPDirective = PreBlockLine->InPPDirective; Parser.Line->InMacroBody = PreBlockLine->InMacroBody; +Parser.Line->UnbracedBodyLevel = PreBlockLine->UnbracedBodyLevel; } ~ScopedLineState() { @@ -2708,7 +2709,9 @@ void UnwrappedLineParser::parseUnbracedBody(bool CheckEOF) { addUnwrappedLine(); ++Line->Level; + ++Line->UnbracedBodyLevel; parseStructuralElement(); + --Line->UnbracedBodyLevel; if (Tok) { assert(!Line->InPPDirective); @@ -4836,6 +4839,8 @@ void UnwrappedLineParser::readToken(int LevelDifference) { PPBranchLevel > 0) { Line->Level += PPBranchLevel; } + assert(Line->Level >= Line->UnbracedBodyLevel); + Line->Level -= Line->UnbracedBodyLevel; flushComments(isOnNewLine(*FormatTok)); parsePPDirective(); PreviousWasComment = FormatTok->is(tok::comment); diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h index d7963a4211bb9..d5eeb3d57149c 100644 --- a/clang/lib/Format/UnwrappedLineParser.h +++ b/clang/lib/Format/UnwrappedLineParser.h @@ -49,6 +49,9 @@ struct UnwrappedLine { /// Whether it is part of a macro body. bool InMacroBody = false; + /// Nesting level of unbraced body of a control statement. + unsigned UnbracedBodyLevel = 0; + bool MustBeDeclaration = false; /// Whether the parser has seen \c decltype(auto) in this line. diff --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp index d2baace6a7d80..3e75707a9faec 100644 --- a/clang/unittests/Format/FormatTestComments.cpp +++ b/clang/unittests/Format/FormatTestComments.cpp @@ -1087,6 +1087,36 @@ TEST_F(FormatTestComments, KeepsLevelOfCommentBeforePPDirective) { Style); } +TEST_F(FormatTestComments, CommentsBetweenUnbracedBodyAndPPDirective) { + verifyFormat("{\n" + " if (a)\n" + "f(); // comment\n" + "#define A\n" + "}"); + + verifyFormat("{\n" + " while (a)\n" + "f();\n" + "// comment\n" + "#define A\n" + "}"); + + verifyNoChange("{\n" + " if (a)\n" + "f();\n" + " // comment\n" + "#define A\n" + "}"); + + verifyNoChange("{\n" + " while (a)\n" + "if (b)\n" + " f();\n" + " // comment\n" + "#define A\n" + "}"); +} + TEST_F(FormatTestComments, SplitsLongLinesInComments) { // FIXME: Do we need to fix up the " */" at the end? // It doesn't look like any of our current logic triggers this. `` https://github.com/llvm/llvm-project/pull/95354 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Don't over-indent comment below unbraced body (PR #95354)
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/95354 Fixes #45002. >From 02f1731d57d40e51605f667c8a0b1223b159e645 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Wed, 12 Jun 2024 22:04:17 -0700 Subject: [PATCH] [clang-format] Don't overindent comment below unbraced body Fixes #45002. --- clang/lib/Format/UnwrappedLineParser.cpp | 5 clang/lib/Format/UnwrappedLineParser.h| 3 ++ clang/unittests/Format/FormatTestComments.cpp | 30 +++ 3 files changed, 38 insertions(+) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 08387d2e08ee0..899e68eadf70e 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -112,6 +112,7 @@ class ScopedLineState { Parser.Line->PPLevel = PreBlockLine->PPLevel; Parser.Line->InPPDirective = PreBlockLine->InPPDirective; Parser.Line->InMacroBody = PreBlockLine->InMacroBody; +Parser.Line->UnbracedBodyLevel = PreBlockLine->UnbracedBodyLevel; } ~ScopedLineState() { @@ -2708,7 +2709,9 @@ void UnwrappedLineParser::parseUnbracedBody(bool CheckEOF) { addUnwrappedLine(); ++Line->Level; + ++Line->UnbracedBodyLevel; parseStructuralElement(); + --Line->UnbracedBodyLevel; if (Tok) { assert(!Line->InPPDirective); @@ -4836,6 +4839,8 @@ void UnwrappedLineParser::readToken(int LevelDifference) { PPBranchLevel > 0) { Line->Level += PPBranchLevel; } + assert(Line->Level >= Line->UnbracedBodyLevel); + Line->Level -= Line->UnbracedBodyLevel; flushComments(isOnNewLine(*FormatTok)); parsePPDirective(); PreviousWasComment = FormatTok->is(tok::comment); diff --git a/clang/lib/Format/UnwrappedLineParser.h b/clang/lib/Format/UnwrappedLineParser.h index d7963a4211bb9..d5eeb3d57149c 100644 --- a/clang/lib/Format/UnwrappedLineParser.h +++ b/clang/lib/Format/UnwrappedLineParser.h @@ -49,6 +49,9 @@ struct UnwrappedLine { /// Whether it is part of a macro body. bool InMacroBody = false; + /// Nesting level of unbraced body of a control statement. + unsigned UnbracedBodyLevel = 0; + bool MustBeDeclaration = false; /// Whether the parser has seen \c decltype(auto) in this line. diff --git a/clang/unittests/Format/FormatTestComments.cpp b/clang/unittests/Format/FormatTestComments.cpp index d2baace6a7d80..3e75707a9faec 100644 --- a/clang/unittests/Format/FormatTestComments.cpp +++ b/clang/unittests/Format/FormatTestComments.cpp @@ -1087,6 +1087,36 @@ TEST_F(FormatTestComments, KeepsLevelOfCommentBeforePPDirective) { Style); } +TEST_F(FormatTestComments, CommentsBetweenUnbracedBodyAndPPDirective) { + verifyFormat("{\n" + " if (a)\n" + "f(); // comment\n" + "#define A\n" + "}"); + + verifyFormat("{\n" + " while (a)\n" + "f();\n" + "// comment\n" + "#define A\n" + "}"); + + verifyNoChange("{\n" + " if (a)\n" + "f();\n" + " // comment\n" + "#define A\n" + "}"); + + verifyNoChange("{\n" + " while (a)\n" + "if (b)\n" + " f();\n" + " // comment\n" + "#define A\n" + "}"); +} + TEST_F(FormatTestComments, SplitsLongLinesInComments) { // FIXME: Do we need to fix up the " */" at the end? // It doesn't look like any of our current logic triggers this. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] added regcall struct by reg support (PR #95257)
mahesh-attarde wrote: Regcall ABI is described on https://cdrdv2-public.intel.com/679047/Intel-ABI-Vector-Function-v0.9.8.pdf Page No. 18 > ![image](https://github.com/llvm/llvm-project/assets/145317060/5ff49ca5-0b4c-4c8f-9f00-5de65e4eaeda) https://github.com/llvm/llvm-project/pull/95257 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (PR #94559)
davemgreen wrote: If you remove tan from isTriviallyVectorizable it should prevent vectorization in the short term. It might be better to default FTAN to expand in https://github.com/llvm/llvm-project/blob/64c9a1e1266ec7bc4c4896b2df116fa12dbacf15/llvm/lib/CodeGen/TargetLoweringBase.cpp#L960, which seems to only be done for f32/f64/f128 at the moment. https://github.com/llvm/llvm-project/pull/94559 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] qualifier should be transformed (PR #94725)
https://github.com/mizvekov requested changes to this pull request. Needs changes as discussed. https://github.com/llvm/llvm-project/pull/94725 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (PR #94559)
efriedma-quic wrote: Can we change the target-independent bits of the tan() implementation in the backend so it doesn't require each target to explicitly request that tan() needs to be expanded? It should be possible to adjust the code in TargetLoweringBase.cpp a bit so FTAN defaults to being expanded for all types. https://github.com/llvm/llvm-project/pull/94559 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 64c9a1e - [clang][Interp] Also revisit references to const types
Author: Timm Bäder Date: 2024-06-13T06:55:07+02:00 New Revision: 64c9a1e1266ec7bc4c4896b2df116fa12dbacf15 URL: https://github.com/llvm/llvm-project/commit/64c9a1e1266ec7bc4c4896b2df116fa12dbacf15 DIFF: https://github.com/llvm/llvm-project/commit/64c9a1e1266ec7bc4c4896b2df116fa12dbacf15.diff LOG: [clang][Interp] Also revisit references to const types Neither isConstant() not isConstQualified() return true for these. Added: Modified: clang/lib/AST/Interp/ByteCodeExprGen.cpp clang/test/AST/Interp/cxx11.cpp Removed: diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 81a5296012b9a..77a1c64d40189 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -3948,9 +3948,17 @@ bool ByteCodeExprGen::visitDeclRef(const ValueDecl *D, const Expr *E) { // we haven't seen yet. if (Ctx.getLangOpts().CPlusPlus) { if (const auto *VD = dyn_cast(D)) { + const auto typeShouldBeVisited = [&](QualType T) -> bool { +if (T.isConstant(Ctx.getASTContext())) + return true; +if (const auto *RT = T->getAs()) + return RT->getPointeeType().isConstQualified(); +return false; + }; + // Visit local const variables like normal. if ((VD->isLocalVarDecl() || VD->isStaticDataMember()) && - VD->getType().isConstant(Ctx.getASTContext())) { + typeShouldBeVisited(VD->getType())) { if (!this->visitVarDecl(VD)) return false; // Retry. diff --git a/clang/test/AST/Interp/cxx11.cpp b/clang/test/AST/Interp/cxx11.cpp index f06a5dd173cba..82b2727bbadbb 100644 --- a/clang/test/AST/Interp/cxx11.cpp +++ b/clang/test/AST/Interp/cxx11.cpp @@ -46,3 +46,19 @@ constexpr int preInc(int x) { // both-error {{never produces a constant expressi constexpr int postInc(int x) { // both-error {{never produces a constant expression}} return x++; // both-note {{subexpression}} } + + +namespace ReferenceToConst { + template struct S; // both-note 1{{here}} + struct LiteralType { +constexpr LiteralType(int n) : n(n) {} +int n; + }; + template struct T { +T() { + static const int ki = 42; + const int = ki; + typename S::T check5; // both-error {{undefined template}} +} + }; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)
chrisnc wrote: Thank you for the review! > * Calling a function marked interrupt from a function marked interrupt is > still UB isn't it? Should there be another warning to cover that scenario as > well? Correct. I can create a separate issue to describe such a warning. > * I see that gcc has a warning in `-Wattributes` for this, you should raise a > bug there equivalent to the one llvm has, perhaps there even is one already. It does, but `gcc`'s `-Wattributes` doesn't suffer from any of the issues being addressed here: it's already a separate flag, it cannot be silenced by putting `__attribute__((interrupt))` on the callee, and its warning text describes compiling with `-mgeneral-regs-only` to avoid the issue, though this only works when passed on the command line, not with `__attribute__((target("general-regs-only")))`. It seems that LLVM does not have this target feature for 32-bit Arm, so I opted for `soft-float` as the escape hatch, which should achieve the same result, and check for it in function attributes. It is not checked transitively though, so this PR will not catch cases where an interrupt calls a soft-float function that then calls a function that uses VFP. The latter call is otherwise allowed though. IMO this is still a lot better than not having the escape hatch, but I'm open to suggestions. https://github.com/llvm/llvm-project/pull/91870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Sema] qualifier should be transformed (PR #94725)
mizvekov wrote: I think this is missing one detail: We now have the same qualifier in two places: The elaborated type node attached to the TST, and in the name of the TST itself. While this is not ideal situation, I think it makes sense to just drop the TemplateName qualifier in the transform for now, so we don't keep transforming it twice, until we make the situation consistent again. Right now the NNS in the TST name is not printed, its only purpose there is to carry the template keyword information, which shouldn't be affected here. The fact that this change somehow affects program semantics is still unexpected and unexplained. As I said on the other PR, after we have built a TST, per current AST design, we shouldn't need the nested name specifier anymore beyond type sugar. So either we built this TST too early, as in it should have stayed as a DependentTemplateSpecializationType longer or some such, or there is something that needs to be rectified in the AST design, but I can't imagine what. If I had to take a guess, there is something wrong in the dependency computation for the NNS. Have you checked that? https://github.com/llvm/llvm-project/pull/94725 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)
@@ -384,6 +384,10 @@ Modified Compiler Flags evaluating to ``true`` and an empty body such as ``while(1);``) are considered infinite, even when the ``-ffinite-loop`` flag is set. +- Removed "arm interrupt calling convention" warning that was included in chrisnc wrote: "Made into" implies that it's the more or less the same warning, but I'm trying to convey that the existing warning was removed because it's unsound, and the name is part of its confusedness. I will revisit this. https://github.com/llvm/llvm-project/pull/91870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)
@@ -336,9 +336,10 @@ def warn_anyx86_excessive_regsave : Warning< " with attribute 'no_caller_saved_registers'" " or be compiled with '-mgeneral-regs-only'">, InGroup>; -def warn_arm_interrupt_calling_convention : Warning< - "call to function without interrupt attribute could clobber interruptee's VFP registers">, - InGroup; +def warn_arm_interrupt_vfp_clobber : Warning< + "calling a VFP-enabled function from an interrupt could clobber the " chrisnc wrote: It's a phrasal adjective which would normally be hyphenated, but I will consider how to rephrase so it's not needed. https://github.com/llvm/llvm-project/pull/91870 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Check whether EvaluatedStmt::Value is valid in VarDecl::hasInit (PR #94515)
@@ -2402,10 +2405,9 @@ Expr *VarDecl::getInit() { auto *Eval = getEvaluatedStmt(); - return cast_if_present( - Eval->Value.isOffset() - ? Eval->Value.get(getASTContext().getExternalSource()) - : Eval->Value.get(nullptr)); + return cast(Eval->Value.isOffset() +? Eval->Value.get(getASTContext().getExternalSource()) +: Eval->Value.get(nullptr)); mizvekov wrote: Small nit: It seems this could move the conditional into the argument for `Eval->Value.get`. https://github.com/llvm/llvm-project/pull/94515 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Check whether EvaluatedStmt::Value is valid in VarDecl::hasInit (PR #94515)
https://github.com/mizvekov approved this pull request. This is much better, thanks! LGTM https://github.com/llvm/llvm-project/pull/94515 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Check whether EvaluatedStmt::Value is valid in VarDecl::hasInit (PR #94515)
https://github.com/mizvekov edited https://github.com/llvm/llvm-project/pull/94515 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
https://github.com/shiltian edited https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Don't print extra space when dumping template names (PR #95213)
https://github.com/mizvekov approved this pull request. I think what I tried to do here is generally consistent: The convention on the Text node dumper is to add a space at the beginning of the field you want to append. I think the true issue here is the label: It breaks convention by adding a space after the colon. I think it would be better to fix that, but I don't know the impact. Since right now this field is only added after the label, this makes little practical difference, so I leave it up to you, either way is fine. Thanks for the fix! https://github.com/llvm/llvm-project/pull/95213 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
@@ -0,0 +1,95 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu verde -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu tonga -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +// CHECK-LABEL: @test_amdgcn_make_buffer_rsrc_p0( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr [[P:%.*]], i16 [[STRIDE:%.*]], i32 [[NUM:%.*]], i32 [[FLAGS:%.*]]) +// CHECK-NEXT:ret ptr addrspace(8) [[TMP0]] +// +__buffer_rsrc_t test_amdgcn_make_buffer_rsrc_p0(void *p, short stride, int num, int flags) { + return __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); shiltian wrote: For example, we have the following code: ``` void test_amdgcn_buffer_rsrc_t_assignment(void *p, short stride, int num, int flags, char c) { __buffer_rsrc_t rsrc = __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); bar(); __builtin_amdgcn_raw_ptr_buffer_store_i8(c, rsrc, 0, 0, 0); } ``` The generated IR would be: ``` define dso_local void @test_amdgcn_buffer_rsrc_t_assignment(ptr nocapture noundef writeonly %p, i16 noundef signext %stride, i32 noundef %num, i32 noundef %flags, i8 noundef signext %c) local_unnamed_addr { entry: %0 = tail call ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr %p, i16 %stride, i32 %num, i32 %flags) tail call void @bar() tail call void @llvm.amdgcn.raw.ptr.buffer.store.i8(i8 %c, ptr addrspace(8) %0, i32 0, i32 0, i32 0) ret void } declare ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr readnone, i16, i32, i32) #1 declare void @bar() local_unnamed_addr #2 ``` However, I just checked the potential use case of this, such as https://github.com/ROCm/composable_kernel/blob/acda4c5a3c34c13b71475fdd963e61182bba8a76/include/ck_tile/core/arch/amd_buffer_addressing.hpp#L71, we will need this type to be able to be passed around, so a sizeless type doesn't work. To move forward, I think we still need to make it a 128-bit fat pointer. I'm not sure yet if we want to make it an `i128` or `4xi32`, or a struct type because we definitely need to prevent the case like `__buffer_rsrc_t rsrc = some_i128_val;` or `__buffer_rsrc_t rsrc = some_4xi32_val;`. At clang codegen level, it is still taken as AS8 pointer. WDYT? @yxsamliu @arsenm @krzysz00 https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Interp] Implement dynamic memory allocation handling (PR #70306)
tbaederr wrote: Ping https://github.com/llvm/llvm-project/pull/70306 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)
mizvekov wrote: FYI https://github.com/itanium-cxx-abi/cxx-abi/issues/184 is the tracking issue for the mangling rules we need here. We will probably end up with something quite different than what I coded here so far. https://github.com/llvm/llvm-project/pull/94981 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)
@@ -9219,7 +9222,8 @@ class Sema final : public SemaBase { /// \returns true if an error occurred, false otherwise. bool CheckTemplateArgumentList( TemplateDecl *Template, SourceLocation TemplateLoc, - TemplateArgumentListInfo , bool PartialTemplateArgs, + TemplateArgumentListInfo , mizvekov wrote: I am not seeing a worthwhile tradeoff. Just the function signature is hugely complicated, and would need to be duplicated. The implementation would be mostly the same, with a small block which would be omitted in one of the implementations. What did you have in mind? https://github.com/llvm/llvm-project/pull/94981 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)
@@ -9434,6 +9505,32 @@ ASTContext::getSubstTemplateTemplateParmPack(const TemplateArgument , return TemplateName(Subst); } +/// Retrieve the template name that represents a template name +/// deduced from a specialization. +TemplateName +ASTContext::getDeducedTemplateName(TemplateName Underlying, + DefaultArguments DefaultArgs) const { + if (!DefaultArgs) +return Underlying; + + auto = const_cast(*this); mizvekov wrote: Actually in this case the relevant hash tables were already declared mutable, but there were a couple of profile functions not marked const. Fixed. https://github.com/llvm/llvm-project/pull/94981 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-doc][cmake] Copy assets to build directory (PR #95187)
PeterChou1 wrote: > @petrhosek I'm pretty sure there's a better way to spell this, but I think we > need something similar to properly test clang-doc w/o an install step. > > cc: @PeterChou1 It looks like copy_directory_if_different is not available on windows https://github.com/llvm/llvm-project/pull/95187 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
@@ -0,0 +1,95 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu verde -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu tonga -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +// CHECK-LABEL: @test_amdgcn_make_buffer_rsrc_p0( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr [[P:%.*]], i16 [[STRIDE:%.*]], i32 [[NUM:%.*]], i32 [[FLAGS:%.*]]) +// CHECK-NEXT:ret ptr addrspace(8) [[TMP0]] +// +__buffer_rsrc_t test_amdgcn_make_buffer_rsrc_p0(void *p, short stride, int num, int flags) { + return __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); yxsamliu wrote: > No, we don't allow to have that. Per the discussion with @arsenm , > `__buffer_rsrc_t` is a sizeless target opaque type. It can't be used in > anywhere that requires its size to be known. If you cannot assign it to a variable, how are you going to use it? Can you provide some pseudo code about how to use the returned value of `__builtin_amdgcn_make_buffer_rsrc` ? https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/94981 >From f05e8590c7fae599d0658829949fa907942e83f2 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Mon, 20 May 2024 01:15:03 -0300 Subject: [PATCH] [clang] Implement CWG2398 provisional TTP matching to class templates This extends default argument deduction to cover class templates as well, and also applies outside of partial ordering, adding to the provisional wording introduced in https://github.com/llvm/llvm-project/pull/89807. This solves some ambuguity introduced in P0522 regarding how template template parameters are partially ordered, and should reduce the negative impact of enabling `-frelaxed-template-template-args` by default. Given the following example: ```C++ template struct A; template struct B; template class TT1, class T5> struct B>; // #1 template struct B>; // #2 template struct B>; ``` Prior to P0522, `#2` was picked. Afterwards, this became ambiguous. This patch restores the pre-P0522 behavior, `#2` is picked again. As the consequences are not restricted to partial ordering, the following code becomes valid: ```C++ template struct A {}; A v; template class TT> void f(TT); // OK: TT picks 'float' as the default argument for the second parameter. void g() { f(v); } ``` Also, since 'f' deduced from `A` is different from 'f' deduced from `A`, this implements an additional mangling rule. --- Since this changes provisional implementation of CWG2398 which has not been released yet, and already contains a changelog entry, we don't provide a changelog entry here. --- clang-tools-extra/clangd/DumpAST.cpp | 1 + .../clangd/SemanticHighlighting.cpp | 1 + clang/include/clang/AST/ASTContext.h | 11 +- clang/include/clang/AST/ASTImporter.h | 5 + clang/include/clang/AST/DependenceFlags.h | 5 + clang/include/clang/AST/PropertiesBase.td | 17 ++ clang/include/clang/AST/TemplateName.h| 63 ++- clang/include/clang/Sema/Sema.h | 10 +- clang/lib/AST/ASTContext.cpp | 153 +--- clang/lib/AST/ASTDiagnostic.cpp | 45 +++-- clang/lib/AST/ASTImporter.cpp | 15 ++ clang/lib/AST/ASTStructuralEquivalence.cpp| 3 + clang/lib/AST/Decl.cpp| 3 +- clang/lib/AST/ItaniumMangle.cpp | 20 ++- clang/lib/AST/ODRHash.cpp | 1 + clang/lib/AST/TemplateName.cpp| 163 ++ clang/lib/AST/TextNodeDumper.cpp | 12 ++ clang/lib/AST/Type.cpp| 3 +- clang/lib/AST/TypePrinter.cpp | 3 +- clang/lib/Sema/SemaDeclCXX.cpp| 9 +- clang/lib/Sema/SemaTemplate.cpp | 63 +-- clang/lib/Sema/SemaTemplateDeduction.cpp | 158 + .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 24 +-- .../CXX/temp/temp.decls/temp.alias/p2.cpp | 5 +- clang/test/CodeGenCXX/mangle-cwg2398.cpp | 11 ++ clang/test/SemaTemplate/cwg2398.cpp | 62 +-- clang/tools/libclang/CIndex.cpp | 3 + clang/unittests/AST/ASTImporterTest.cpp | 17 ++ 28 files changed, 629 insertions(+), 257 deletions(-) create mode 100644 clang/test/CodeGenCXX/mangle-cwg2398.cpp diff --git a/clang-tools-extra/clangd/DumpAST.cpp b/clang-tools-extra/clangd/DumpAST.cpp index 9a525efb938e8..e605f82e91fe4 100644 --- a/clang-tools-extra/clangd/DumpAST.cpp +++ b/clang-tools-extra/clangd/DumpAST.cpp @@ -187,6 +187,7 @@ class DumpVisitor : public RecursiveASTVisitor { TEMPLATE_KIND(SubstTemplateTemplateParm); TEMPLATE_KIND(SubstTemplateTemplateParmPack); TEMPLATE_KIND(UsingTemplate); + TEMPLATE_KIND(DeducedTemplate); #undef TEMPLATE_KIND } llvm_unreachable("Unhandled NameKind enum"); diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp index a366f1331c2d3..e6d16af2495fe 100644 --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp +++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -1120,6 +1120,7 @@ class CollectExtraHighlightings case TemplateName::SubstTemplateTemplateParm: case TemplateName::SubstTemplateTemplateParmPack: case TemplateName::UsingTemplate: +case TemplateName::DeducedTemplate: // Names that could be resolved to a TemplateDecl are handled elsewhere. break; } diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index f1f20fca477a4..c9376dc02fcfc 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -262,6 +262,8 @@ class ASTContext : public RefCountedBase { mutable llvm::ContextualFoldingSet SubstTemplateTemplateParmPacks; + mutable llvm::ContextualFoldingSet + DeducedTemplates; mutable llvm::ContextualFoldingSet
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
yxsamliu wrote: > > I am wondering whether prefix the builtin type with `__amdgcn_` would be > > better since I envision risk of conflicting with reserved names of other > > compilers or standard libraries. > > In the patch where the type was introduced we had a brief back-and-forth. I > checked the reference type WASM introduced and they don't have prefix. I > don't think in the future we'd have a cross-platform/-compiler type called > `__buffer_rsrc_t`, and if it happens, it is not supposed to have `__` prefix. > However, I'm by no means a language expert, so I'm fine if we really want to > add that. we are introducing `__buffer_rsrc_t` in global namespace, which is seen in any other namespace. Imagine some libstdc++ or libc++ header files use the same name in some namespaces and a HIP program includes these header files, there may be compilation error. A search of `__buffer` shows libstdc++ and libc++ do use names starting with `__buffer`: https://github.com/search?q=repo%3Agcc-mirror%2Fgcc%20path%3A%2F%5Elibstdc%5C%2B%5C%2B-v3%5C%2Finclude%5C%2F%2F%20__buffer=code https://github.com/search?q=repo%3Allvm%2Fllvm-project+path%3A%2F%5Elibcxx%5C%2F%2F+__buffer=code=1 I understand the chance of conflict is low. It may be like the chance of hitting by a meteor. However, if we prefix with `__amdgcn_`, there is no such risk. And we have the benefit to clearly indicate it is a amdgcn target-specific type. https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Serialization] Use 32 bit aligned decl id instead of unaligned decl id (PR #95348)
ChuanqiXu9 wrote: @alexfh Could you try to test this? And if this doesn't mitigate it, it will be helpful to provide the hotspot. https://github.com/llvm/llvm-project/pull/95348 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Serialization] Use 32 bit aligned decl id instead of unaligned decl id (PR #95348)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 78ee473784e5ef6f0b19ce4cb111fb6e4d23c6b2 eeef0c06e2a17f49ce3bdf8ae78b9bf1cd05a077 -- clang/include/clang/Serialization/ASTBitCodes.h clang/include/clang/Serialization/ASTReader.h clang/include/clang/Serialization/ModuleFile.h clang/lib/Serialization/ASTReader.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index be5b6c4e3b..2b672f01fd 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -175,9 +175,7 @@ public: UnalignedUInt64() = default; UnalignedUInt64(uint64_t BitOffset) { set(BitOffset); } - operator uint64_t() const { -return get(); - } + operator uint64_t() const { return get(); } void set(uint64_t Offset) { BitLow = Offset; diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 6ef74296c8..15be400454 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -1265,9 +1265,9 @@ bool ASTReader::ReadLexicalDeclContextStorage(ModuleFile , auto = LexicalDecls[DC]; if (!Lex.first) { Lex = std::make_pair( -, llvm::ArrayRef( -reinterpret_cast(Blob.data()), -Blob.size() / sizeof(DeclID))); +, +llvm::ArrayRef(reinterpret_cast(Blob.data()), + Blob.size() / sizeof(DeclID))); } DC->setHasExternalLexicalStorage(true); return false; @@ -7972,8 +7972,7 @@ void ASTReader::FindFileRegionDecls(FileID File, if (EndIt != DInfo.Decls.end()) ++EndIt; - for (ArrayRef::iterator DIt = BeginIt; DIt != EndIt; - ++DIt) + for (ArrayRef::iterator DIt = BeginIt; DIt != EndIt; ++DIt) Decls.push_back(GetDecl(getGlobalDeclID(*DInfo.Mod, (LocalDeclID)(*DIt; } `` https://github.com/llvm/llvm-project/pull/95348 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [serialization] no transitive decl change (PR #92083)
ChuanqiXu9 wrote: I sent https://github.com/llvm/llvm-project/pull/95348 for aligned related change. For size increase, the reason and the possible solution are clear. We should store the declaration ID as two slots instead of one in the serialized format so that we can utilize VBR6 format better. https://github.com/llvm/llvm-project/pull/92083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Serialization] Use 32 bit aligned decl id instead of unaligned decl id (PR #95348)
llvmbot wrote: @llvm/pr-subscribers-clang-modules @llvm/pr-subscribers-clang Author: Chuanqi Xu (ChuanqiXu9) Changes See the post commit message in https://github.com/llvm/llvm-project/pull/92083. I suspect the compile time regression in AArch64 is related to alignments. I am not sure if this is the problem since I can't reproduce. --- Full diff: https://github.com/llvm/llvm-project/pull/95348.diff 4 Files Affected: - (modified) clang/include/clang/Serialization/ASTBitCodes.h (+11-9) - (modified) clang/include/clang/Serialization/ASTReader.h (+5-5) - (modified) clang/include/clang/Serialization/ModuleFile.h (+1-1) - (modified) clang/lib/Serialization/ASTReader.cpp (+11-11) ``diff diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index 52a6c5e10f802..be5b6c4e3b9bd 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -168,13 +168,17 @@ const unsigned int NUM_PREDEF_SUBMODULE_IDS = 1; /// because blobs in bitstream are 32-bit aligned). This structure is /// serialized "as is" to the AST file. class UnalignedUInt64 { - uint32_t BitLow = 0; - uint32_t BitHigh = 0; + uint32_t BitLow; + uint32_t BitHigh; public: UnalignedUInt64() = default; UnalignedUInt64(uint64_t BitOffset) { set(BitOffset); } + operator uint64_t() const { +return get(); + } + void set(uint64_t Offset) { BitLow = Offset; BitHigh = Offset >> 32; @@ -255,11 +259,9 @@ class DeclOffset { } }; -// The unaligned decl ID used in the Blobs of bistreams. -using unaligned_decl_id_t = -llvm::support::detail::packed_endian_specific_integral< -serialization::DeclID, llvm::endianness::native, -llvm::support::unaligned>; +// The 32 bits aligned decl ID used in the Blobs of bistreams due the blobs +// are 32 bits aligned. +using SerializedDeclID = UnalignedUInt64; /// The number of predefined preprocessed entity IDs. const unsigned int NUM_PREDEF_PP_ENTITY_IDS = 1; @@ -1986,9 +1988,9 @@ enum CleanupObjectKind { COK_Block, COK_CompoundLiteral }; /// Describes the categories of an Objective-C class. struct ObjCCategoriesInfo { - // The ID of the definition. Use unaligned_decl_id_t to keep + // The ID of the definition. Use SerializedDeclID to keep // ObjCCategoriesInfo 32-bit aligned. - unaligned_decl_id_t DefinitionID; + SerializedDeclID DefinitionID; // Offset into the array of category lists. unsigned Offset; diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index 0a9006223dcbd..07c4f3b624441 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -586,11 +586,11 @@ class ASTReader struct FileDeclsInfo { ModuleFile *Mod = nullptr; -ArrayRef Decls; +ArrayRef Decls; FileDeclsInfo() = default; FileDeclsInfo(ModuleFile *Mod, - ArrayRef Decls) + ArrayRef Decls) : Mod(Mod), Decls(Decls) {} }; @@ -599,7 +599,7 @@ class ASTReader /// An array of lexical contents of a declaration context, as a sequence of /// Decl::Kind, DeclID pairs. - using LexicalContents = ArrayRef; + using LexicalContents = ArrayRef; /// Map from a DeclContext to its lexical contents. llvm::DenseMap> @@ -1482,7 +1482,7 @@ class ASTReader public: class ModuleDeclIterator : public llvm::iterator_adaptor_base< -ModuleDeclIterator, const serialization::unaligned_decl_id_t *, +ModuleDeclIterator, const serialization::SerializedDeclID *, std::random_access_iterator_tag, const Decl *, ptrdiff_t, const Decl *, const Decl *> { ASTReader *Reader = nullptr; @@ -1492,7 +1492,7 @@ class ASTReader ModuleDeclIterator() : iterator_adaptor_base(nullptr) {} ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod, - const serialization::unaligned_decl_id_t *Pos) + const serialization::SerializedDeclID *Pos) : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {} value_type operator*() const { diff --git a/clang/include/clang/Serialization/ModuleFile.h b/clang/include/clang/Serialization/ModuleFile.h index 56193d44dd6f3..a9cbd4bb267aa 100644 --- a/clang/include/clang/Serialization/ModuleFile.h +++ b/clang/include/clang/Serialization/ModuleFile.h @@ -458,7 +458,7 @@ class ModuleFile { unsigned BaseDeclIndex = 0; /// Array of file-level DeclIDs sorted by file. - const serialization::unaligned_decl_id_t *FileSortedDecls = nullptr; + const serialization::SerializedDeclID *FileSortedDecls = nullptr; unsigned NumFileSortedDecls = 0; /// Array of category list location information within this diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 59338b44db32f..6ef74296c829d
[clang] [Serialization] Use 32 bit aligned decl id instead of unaligned decl id (PR #95348)
https://github.com/ChuanqiXu9 created https://github.com/llvm/llvm-project/pull/95348 See the post commit message in https://github.com/llvm/llvm-project/pull/92083. I suspect the compile time regression in AArch64 is related to alignments. I am not sure if this is the problem since I can't reproduce. >From eeef0c06e2a17f49ce3bdf8ae78b9bf1cd05a077 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Thu, 13 Jun 2024 11:41:49 +0800 Subject: [PATCH] [Serialization] Use 32 bit aligned decl id instead of unaligned decl id See the post commit message in https://github.com/llvm/llvm-project/pull/92083. I suspect the compile time regression in AArch64 is related to alignments. --- .../include/clang/Serialization/ASTBitCodes.h | 20 + clang/include/clang/Serialization/ASTReader.h | 10 - .../include/clang/Serialization/ModuleFile.h | 2 +- clang/lib/Serialization/ASTReader.cpp | 22 +-- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h index 52a6c5e10f802..be5b6c4e3b9bd 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -168,13 +168,17 @@ const unsigned int NUM_PREDEF_SUBMODULE_IDS = 1; /// because blobs in bitstream are 32-bit aligned). This structure is /// serialized "as is" to the AST file. class UnalignedUInt64 { - uint32_t BitLow = 0; - uint32_t BitHigh = 0; + uint32_t BitLow; + uint32_t BitHigh; public: UnalignedUInt64() = default; UnalignedUInt64(uint64_t BitOffset) { set(BitOffset); } + operator uint64_t() const { +return get(); + } + void set(uint64_t Offset) { BitLow = Offset; BitHigh = Offset >> 32; @@ -255,11 +259,9 @@ class DeclOffset { } }; -// The unaligned decl ID used in the Blobs of bistreams. -using unaligned_decl_id_t = -llvm::support::detail::packed_endian_specific_integral< -serialization::DeclID, llvm::endianness::native, -llvm::support::unaligned>; +// The 32 bits aligned decl ID used in the Blobs of bistreams due the blobs +// are 32 bits aligned. +using SerializedDeclID = UnalignedUInt64; /// The number of predefined preprocessed entity IDs. const unsigned int NUM_PREDEF_PP_ENTITY_IDS = 1; @@ -1986,9 +1988,9 @@ enum CleanupObjectKind { COK_Block, COK_CompoundLiteral }; /// Describes the categories of an Objective-C class. struct ObjCCategoriesInfo { - // The ID of the definition. Use unaligned_decl_id_t to keep + // The ID of the definition. Use SerializedDeclID to keep // ObjCCategoriesInfo 32-bit aligned. - unaligned_decl_id_t DefinitionID; + SerializedDeclID DefinitionID; // Offset into the array of category lists. unsigned Offset; diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h index 0a9006223dcbd..07c4f3b624441 100644 --- a/clang/include/clang/Serialization/ASTReader.h +++ b/clang/include/clang/Serialization/ASTReader.h @@ -586,11 +586,11 @@ class ASTReader struct FileDeclsInfo { ModuleFile *Mod = nullptr; -ArrayRef Decls; +ArrayRef Decls; FileDeclsInfo() = default; FileDeclsInfo(ModuleFile *Mod, - ArrayRef Decls) + ArrayRef Decls) : Mod(Mod), Decls(Decls) {} }; @@ -599,7 +599,7 @@ class ASTReader /// An array of lexical contents of a declaration context, as a sequence of /// Decl::Kind, DeclID pairs. - using LexicalContents = ArrayRef; + using LexicalContents = ArrayRef; /// Map from a DeclContext to its lexical contents. llvm::DenseMap> @@ -1482,7 +1482,7 @@ class ASTReader public: class ModuleDeclIterator : public llvm::iterator_adaptor_base< -ModuleDeclIterator, const serialization::unaligned_decl_id_t *, +ModuleDeclIterator, const serialization::SerializedDeclID *, std::random_access_iterator_tag, const Decl *, ptrdiff_t, const Decl *, const Decl *> { ASTReader *Reader = nullptr; @@ -1492,7 +1492,7 @@ class ASTReader ModuleDeclIterator() : iterator_adaptor_base(nullptr) {} ModuleDeclIterator(ASTReader *Reader, ModuleFile *Mod, - const serialization::unaligned_decl_id_t *Pos) + const serialization::SerializedDeclID *Pos) : iterator_adaptor_base(Pos), Reader(Reader), Mod(Mod) {} value_type operator*() const { diff --git a/clang/include/clang/Serialization/ModuleFile.h b/clang/include/clang/Serialization/ModuleFile.h index 56193d44dd6f3..a9cbd4bb267aa 100644 --- a/clang/include/clang/Serialization/ModuleFile.h +++ b/clang/include/clang/Serialization/ModuleFile.h @@ -458,7 +458,7 @@ class ModuleFile { unsigned BaseDeclIndex = 0; /// Array of file-level DeclIDs sorted by file. - const serialization::unaligned_decl_id_t *FileSortedDecls = nullptr; + const
[clang] [Clang] Fix handling of brace ellison when building deduction guides (PR #94889)
https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/94889 >From 217c00f47aaa65b113d1c1cfd93a9c4e1d235c1a Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Sun, 9 Jun 2024 11:49:18 +0800 Subject: [PATCH 1/7] [Clang] Fix two issues of CTAD for aggregates --- clang/lib/Sema/SemaInit.cpp | 56 +++-- clang/test/SemaTemplate/deduction-guide.cpp | 19 +++ 2 files changed, 60 insertions(+), 15 deletions(-) diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 79bdc8e9f8783..de2ea639bbba8 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -313,6 +313,8 @@ class InitListChecker { InitListExpr *FullyStructuredList = nullptr; NoInitExpr *DummyExpr = nullptr; SmallVectorImpl *AggrDeductionCandidateParamTypes = nullptr; + SmallVectorImpl + *AggrDeductionCandidateParamTypesWithoutBraceElision = nullptr; NoInitExpr *getDummyInit() { if (!DummyExpr) @@ -506,14 +508,19 @@ class InitListChecker { Sema , const InitializedEntity , InitListExpr *IL, QualType , bool VerifyOnly, bool TreatUnavailableAsInvalid, bool InOverloadResolution = false, - SmallVectorImpl *AggrDeductionCandidateParamTypes = nullptr); + SmallVectorImpl *AggrDeductionCandidateParamTypes = nullptr, + SmallVectorImpl + *AggrDeductionCandidateParamTypesWithoutBraceElision = nullptr); InitListChecker(Sema , const InitializedEntity , InitListExpr *IL, QualType , - SmallVectorImpl ) + SmallVectorImpl , + SmallVectorImpl + ) : InitListChecker(S, Entity, IL, T, /*VerifyOnly=*/true, /*TreatUnavailableAsInvalid=*/false, /*InOverloadResolution=*/false, -){}; +, +) {} bool HadError() { return hadError; } @@ -982,11 +989,15 @@ static bool hasAnyDesignatedInits(const InitListExpr *IL) { InitListChecker::InitListChecker( Sema , const InitializedEntity , InitListExpr *IL, QualType , bool VerifyOnly, bool TreatUnavailableAsInvalid, bool InOverloadResolution, -SmallVectorImpl *AggrDeductionCandidateParamTypes) +SmallVectorImpl *AggrDeductionCandidateParamTypes, +SmallVectorImpl +*AggrDeductionCandidateParamTypesWithoutBraceElision) : SemaRef(S), VerifyOnly(VerifyOnly), TreatUnavailableAsInvalid(TreatUnavailableAsInvalid), InOverloadResolution(InOverloadResolution), - AggrDeductionCandidateParamTypes(AggrDeductionCandidateParamTypes) { + AggrDeductionCandidateParamTypes(AggrDeductionCandidateParamTypes), + AggrDeductionCandidateParamTypesWithoutBraceElision( + AggrDeductionCandidateParamTypesWithoutBraceElision) { if (!VerifyOnly || hasAnyDesignatedInits(IL)) { FullyStructuredList = createInitListExpr(T, IL->getSourceRange(), IL->getNumInits()); @@ -1448,13 +1459,17 @@ void InitListChecker::CheckSubElementType(const InitializedEntity , // brace elision is not considered for any aggregate element that has a // dependent non-array type or an array type with a value-dependent // bound - assert(AggrDeductionCandidateParamTypes); - if (!isa_and_nonnull( + assert(AggrDeductionCandidateParamTypes && + AggrDeductionCandidateParamTypesWithoutBraceElision); + if (!isa_and_present( SemaRef.Context.getAsArrayType(ElemType))) { ++Index; AggrDeductionCandidateParamTypes->push_back(ElemType); return; } + // For array types with known bounds, we still want the brace version even + // though the braces can be elided. + AggrDeductionCandidateParamTypesWithoutBraceElision->push_back(ElemType); } else { InitializationSequence Seq(SemaRef, TmpEntity, Kind, expr, /*TopLevelOfInitList*/ true); @@ -10918,22 +10933,24 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( if (!(RD->getDefinition() && RD->isAggregate())) return; QualType Ty = Context.getRecordType(RD); - SmallVector ElementTypes; - - InitListChecker CheckInitList(*this, Entity, ListInit, Ty, ElementTypes); - if (!CheckInitList.HadError()) { + auto BuildAggregateDeductionGuide = [&](MutableArrayRef + ElementTypes, + bool BracedVersion = false) { +if (ElementTypes.empty()) + return; // C++ [over.match.class.deduct]p1.8: // if e_i is of array type and x_i is a braced-init-list, T_i is an // rvalue reference to the declared type of e_i and // C++ [over.match.class.deduct]p1.9: -// if e_i is of array type and x_i is a bstring-literal, T_i is an +// if
[clang] [Clang] Fix handling of brace ellison when building deduction guides (PR #94889)
@@ -1449,7 +1449,10 @@ void InitListChecker::CheckSubElementType(const InitializedEntity , // dependent non-array type or an array type with a value-dependent // bound assert(AggrDeductionCandidateParamTypes); - if (!isa_and_nonnull( + // Don't consider the brace elision if the initializer is a + // braced-init-list. + if (isa(expr) || zyn0217 wrote: Thanks for the writeup! This matches what I thought. A few more comments: > as the e1 has a dependent type we can't perform semantic checks to see > whether the T t[2] can be initialized by x1, we always assume true here. Yeah. For the case above, and as per [P2081](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2082r1.pdf)'s purposes, brace elision should be considered on arrays (possibly type-dependent, but the bound should be non-dependent), and what we used to do here is to always fall through to the brace elision logic below regardless of the presence of braces within the corresponding initializer `e`. And this results in issues of not having proper deduction guides. > This has an effect that we will generate the deduction guide even for invalid > case e.g. x1 is {1, 2, 3} ... Yep, we don't guard against invalid initializers here because the `InitListChecker` is merely employed to generate "candidate" parameters. (where we set `VerifyOnly` to true) https://github.com/llvm/llvm-project/pull/94889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-format] Don't count template template parameter as declaration (PR #95025)
@@ -1269,10 +1269,17 @@ class AnnotatingParser { if (CurrentToken && CurrentToken->is(tok::less)) { CurrentToken->setType(TT_TemplateOpener); next(); - if (!parseAngle()) + TemplateDeclarationDepth++; + if (!parseAngle()) { +TemplateDeclarationDepth--; return false; - if (CurrentToken) + } + TemplateDeclarationDepth--; + if (CurrentToken && + (TemplateDeclarationDepth == 0 || + !CurrentToken->isOneOf(tok::kw_typename, tok::kw_class))) { owenca wrote: > If parseAngle fails, wouldn't that cause InTemplateDeclaration to forever be > true? Is that not an issue? If `parseAngle()` returns false, it probably means that the template decl is ill-formed. If so, it doesn't matter if `InTemplateDeclaration` is set to false? An alternative solution: ``` - bool parseTemplateDeclaration() { -if (CurrentToken && CurrentToken->is(tok::less)) { - CurrentToken->setType(TT_TemplateOpener); - next(); - if (!parseAngle()) -return false; - if (CurrentToken) -CurrentToken->Previous->ClosesTemplateDeclaration = true; - return true; -} -return false; + bool parseTemplateDeclaration(bool InTemplateParameter) { +if (!CurrentToken || CurrentToken->isNot(tok::less)) + return false; + +InTemplateDeclaration = true; +CurrentToken->setType(TT_TemplateOpener); +next(); + +const bool WellFormed = parseAngle(); +InTemplateDeclaration = InTemplateParameter; + +if (!WellFormed) + return false; + +if (CurrentToken && !InTemplateParameter) + CurrentToken->Previous->ClosesTemplateDeclaration = true; + +return true; } ``` https://github.com/llvm/llvm-project/pull/95025 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (PR #94559)
farzonl wrote: It seems like we have four options here. We can drop the `def Tan : FPMathTemplate, LibBuiltin<"math.h">` builtins so no `Builtin::BItanf` or `Builtin::BItanl` in cgbuitlin switch case. That wouldn't solve the SLPVectorizer case but doesn't expose it either unless you use a clang_builtin function which should limit the impact. The tan library functions would behave as before. Option 2 we land an arm7 backend for Tan. That could work for you, but the issue you raised with the `SLPVectorizer` case likely means this same issue exists for powerPC, RISCV, and potentially other backends. Option 3. we guard the emitter with a target check for wasm (maybe), x86, and aarch64 ```cpp case Builtin::BItanf: case Builtin::BItanl: case Builtin::BI__builtin_tan: case Builtin::BI__builtin_tanf: case Builtin::BI__builtin_tanf16: case Builtin::BI__builtin_tanl: case Builtin::BI__builtin_tanf128: { switch(CGF.getTarget().getTriple().getArch()) { case llvm::Triple::aarch64: case llvm::Triple::x86: case llvm::Triple::x86_64: case llvm::Triple::wasm32: case llvm::Triple::wasm64: return RValue::get(emitUnaryMaybeConstrainedFPBuiltin( *this, E, Intrinsic::tan, Intrinsic::experimental_constrained_tan)); } } ``` Option 4 we revert this change, The test cases would go stale and it also means our plans for landing constraint intrinsics needs to go in the backlog, because it means constraint intrinsics don't make sense until tan has full support across all backends. https://github.com/llvm/llvm-project/pull/94559 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix handling of brace ellison when building deduction guides (PR #94889)
@@ -10918,22 +10944,24 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( if (!(RD->getDefinition() && RD->isAggregate())) return; QualType Ty = Context.getRecordType(RD); - SmallVector ElementTypes; - - InitListChecker CheckInitList(*this, Entity, ListInit, Ty, ElementTypes); - if (!CheckInitList.HadError()) { + auto BuildAggregateDeductionGuide = [&](MutableArrayRef + ElementTypes, + bool BracedVersion = false) { +if (ElementTypes.empty()) + return; // C++ [over.match.class.deduct]p1.8: // if e_i is of array type and x_i is a braced-init-list, T_i is an // rvalue reference to the declared type of e_i and // C++ [over.match.class.deduct]p1.9: -// if e_i is of array type and x_i is a bstring-literal, T_i is an +// if e_i is of array type and x_i is a string-literal, T_i is an // lvalue reference to the const-qualified declared type of e_i and // C++ [over.match.class.deduct]p1.10: // otherwise, T_i is the declared type of e_i -for (int I = 0, E = ListInit->getNumInits(); +for (int I = 0, E = BracedVersion ? ElementTypes.size() + : ListInit->getNumInits(); I < E && !isa(ElementTypes[I]); ++I) if (ElementTypes[I]->isArrayType()) { -if (isa(ListInit->getInit(I))) +if (isa(ListInit->getInit(I))) zyn0217 wrote: How about saying `The braced-init-list consisted of initializer-list and designated-initializer-list`? Probably this is less confusing from the logical relationship. https://github.com/llvm/llvm-project/pull/94889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix handling of brace ellison when building deduction guides (PR #94889)
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/94889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix handling of brace ellison when building deduction guides (PR #94889)
https://github.com/zyn0217 edited https://github.com/llvm/llvm-project/pull/94889 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)
@@ -318,6 +318,9 @@ namespace { if (Diags.hasUnrecoverableErrorOccurred()) return; + if (RD->shouldEmitInExternalSource()) ChuanqiXu9 wrote: Yes, I think it is not bad to put the check `RD->shouldEmitInExternalSource()` into `HandleVTable`. I feel the most natural logic may be, I see a vtable then I pass it to the consumer and it is the job of the consumer to decide whether or not to emit it. WDYT? https://github.com/llvm/llvm-project/pull/75912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)
@@ -318,6 +318,9 @@ namespace { if (Diags.hasUnrecoverableErrorOccurred()) return; + if (RD->shouldEmitInExternalSource()) efriedma-quic wrote: Did you mean to change something in ModuleBuilder.cpp? https://github.com/llvm/llvm-project/pull/75912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (PR #94559)
aeubanks wrote: SLPVectorizer can introduce `llvm.tan.v2f32`. For example, running `opt -O3` on the following introduces `llvm.tan.v2f32` ``` target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" target triple = "thumbv7-unknown-linux-android26" ; Function Attrs: null_pointer_is_valid define void @foo() #0 { bb: %call = call float @pluto(float 1.00e+00) %call1 = call i1 @ham(float %call) %call2 = call float @pluto(float 0.00e+00) %call3 = call i1 @ham(float %call2) %select = select i1 %call3, float 0.00e+00, float 1.00e+00 %select4 = select i1 %call1, float 0.00e+00, float 1.00e+00 store float %select, ptr null, align 4 %call5 = call ptr null(ptr null, float %select4, float 0.00e+00, float 0.00e+00, float 0.00e+00) ret void } define float @pluto(float %arg) { bb: %call = call float @llvm.tan.f32(float %arg) ret float %call } define i1 @ham(float %arg) { bb: %fcmp = fcmp ole float %arg, 0.00e+00 ret i1 %fcmp } ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) declare float @llvm.tan.f32(float) #1 attributes #0 = { null_pointer_is_valid } attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } ``` https://github.com/llvm/llvm-project/pull/94559 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)
haoNoQ wrote: Ok I think I'm completely happy with the patch now. It makes perfect sense to me and appears to be doing the right thing. Thank you @ziqingluo-90 for figuring this out! Let's add that comment and land. https://github.com/llvm/llvm-project/pull/92031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)
@@ -1911,6 +1911,20 @@ SourceManager::getDecomposedIncludedLoc(FileID FID) const { return DecompLoc; } +FileID SourceManager::getFirstFIDOfLoadedAST(SourceLocation Loc) const { + assert(isLoadedSourceLocation(Loc) && + "Must be a source location in a loaded PCH/Module file"); + + auto [FID, Ignore] = getDecomposedLoc(Loc); + const FileID *FirstFID = + llvm::lower_bound(LoadedSLocEntryAllocBegin, FID, std::greater{}); haoNoQ wrote: This is quite magical to me because I don't understand how FileIDs are assigned and in what order they show up in the `LoadedSLocEntryAllocBegin` list. But that's probably ok, this looks like completely normal `SourceManager` code to me. https://github.com/llvm/llvm-project/pull/92031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Safe Buffers] Serialize unsafe_buffer_usage pragmas (PR #92031)
@@ -1483,26 +1484,40 @@ void Preprocessor::emitFinalMacroWarning(const Token , } bool Preprocessor::isSafeBufferOptOut(const SourceManager , - const SourceLocation ) const { - // Try to find a region in `SafeBufferOptOutMap` where `Loc` is in: - auto FirstRegionEndingAfterLoc = llvm::partition_point( - SafeBufferOptOutMap, - [, - ](const std::pair ) { -return SourceMgr.isBeforeInTranslationUnit(Region.second, Loc); - }); + const SourceLocation ) const { + // The lambda that tests if a `Loc` is in an opt-out region given one opt-out + // region map: + auto TestInMap = [](const SafeBufferOptOutRegionsTy , +const SourceLocation ) -> bool { +// Try to find a region in `SafeBufferOptOutMap` where `Loc` is in: +auto FirstRegionEndingAfterLoc = llvm::partition_point( +Map, [, + ](const std::pair ) { + return SourceMgr.isBeforeInTranslationUnit(Region.second, Loc); +}); + +if (FirstRegionEndingAfterLoc != Map.end()) { + // To test if the start location of the found region precedes `Loc`: + return SourceMgr.isBeforeInTranslationUnit( + FirstRegionEndingAfterLoc->first, Loc); +} +// If we do not find a region whose end location passes `Loc`, we want to +// check if the current region is still open: +if (!Map.empty() && Map.back().first == Map.back().second) + return SourceMgr.isBeforeInTranslationUnit(Map.back().first, Loc); +return false; + }; haoNoQ wrote: Ok @ziqingluo-90 has just walked me through this offline and I think I understand what's happening now. What was unobvious to me: shouldn't we `TestInMap` over the entire stack of includes? And the answer is: - Regular textual `#include`s will just show up in the current map normally; there's no need to go up the stack. - PCHes are going to be included with the `-include-pch` flag, not directly. There's not really much of a stack going on at this point and there's no way to "put pragmas around the compiler flag". - In case of modules, we don't care what this function returns deep inside a module, because we probably shouldn't be analyzing that code in the first place. Instead, the warning should be naturally enabled in the clang invocation that builds the module itself, and that's where the warning would be emitted, taking only the current module into account. - As a matter of fact, as of today we're analyzing that nested code. But we shouldn't be, that's not how modules are intended to work. We consider it a bug and have a separate plan to fix this. Right now this means that the warning will be emitted multiple times for the same line of code (both by module compilation and by .cpp file compilation, and possibly by everything in between). And the worst that could happen if this function misbehaves, is that some of these duplicates will disappear. Which is annoying but harmless. Let's add a comment explaining this! https://github.com/llvm/llvm-project/pull/92031 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)
@@ -318,6 +318,9 @@ namespace { if (Diags.hasUnrecoverableErrorOccurred()) return; + if (RD->shouldEmitInExternalSource()) ChuanqiXu9 wrote: I use `isInCurrentModuleUnit` instead since I feel the semantics are more clear. https://github.com/llvm/llvm-project/pull/75912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)
https://github.com/ChuanqiXu9 updated https://github.com/llvm/llvm-project/pull/75912 >From cf8be3c418dde67b74d4a5a4ea98a33f0e2fbd72 Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Tue, 19 Dec 2023 17:00:59 +0800 Subject: [PATCH 1/6] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes Close https://github.com/llvm/llvm-project/issues/70585 and reflect https://github.com/itanium-cxx-abi/cxx-abi/issues/170. The significant change of the patch is: for dynamic classes attached to module units, we generate the vtable to the attached module units directly and the key functions for such classes is meaningless. --- clang/include/clang/AST/DeclBase.h| 3 ++ clang/lib/AST/DeclBase.cpp| 9 + clang/lib/CodeGen/CGVTables.cpp | 28 ++ clang/lib/CodeGen/CodeGenModule.cpp | 7 clang/lib/CodeGen/ItaniumCXXABI.cpp | 3 ++ clang/lib/Sema/SemaDecl.cpp | 9 + clang/lib/Sema/SemaDeclCXX.cpp| 12 -- clang/lib/Serialization/ASTReaderDecl.cpp | 6 +++ clang/lib/Serialization/ASTWriterDecl.cpp | 6 +++ clang/test/CodeGenCXX/modules-vtable.cppm | 31 +-- clang/test/CodeGenCXX/pr70585.cppm| 47 +++ 11 files changed, 138 insertions(+), 23 deletions(-) create mode 100644 clang/test/CodeGenCXX/pr70585.cppm diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 600ce73c7f019..f38386381853b 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -670,6 +670,9 @@ class alignas(8) Decl { /// Whether this declaration comes from another module unit. bool isInAnotherModuleUnit() const; + /// Whether this declaration comes from the same module unit being compiled. + bool isInCurrentModuleUnit() const; + /// Whether the definition of the declaration should be emitted in external /// sources. bool shouldEmitInExternalSource() const; diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 1e9c879e371bc..153dc3351dae5 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -1106,6 +1106,15 @@ bool Decl::isInAnotherModuleUnit() const { return M != getASTContext().getCurrentNamedModule(); } +bool Decl::isInCurrentModuleUnit() const { + auto *M = getOwningModule(); + + if (!M || !M->isNamedModule()) +return false; + + return M == getASTContext().getCurrentNamedModule(); +} + bool Decl::shouldEmitInExternalSource() const { ExternalASTSource *Source = getASTContext().getExternalSource(); if (!Source) diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index 001633453f242..55c3032dc9332 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -1051,6 +1051,11 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) { if (!RD->isExternallyVisible()) return llvm::GlobalVariable::InternalLinkage; + // V-tables for non-template classes with an owning module are always + // uniquely emitted in that module. + if (RD->isInNamedModule()) +return llvm::GlobalVariable::ExternalLinkage; + // We're at the end of the translation unit, so the current key // function is fully correct. const CXXMethodDecl *keyFunction = Context.getCurrentKeyFunction(RD); @@ -1185,6 +1190,21 @@ bool CodeGenVTables::isVTableExternal(const CXXRecordDecl *RD) { TSK == TSK_ExplicitInstantiationDefinition) return false; + // Itanium C++ ABI [5.2.3]: + // Virtual tables for dynamic classes are emitted as follows: + // + // - If the class is templated, the tables are emitted in every object that + // references any of them. + // - Otherwise, if the class is attached to a module, the tables are uniquely + // emitted in the object for the module unit in which it is defined. + // - Otherwise, if the class has a key function (see below), the tables are + // emitted in the object for the translation unit containing the definition of + // the key function. This is unique if the key function is not inline. + // - Otherwise, the tables are emitted in every object that references any of + // them. + if (RD->isInNamedModule()) +return RD->shouldEmitInExternalSource(); + // Otherwise, if the class doesn't have a key function (possibly // anymore), the vtable must be defined here. const CXXMethodDecl *keyFunction = CGM.getContext().getCurrentKeyFunction(RD); @@ -1194,13 +1214,7 @@ bool CodeGenVTables::isVTableExternal(const CXXRecordDecl *RD) { const FunctionDecl *Def; // Otherwise, if we don't have a definition of the key function, the // vtable must be defined somewhere else. - if (!keyFunction->hasBody(Def)) -return true; - - assert(Def && "The body of the key function is not assigned to Def?"); - // If the non-inline key function comes from another module unit, the vtable - // must be defined there. - return
[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)
aeubanks wrote: > @aeubanks I'll revert. Is this example C or C++? C++ https://github.com/llvm/llvm-project/pull/94216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [serialization] no transitive decl change (PR #92083)
ChuanqiXu9 wrote: Oh, the time regression is surprising to me. And I observed that @alexfh only reports (compile performance) problems on AArch64 but @bgra8 reports (size increase problems) on both ARM64 and X86_64. @alexfh is it true? So I **guess** the problem may come from the unaligned access. I'll try to refactor it to store 2 32-bits integer instead of 1 64 bits in the PCM files. It may still be helpful to locate the problem and prepare a reproducer though. https://github.com/llvm/llvm-project/pull/92083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2e1ad93 - [clang] fix broken canonicalization of DeducedTemplateSpecializationType (#95202)
Author: Matheus Izvekov Date: 2024-06-12T22:40:39-03:00 New Revision: 2e1ad93961a3f444659c5d02d800e3144acccdb4 URL: https://github.com/llvm/llvm-project/commit/2e1ad93961a3f444659c5d02d800e3144acccdb4 DIFF: https://github.com/llvm/llvm-project/commit/2e1ad93961a3f444659c5d02d800e3144acccdb4.diff LOG: [clang] fix broken canonicalization of DeducedTemplateSpecializationType (#95202) This reverts the functional elements of commit 3e78fa860235431323aaf08c8fa922d75a7cfffa and redoes it, by fixing the true root cause of #61317. A TemplateName can be non-canonical; profiling it based on the canonical name would result in inconsistent preservation of as-written information in the AST. The true problem in #61317 is that we would not consider the methods with requirements expression which contain DTSTs as the same in relation to merging of declarations when importing modules. The expressions would never match because they contained DTSTs pointing to different redeclarations of the same class template, but since canonicalization for them was broken, their canonical types would not match either. --- No changelog entry because #61317 was already claimed as fixed in previous release. Added: clang/unittests/AST/ProfilingTest.cpp Modified: clang/include/clang/AST/ASTContext.h clang/include/clang/AST/TemplateName.h clang/include/clang/AST/Type.h clang/lib/AST/ASTContext.cpp clang/lib/AST/TemplateName.cpp clang/unittests/AST/CMakeLists.txt Removed: diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 8bce4812f0d48..f1f20fca477a4 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1771,6 +1771,13 @@ class ASTContext : public RefCountedBase { QualType DeducedType, bool IsDependent) const; +private: + QualType getDeducedTemplateSpecializationTypeInternal(TemplateName Template, +QualType DeducedType, +bool IsDependent, +QualType Canon) const; + +public: /// Return the unique reference to the type for the specified TagDecl /// (struct/union/class/enum) decl. QualType getTagDeclType(const TagDecl *Decl) const; diff --git a/clang/include/clang/AST/TemplateName.h b/clang/include/clang/AST/TemplateName.h index 988a55acd2252..24a7fde76195d 100644 --- a/clang/include/clang/AST/TemplateName.h +++ b/clang/include/clang/AST/TemplateName.h @@ -346,7 +346,9 @@ class TemplateName { /// error. void dump() const; - void Profile(llvm::FoldingSetNodeID ); + void Profile(llvm::FoldingSetNodeID ) { +ID.AddPointer(Storage.getOpaqueValue()); + } /// Retrieve the template name as a void pointer. void *getAsVoidPointer() const { return Storage.getOpaqueValue(); } diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..fab233b62d8d1 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -6050,30 +6050,27 @@ class DeducedTemplateSpecializationType : public DeducedType, DeducedTemplateSpecializationType(TemplateName Template, QualType DeducedAsType, -bool IsDeducedAsDependent) +bool IsDeducedAsDependent, QualType Canon) : DeducedType(DeducedTemplateSpecialization, DeducedAsType, toTypeDependence(Template.getDependence()) | (IsDeducedAsDependent ? TypeDependence::DependentInstantiation : TypeDependence::None), -DeducedAsType.isNull() ? QualType(this, 0) - : DeducedAsType.getCanonicalType()), +Canon), Template(Template) {} public: /// Retrieve the name of the template that we are deducing. TemplateName getTemplateName() const { return Template;} - void Profile(llvm::FoldingSetNodeID ) { + void Profile(llvm::FoldingSetNodeID ) const { Profile(ID, getTemplateName(), getDeducedType(), isDependentType()); } static void Profile(llvm::FoldingSetNodeID , TemplateName Template, QualType Deduced, bool IsDependent) { Template.Profile(ID); -QualType CanonicalType = -Deduced.isNull() ? Deduced : Deduced.getCanonicalType(); -ID.AddPointer(CanonicalType.getAsOpaquePtr()); +Deduced.Profile(ID); ID.AddBoolean(IsDependent || Template.isDependent()); } diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index cd76b8aa271da..aa22825602a40 100644 ---
[clang] [clang] fix broken canonicalization of DeducedTemplateSpecializationType (PR #95202)
https://github.com/mizvekov closed https://github.com/llvm/llvm-project/pull/95202 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix broken canonicalization of DeducedTemplateSpecializationType (PR #95202)
https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/95202 >From 8bd63f109c2bc1888b4d8dbd5e880900bbb4cef7 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Wed, 12 Jun 2024 00:42:48 -0300 Subject: [PATCH] [clang] fix broken canonicalization of DeducedTemplateSpecializationType This reverts the functional elements of commit 3e78fa860235431323aaf08c8fa922d75a7cfffa and redoes it, by fixing the true root cause of #61317. A TemplateName can be non-canonical; profiling it based on the canonical name would result in inconsistent preservation of as-written information in the AST. The true problem in #61317 is that we would not consider the methods with requirements expression which contain DTSTs as the same in relation to merging of declarations when importing modules. The expressions would never match because they contained DTSTs pointing to different redeclarations of the same class template, but since canonicalization for them was broken, their canonical types would not match either. --- No changelog entry because #61317 was already claimed as fixed in previous release. --- clang/include/clang/AST/ASTContext.h | 7 +++ clang/include/clang/AST/TemplateName.h | 4 +- clang/include/clang/AST/Type.h | 11 ++-- clang/lib/AST/ASTContext.cpp | 25 ++--- clang/lib/AST/TemplateName.cpp | 9 clang/unittests/AST/CMakeLists.txt | 1 + clang/unittests/AST/ProfilingTest.cpp | 73 ++ 7 files changed, 107 insertions(+), 23 deletions(-) create mode 100644 clang/unittests/AST/ProfilingTest.cpp diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index a1d1d1c51cd41..53ece996769a8 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1771,6 +1771,13 @@ class ASTContext : public RefCountedBase { QualType DeducedType, bool IsDependent) const; +private: + QualType getDeducedTemplateSpecializationTypeInternal(TemplateName Template, +QualType DeducedType, +bool IsDependent, +QualType Canon) const; + +public: /// Return the unique reference to the type for the specified TagDecl /// (struct/union/class/enum) decl. QualType getTagDeclType(const TagDecl *Decl) const; diff --git a/clang/include/clang/AST/TemplateName.h b/clang/include/clang/AST/TemplateName.h index 988a55acd2252..24a7fde76195d 100644 --- a/clang/include/clang/AST/TemplateName.h +++ b/clang/include/clang/AST/TemplateName.h @@ -346,7 +346,9 @@ class TemplateName { /// error. void dump() const; - void Profile(llvm::FoldingSetNodeID ); + void Profile(llvm::FoldingSetNodeID ) { +ID.AddPointer(Storage.getOpaqueValue()); + } /// Retrieve the template name as a void pointer. void *getAsVoidPointer() const { return Storage.getOpaqueValue(); } diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 9eb3f6c09e3d3..fab233b62d8d1 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -6050,30 +6050,27 @@ class DeducedTemplateSpecializationType : public DeducedType, DeducedTemplateSpecializationType(TemplateName Template, QualType DeducedAsType, -bool IsDeducedAsDependent) +bool IsDeducedAsDependent, QualType Canon) : DeducedType(DeducedTemplateSpecialization, DeducedAsType, toTypeDependence(Template.getDependence()) | (IsDeducedAsDependent ? TypeDependence::DependentInstantiation : TypeDependence::None), -DeducedAsType.isNull() ? QualType(this, 0) - : DeducedAsType.getCanonicalType()), +Canon), Template(Template) {} public: /// Retrieve the name of the template that we are deducing. TemplateName getTemplateName() const { return Template;} - void Profile(llvm::FoldingSetNodeID ) { + void Profile(llvm::FoldingSetNodeID ) const { Profile(ID, getTemplateName(), getDeducedType(), isDependentType()); } static void Profile(llvm::FoldingSetNodeID , TemplateName Template, QualType Deduced, bool IsDependent) { Template.Profile(ID); -QualType CanonicalType = -Deduced.isNull() ? Deduced : Deduced.getCanonicalType(); -ID.AddPointer(CanonicalType.getAsOpaquePtr()); +Deduced.Profile(ID); ID.AddBoolean(IsDependent || Template.isDependent()); } diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index bf74e56a14799..34aa399fda2f8 100644 ---
[clang-tools-extra] [clang-tidy] ignoring macro with hash preprocessing token in cppcoreguidelines-macro-usage (PR #95265)
https://github.com/HerrCai0907 closed https://github.com/llvm/llvm-project/pull/95265 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] b06da39 - [clang-tidy] ignoring macro with hash preprocessing token in cppcoreguidelines-macro-usage (#95265)
Author: Congcong Cai Date: 2024-06-13T09:36:33+08:00 New Revision: b06da39cae0f7e2c6b8bc0bb03b734f9715c0bf3 URL: https://github.com/llvm/llvm-project/commit/b06da39cae0f7e2c6b8bc0bb03b734f9715c0bf3 DIFF: https://github.com/llvm/llvm-project/commit/b06da39cae0f7e2c6b8bc0bb03b734f9715c0bf3.diff LOG: [clang-tidy] ignoring macro with hash preprocessing token in cppcoreguidelines-macro-usage (#95265) `#` and `##` preprocessing tokens cannot be replaced by constexpr function. It should be ignored in check. Added: Modified: clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/macro-usage.rst clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/macro-usage.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp index 0cd4bf6fdfd87..11eb056e916d3 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp @@ -7,12 +7,12 @@ //===--===// #include "MacroUsageCheck.h" +#include "clang/Basic/TokenKinds.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Lex/PPCallbacks.h" #include "clang/Lex/Preprocessor.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Regex.h" -#include #include #include @@ -37,7 +37,10 @@ class MacroUsageCallbacks : public PPCallbacks { const MacroDirective *MD) override { if (SM.isWrittenInBuiltinFile(MD->getLocation()) || MD->getMacroInfo()->isUsedForHeaderGuard() || -MD->getMacroInfo()->getNumTokens() == 0) +MD->getMacroInfo()->tokens_empty() || +llvm::any_of(MD->getMacroInfo()->tokens(), [](const Token ) { + return T.isOneOf(tok::TokenKind::hash, tok::TokenKind::hashhash); +})) return; if (IgnoreCommandLineMacros && diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 6bf70c5cf4f8a..5d5aecd67b2d7 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -266,6 +266,10 @@ Changes in existing checks ` check to also handle calls to ``std::forward``. +- Improved :doc:`cppcoreguidelines-macro-usage + ` check by ignoring macro with + hash preprocessing token. + - Improved :doc:`cppcoreguidelines-missing-std-forward ` check by no longer giving false positives for deleted functions, by fixing false negatives when only diff --git a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/macro-usage.rst b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/macro-usage.rst index 8b763c28479e6..49417effbb6ff 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/macro-usage.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/macro-usage.rst @@ -17,6 +17,7 @@ Examples: #define C 0 #define F1(x, y) ((a) > (b) ? (a) : (b)) #define F2(...) (__VA_ARGS__) + #define F3(x, y) x##y #define COMMA , #define NORETURN [[noreturn]] #define DEPRECATED attribute((deprecated)) diff --git a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/macro-usage.cpp b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/macro-usage.cpp index 404aafb6b1c45..865ef9df1182e 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/macro-usage.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/macro-usage.cpp @@ -31,6 +31,10 @@ // CHECK-MESSAGES: [[@LINE-1]]:9: warning: variadic macro 'PROBLEMATIC_VARIADIC2' used; consider using a 'constexpr' variadic template function // These are all examples of common macros that shouldn't have constexpr suggestions. +#define CONCAT_NAME(a, b) a##b + +#define CONCAT_STR(a, b) #a #b + #define COMMA , #define NORETURN [[noreturn]] ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix broken canonicalization of DeducedTemplateSpecializationType (PR #95202)
https://github.com/ChuanqiXu9 approved this pull request. LGTM. Thanks. https://github.com/llvm/llvm-project/pull/95202 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Fuchsia] Add armv7m and armv8m runtimes to Fuchsia Clang toolchain (PR #95337)
https://github.com/petrhosek approved this pull request. https://github.com/llvm/llvm-project/pull/95337 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Implement resource binding type prefix mismatch errors (PR #87578)
https://github.com/bob80905 updated https://github.com/llvm/llvm-project/pull/87578 >From 3960050439964fe3c0536696490b284a6c470cd1 Mon Sep 17 00:00:00 2001 From: Joshua Batista Date: Wed, 3 Apr 2024 13:15:59 -0700 Subject: [PATCH 01/14] implement binding type error for t/cbuffers and rwbuffers --- .../clang/Basic/DiagnosticSemaKinds.td| 1 + clang/lib/Sema/HLSLExternalSemaSource.cpp | 19 +++-- clang/lib/Sema/SemaDeclAttr.cpp | 73 ++- .../resource_binding_attr_error_mismatch.hlsl | 65 + 4 files changed, 149 insertions(+), 9 deletions(-) create mode 100644 clang/test/SemaHLSL/resource_binding_attr_error_mismatch.hlsl diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 51af81bf1f6fc..9a0946276f80f 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -12149,6 +12149,7 @@ def err_hlsl_missing_semantic_annotation : Error< def err_hlsl_init_priority_unsupported : Error< "initializer priorities are not supported in HLSL">; +def err_hlsl_mismatching_register_type_and_name: Error<"invalid register name prefix '%0' for register type '%1' (expected '%2')">; def err_hlsl_unsupported_register_type : Error<"invalid resource class specifier '%0' used; expected 'b', 's', 't', or 'u'">; def err_hlsl_unsupported_register_number : Error<"register number should be an integer">; def err_hlsl_expected_space : Error<"invalid space specifier '%0' used; expected 'space' followed by an integer, like space1">; diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp b/clang/lib/Sema/HLSLExternalSemaSource.cpp index 1a1febf7a3524..479689ec82dce 100644 --- a/clang/lib/Sema/HLSLExternalSemaSource.cpp +++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp @@ -119,8 +119,10 @@ struct BuiltinTypeDeclBuilder { ResourceKind RK, bool IsROV) { if (Record->isCompleteDefinition()) return *this; -Record->addAttr(HLSLResourceAttr::CreateImplicit(Record->getASTContext(), - RC, RK, IsROV)); +HLSLResourceAttr *attr = HLSLResourceAttr::CreateImplicit( +Record->getASTContext(), RC, RK, IsROV); + +Record->addAttr(attr); return *this; } @@ -482,15 +484,18 @@ static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema , bool IsROV) { return BuiltinTypeDeclBuilder(Decl) .addHandleMember() - .addDefaultHandleConstructor(S, RC) - .annotateResourceClass(RC, RK, IsROV); + .addDefaultHandleConstructor(S, RC); } void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() { CXXRecordDecl *Decl; - Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWBuffer") - .addSimpleTemplateParams({"element_type"}) - .Record; + Decl = + BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWBuffer") + .addSimpleTemplateParams({"element_type"}) + .annotateResourceClass(ResourceClass::UAV, ResourceKind::TypedBuffer, + /*IsROV=*/false) + .Record; + onCompletion(Decl, [this](CXXRecordDecl *Decl) { setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, ResourceKind::TypedBuffer, /*IsROV=*/false) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index f25f3afd0f4af..e720fe56c3ea1 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -7333,12 +7333,12 @@ static void handleHLSLResourceBindingAttr(Sema , Decl *D, } else { Slot = Str; } - + QualType Ty = ((clang::ValueDecl *)D)->getType(); // Validate. if (!Slot.empty()) { switch (Slot[0]) { -case 'u': case 'b': +case 'u': case 's': case 't': break; @@ -7367,6 +7367,75 @@ static void handleHLSLResourceBindingAttr(Sema , Decl *D, return; } + VarDecl *VD = dyn_cast(D); + HLSLBufferDecl *BD = dyn_cast(D); + + if (VD || BD) { +llvm::hlsl::ResourceClass RC; +std::string varTy = ""; +if (VD) { + + const Type *Ty = VD->getType()->getPointeeOrArrayElementType(); + if (!Ty) +return; + QualType t = ((ElaboratedType *)Ty)->getNamedType(); + const CXXRecordDecl *RD = Ty->getAsCXXRecordDecl(); + if (!RD) +return; + + if (auto TDecl = dyn_cast(RD)) +RD = TDecl->getSpecializedTemplate()->getTemplatedDecl(); + RD = RD->getCanonicalDecl(); + const auto *Attr = RD->getAttr(); + if (!Attr) +return; + + RC = Attr->getResourceClass(); + varTy = RD->getNameAsString(); +} else { + if (BD->isCBuffer()) { +RC = llvm::hlsl::ResourceClass::CBuffer; +varTy = "cbuffer"; + } else { +RC = llvm::hlsl::ResourceClass::CBuffer; +varTy =
[clang] [Fuchsia] Add armv7m and armv8m runtimes to Fuchsia Clang toolchain (PR #95337)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Haowei (zeroomega) Changes This patch adds armv7m and armv8m runtimes to Fuchsia Clang toolchain configuration. --- Full diff: https://github.com/llvm/llvm-project/pull/95337.diff 1 Files Affected: - (modified) clang/cmake/caches/Fuchsia-stage2.cmake (+3-3) ``diff diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index aa07b04be65cc..a573ec5473210 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -300,14 +300,14 @@ if(FUCHSIA_SDK) set(LLVM_RUNTIME_MULTILIB_hwasan+noexcept_TARGETS "aarch64-unknown-fuchsia;riscv64-unknown-fuchsia" CACHE STRING "") endif() -foreach(target armv6m-unknown-eabi) +foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m-unknown-eabi) list(APPEND BUILTIN_TARGETS "${target}") set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "") set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "") set(BUILTINS_${target}_CMAKE_SYSROOT "" CACHE STRING "") set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") foreach(lang C;CXX;ASM) -set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} -mcpu=cortex-m0plus -mthumb" CACHE STRING "") +set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} -mthumb" CACHE STRING "") endforeach() foreach(type SHARED;MODULE;EXE) set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") @@ -321,7 +321,7 @@ foreach(target armv6m-unknown-eabi) set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") set(RUNTIMES_${target}_CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE STRING "") foreach(lang C;CXX;ASM) -set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} -mcpu=cortex-m0plus -mthumb" CACHE STRING "") +set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} -mthumb" CACHE STRING "") endforeach() foreach(type SHARED;MODULE;EXE) set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") `` https://github.com/llvm/llvm-project/pull/95337 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Fuchsia] Add armv7m and armv8m runtimes to Fuchsia Clang toolchain (PR #95337)
https://github.com/zeroomega created https://github.com/llvm/llvm-project/pull/95337 This patch adds armv7m and armv8m runtimes to Fuchsia Clang toolchain configuration. >From 5dfd619b9a5799539606d3bb2879c9d13111a6da Mon Sep 17 00:00:00 2001 From: Haowei Wu Date: Wed, 12 Jun 2024 17:27:23 -0700 Subject: [PATCH] [Fuchsia] Add armv7m and armv8m runtimes to Fuchsia Clang toolchain This patch adds armv7m and armv8m runtimes to Fuchsia Clang toolchain configuration. --- clang/cmake/caches/Fuchsia-stage2.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake b/clang/cmake/caches/Fuchsia-stage2.cmake index aa07b04be65cc..a573ec5473210 100644 --- a/clang/cmake/caches/Fuchsia-stage2.cmake +++ b/clang/cmake/caches/Fuchsia-stage2.cmake @@ -300,14 +300,14 @@ if(FUCHSIA_SDK) set(LLVM_RUNTIME_MULTILIB_hwasan+noexcept_TARGETS "aarch64-unknown-fuchsia;riscv64-unknown-fuchsia" CACHE STRING "") endif() -foreach(target armv6m-unknown-eabi) +foreach(target armv6m-unknown-eabi;armv7m-unknown-eabi;armv8m-unknown-eabi) list(APPEND BUILTIN_TARGETS "${target}") set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Generic CACHE STRING "") set(BUILTINS_${target}_CMAKE_SYSTEM_PROCESSOR arm CACHE STRING "") set(BUILTINS_${target}_CMAKE_SYSROOT "" CACHE STRING "") set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") foreach(lang C;CXX;ASM) -set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} -mcpu=cortex-m0plus -mthumb" CACHE STRING "") +set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} -mthumb" CACHE STRING "") endforeach() foreach(type SHARED;MODULE;EXE) set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") @@ -321,7 +321,7 @@ foreach(target armv6m-unknown-eabi) set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") set(RUNTIMES_${target}_CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE STRING "") foreach(lang C;CXX;ASM) -set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} -mcpu=cortex-m0plus -mthumb" CACHE STRING "") +set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} -mthumb" CACHE STRING "") endforeach() foreach(type SHARED;MODULE;EXE) set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "") ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [serialization] no transitive decl change (PR #92083)
alexfh wrote: So, what's happening here is a significant increase in the compilation time of a pretty large source that has a large number of modular dependencies (using Clang header modules rather than C++20 modules). The times reported by `clang -ftime-report` for clang frontend change drastically: before this commit: ``` ===-=== Clang front-end time report ===-=== Total Execution Time: 207.1765 seconds (218.7714 wall clock) ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- 153.2751 ( 78.6%) 8.5109 ( 70.4%) 161.7860 ( 78.1%) 170.5710 ( 78.0%) Clang front-end timer 40.0169 ( 20.5%) 3.1469 ( 26.0%) 43.1638 ( 20.8%) 45.8168 ( 20.9%) Reading modules ``` after this commit: ``` ===-=== Clang front-end time report ===-=== Total Execution Time: 1134.1241 seconds (1179.8429 wall clock) ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- 591.7280 ( 54.0%) 21.5861 ( 56.0%) 613.3141 ( 54.1%) 638.4518 ( 54.1%) Clang front-end timer 502.9522 ( 45.9%) 16.6865 ( 43.3%) 519.6387 ( 45.8%) 540.1083 ( 45.8%) Reading modules ``` Given the notorious difficulty in preparing shareable test cases for modular compilations, I expect this to take days until we can give you something specific, but I'll ask @ilya-biryukov if he can spot something right away. And I suspect that ARM is a red herring here. The problem seems to be purely in Clang frontend. Checking... https://github.com/llvm/llvm-project/pull/92083 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ca91538 - [MC] Move AllowTemporaryLabels setting to MCContext::MCContext
Author: Fangrui Song Date: 2024-06-12T16:42:58-07:00 New Revision: ca91538c9c6f5328f398ac849dcc4230824b007e URL: https://github.com/llvm/llvm-project/commit/ca91538c9c6f5328f398ac849dcc4230824b007e DIFF: https://github.com/llvm/llvm-project/commit/ca91538c9c6f5328f398ac849dcc4230824b007e.diff LOG: [MC] Move AllowTemporaryLabels setting to MCContext::MCContext Also delete `AllowTemporaryLabels = true` from MCContext::reset: when llc supports -save-temp-labels in the next change, this assignment should be removed to support -compile-twice. Added: Modified: clang/tools/driver/cc1as_main.cpp llvm/lib/CodeGen/LLVMTargetMachine.cpp llvm/lib/MC/MCContext.cpp llvm/tools/llvm-ml/llvm-ml.cpp Removed: diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp index 4eb753a7297a9..ce1e181042609 100644 --- a/clang/tools/driver/cc1as_main.cpp +++ b/clang/tools/driver/cc1as_main.cpp @@ -429,6 +429,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation , MCOptions.MCRelaxAll = Opts.RelaxAll; MCOptions.EmitDwarfUnwind = Opts.EmitDwarfUnwind; MCOptions.EmitCompactUnwindNonCanonical = Opts.EmitCompactUnwindNonCanonical; + MCOptions.MCSaveTempLabels = Opts.SaveTemporaryLabels; MCOptions.X86RelaxRelocations = Opts.RelaxELFRelocations; MCOptions.CompressDebugSections = Opts.CompressDebugSections; MCOptions.AsSecureLogFile = Opts.AsSecureLogFile; @@ -483,8 +484,6 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation , MOFI->setDarwinTargetVariantSDKVersion(Opts.DarwinTargetVariantSDKVersion); Ctx.setObjectFileInfo(MOFI.get()); - if (Opts.SaveTemporaryLabels) -Ctx.setAllowTemporaryLabels(false); if (Opts.GenDwarfForAssembly) Ctx.setGenDwarfForAssembly(true); if (!Opts.DwarfDebugFlags.empty()) diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp index 94ab8ed442eb7..1d13173632833 100644 --- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp +++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp @@ -150,9 +150,6 @@ bool LLVMTargetMachine::addAsmPrinter(PassManagerBase , Expected> LLVMTargetMachine::createMCStreamer( raw_pwrite_stream , raw_pwrite_stream *DwoOut, CodeGenFileType FileType, MCContext ) { - if (Options.MCOptions.MCSaveTempLabels) -Context.setAllowTemporaryLabels(false); - const MCSubtargetInfo = *getMCSubtargetInfo(); const MCAsmInfo = *getMCAsmInfo(); const MCRegisterInfo = *getMCRegisterInfo(); @@ -272,8 +269,6 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase , MCContext *, // libunwind is unable to load compact unwind dynamically, so we must generate // DWARF unwind info for the JIT. Options.MCOptions.EmitDwarfUnwind = EmitDwarfUnwindType::Always; - if (Options.MCOptions.MCSaveTempLabels) -Ctx->setAllowTemporaryLabels(false); // Create the code emitter for the target if it exists. If not, .o file // emission fails. diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 1590054717960..fa1b095d42a29 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -74,6 +74,7 @@ MCContext::MCContext(const Triple , const MCAsmInfo *mai, InlineAsmUsedLabelNames(Allocator), CurrentDwarfLoc(0, 0, 0, DWARF2_FLAG_IS_STMT, 0, 0), AutoReset(DoAutoReset), TargetOptions(TargetOpts) { + AllowTemporaryLabels = !(TargetOptions && TargetOptions->MCSaveTempLabels); SecureLogFile = TargetOptions ? TargetOptions->AsSecureLogFile : ""; if (SrcMgr && SrcMgr->getNumBuffers()) @@ -179,7 +180,6 @@ void MCContext::reset() { ELFSeenGenericMergeableSections.clear(); NextID.clear(); - AllowTemporaryLabels = true; DwarfLocSeen = false; GenDwarfForAssembly = false; GenDwarfFileNumber = 0; diff --git a/llvm/tools/llvm-ml/llvm-ml.cpp b/llvm/tools/llvm-ml/llvm-ml.cpp index f1f39af059aa4..24643bd4296be 100644 --- a/llvm/tools/llvm-ml/llvm-ml.cpp +++ b/llvm/tools/llvm-ml/llvm-ml.cpp @@ -263,6 +263,7 @@ int llvm_ml_main(int Argc, char **Argv, const llvm::ToolContext &) { MCTargetOptions MCOptions; MCOptions.AssemblyLanguage = "masm"; MCOptions.MCFatalWarnings = InputArgs.hasArg(OPT_fatal_warnings); + MCOptions.MCSaveTempLabels = InputArgs.hasArg(OPT_save_temp_labels); Triple TheTriple = GetTriple(ProgName, InputArgs); std::string Error; @@ -330,9 +331,6 @@ int llvm_ml_main(int Argc, char **Argv, const llvm::ToolContext &) { Ctx, /*PIC=*/false, /*LargeCodeModel=*/true)); Ctx.setObjectFileInfo(MOFI.get()); - if (InputArgs.hasArg(OPT_save_temp_labels)) -Ctx.setAllowTemporaryLabels(false); - // Set compilation information. SmallString<128> CWD; if (!sys::fs::current_path(CWD)) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] (DRAFT) Another way to implement #92071: [HLSL] Default linkage of HLSL function should be internal (PR #95331)
https://github.com/hekota edited https://github.com/llvm/llvm-project/pull/95331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] (DRAFT) Another way to implement #92071: [HLSL] Default linkage of HLSL function should be internal (PR #95331)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 5d87ba1c1f584dfbd5afaf187099b43681b2206d f4fdb0eb680ab1ddf4f289bde30b1a72872b2f8d -- clang/lib/AST/ASTContext.cpp clang/lib/AST/Decl.cpp clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/CodeGen/CGHLSLRuntime.h clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/Sema/Sema.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index a06e7a2d19..041667ecbd 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -688,7 +688,7 @@ LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D, return LinkageInfo::internal(); } if (Context.getLangOpts().HLSL) { - return LinkageInfo::internal(); +return LinkageInfo::internal(); } // Set up the defaults. diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index b3ddb88be4..1186a055c9 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -953,7 +953,7 @@ static void checkUndefinedButUsed(Sema ) { Func->getIdentifier()->isMangledOpenMPVariantName(); } } - // Do not warn on undefined internal functions in HLSL, they will get + // Do not warn on undefined internal functions in HLSL, they will get // external linkage assigned during CodeGen if (S.getLangOpts().HLSL) continue; `` https://github.com/llvm/llvm-project/pull/95331 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)
krzysz00 wrote: Just a note - and maybe this was already discussed above - is there good reason not to explicitly make this type a 128-bit scalar? The LLVM data layout already does this https://github.com/llvm/llvm-project/pull/94830 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Expose `-fno-eliminate-unused-debug-types` to clang-cl (PR #95259)
https://github.com/aganea edited https://github.com/llvm/llvm-project/pull/95259 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
@@ -0,0 +1,95 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu verde -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu tonga -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +// CHECK-LABEL: @test_amdgcn_make_buffer_rsrc_p0( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr [[P:%.*]], i16 [[STRIDE:%.*]], i32 [[NUM:%.*]], i32 [[FLAGS:%.*]]) +// CHECK-NEXT:ret ptr addrspace(8) [[TMP0]] +// +__buffer_rsrc_t test_amdgcn_make_buffer_rsrc_p0(void *p, short stride, int num, int flags) { + return __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); krzysz00 wrote: The struct mentioned above is (if you pack it and make the second member an int32_t) a valid alternate means of implementing address space 7 I'd actually be willing to commit to making a buffer resource being 128 bits long, since that's already fixed in the LLVM data layout and since if that ever changes we'd need new builtins anyway https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [HLSL] Change default linkage of HLSL functions and `groupshared` variables (PR #93336)
@@ -108,3 +108,16 @@ behavior between Clang and DXC. Some examples include: diagnostic notifying the user of the conversion rather than silently altering precision relative to the other overloads (as FXC does) or generating code that will fail validation (as DXC does). + +Correctness improvements (bug fixes) + + +Entry point functions & ``static`` keyword +-- +Marking a shader entry point function ``static`` will result in an error. hekota wrote: Yes: https://github.com/llvm/llvm-project/blob/e80c59556d2d71cc2d0dcb2bd712c36cc4043025/clang/test/SemaHLSL/shader_type_attr.hlsl#L20-L22 https://github.com/llvm/llvm-project/pull/93336 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Expose `-fno-eliminate-unused-debug-types` to clang-cl (PR #95259)
https://github.com/amykhuang approved this pull request. Looks reasonable to me. https://github.com/llvm/llvm-project/pull/95259 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add support for Cortex-A725 and Cortex-X925 (PR #95214)
https://github.com/jthackray closed https://github.com/llvm/llvm-project/pull/95214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e80c595 - [AArch64] Add support for Cortex-A725 and Cortex-X925 (#95214)
Author: Jonathan Thackray Date: 2024-06-13T00:00:57+01:00 New Revision: e80c59556d2d71cc2d0dcb2bd712c36cc4043025 URL: https://github.com/llvm/llvm-project/commit/e80c59556d2d71cc2d0dcb2bd712c36cc4043025 DIFF: https://github.com/llvm/llvm-project/commit/e80c59556d2d71cc2d0dcb2bd712c36cc4043025.diff LOG: [AArch64] Add support for Cortex-A725 and Cortex-X925 (#95214) Cortex-A725 and Cortex-X925 are Armv9.2 AArch64 CPUs. Technical Reference Manual for Cortex-A725: https://developer.arm.com/documentation/107652/latest Technical Reference Manual for Cortex-X925: https://developer.arm.com/documentation/102807/latest Added: Modified: clang/docs/ReleaseNotes.rst clang/test/Driver/aarch64-mcpu.c clang/test/Misc/target-invalid-cpu-note.c llvm/docs/ReleaseNotes.rst llvm/include/llvm/TargetParser/AArch64TargetParser.h llvm/lib/Target/AArch64/AArch64Processors.td llvm/lib/Target/AArch64/AArch64Subtarget.cpp llvm/lib/TargetParser/Host.cpp llvm/unittests/TargetParser/TargetParserTest.cpp Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index cf1ba02cbc4b2..148ff05008552 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -903,11 +903,13 @@ Arm and AArch64 Support a feature modifier for -march and -mcpu as well as via target attributes like ``target_version`` or ``target_clones``. - Support has been added for the following processors (-mcpu identifiers in parenthesis): +* Arm Cortex-R52+ (cortex-r52plus). +* Arm Cortex-R82AE (cortex-r82ae). * Arm Cortex-A78AE (cortex-a78ae). * Arm Cortex-A520AE (cortex-a520ae). * Arm Cortex-A720AE (cortex-a720ae). -* Arm Cortex-R82AE (cortex-r82ae). -* Arm Cortex-R52+ (cortex-r52plus). +* Arm Cortex-A725 (cortex-a725). +* Arm Cortex-X925 (cortex-x925). * Arm Neoverse-N3 (neoverse-n3). * Arm Neoverse-V3 (neoverse-v3). * Arm Neoverse-V3AE (neoverse-v3ae). diff --git a/clang/test/Driver/aarch64-mcpu.c b/clang/test/Driver/aarch64-mcpu.c index ad4a5f9ac6fb8..97303510d6881 100644 --- a/clang/test/Driver/aarch64-mcpu.c +++ b/clang/test/Driver/aarch64-mcpu.c @@ -46,6 +46,8 @@ // CORTEXX3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x3" // RUN: %clang --target=aarch64 -mcpu=cortex-x4 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-X4 %s // CORTEX-X4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x4" +// RUN: %clang --target=aarch64 -mcpu=cortex-x925 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-X925 %s +// CORTEX-X925: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x925" // RUN: %clang --target=aarch64 -mcpu=cortex-a78 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEXA78 %s // CORTEXA78: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a78" // RUN: %clang --target=aarch64 -mcpu=cortex-a78c -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-A78C %s @@ -58,6 +60,8 @@ // CORTEX-A720: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a720" // RUN: %clang --target=aarch64 -mcpu=cortex-a720ae -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-A720AE %s // CORTEX-A720AE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a720ae" +// RUN: %clang --target=aarch64 -mcpu=cortex-a725 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-A725 %s +// CORTEX-A725: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a725" // RUN: %clang --target=aarch64 -mcpu=neoverse-e1 -### -c %s 2>&1 | FileCheck -check-prefix=NEOVERSE-E1 %s // NEOVERSE-E1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-e1" // RUN: %clang --target=aarch64 -mcpu=neoverse-v1 -### -c %s 2>&1 | FileCheck -check-prefix=NEOVERSE-V1 %s diff --git a/clang/test/Misc/target-invalid-cpu-note.c b/clang/test/Misc/target-invalid-cpu-note.c index 2439025609b9f..5362c6f882c25 100644 --- a/clang/test/Misc/target-invalid-cpu-note.c +++ b/clang/test/Misc/target-invalid-cpu-note.c @@ -5,11 +5,11 @@ // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AARCH64 // AARCH64: error: unknown target CPU 'not-a-cpu' -// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, cortex-a720ae, cortex-r82, cortex-r82ae, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-n3, neoverse-512tvb, neoverse-v1, neoverse-v2, neoverse-v3, neoverse-v3ae, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, apple-m2,
[clang] Bump the DWARF version number to 5 on Darwin. (PR #95164)
adrian-prantl wrote: Thanks! https://github.com/llvm/llvm-project/pull/95164 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang][Driver] Add HIPAMD Driver support for AMDGCN flavoured SPIR-V (PR #95061)
@@ -128,12 +128,13 @@ enum class CudaArch { GFX12_GENERIC, GFX1200, GFX1201, + AMDGCNSPIRV, Generic, // A processor model named 'generic' if the target backend defines a // public one. LAST, CudaDefault = CudaArch::SM_52, - HIPDefault = CudaArch::GFX906, + HIPDefault = CudaArch::AMDGCNSPIRV, AlexVlx wrote: Done. https://github.com/llvm/llvm-project/pull/95061 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "Bump the DWARF version number to 5 on Darwin." (PR #95325)
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-driver Author: Florian Mayer (fmayer) Changes Reverts llvm/llvm-project#95164 This broke a buildbot: https://lab.llvm.org/buildbot/#/builders/37/builds/35987 --- Full diff: https://github.com/llvm/llvm-project/pull/95325.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/Darwin.cpp (+1-11) - (modified) clang/test/Driver/debug-options.c (+1-26) ``diff diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index ca75a622b061e..ed5737915aa96 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1257,17 +1257,7 @@ unsigned DarwinClang::GetDefaultDwarfVersion() const { if ((isTargetMacOSBased() && isMacosxVersionLT(10, 11)) || (isTargetIOSBased() && isIPhoneOSVersionLT(9))) return 2; - // Default to use DWARF 4 on OS X 10.11 - macOS 14 / iOS 9 - iOS 17. - if ((isTargetMacOSBased() && isMacosxVersionLT(15)) || - (isTargetIOSBased() && isIPhoneOSVersionLT(18)) || - (isTargetWatchOSBased() && TargetVersion < llvm::VersionTuple(11)) || - (isTargetXROS() && TargetVersion < llvm::VersionTuple(2)) || - (isTargetDriverKit() && TargetVersion < llvm::VersionTuple(24)) || - (isTargetMacOSBased() && - TargetVersion.empty()) || // apple-darwin, no version. - (TargetPlatform == llvm::Triple::BridgeOS)) -return 4; - return 5; + return 4; } void MachO::AddLinkRuntimeLib(const ArgList , ArgStringList , diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index 0a665f7017d63..07f6ca9e3902f 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -68,32 +68,7 @@ // RUN: %clang -### -c -g %s -target x86_64-apple-driverkit19.0 2>&1 \ // RUN: | FileCheck -check-prefix=G_STANDALONE \ // RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -g %s -target x86_64-apple-macosx15 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64-apple-ios17.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -g %s -target arm64-apple-ios18.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64_32-apple-watchos11 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64-apple-tvos18.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target x86_64-apple-driverkit24.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64-apple-xros1 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -g %s -target arm64-apple-xros2 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// -// RUN: %clang -### -c -fsave-optimization-record %s\ +// RUN: %clang -### -c -fsave-optimization-record %s \ // RUN:-target x86_64-apple-darwin 2>&1 \ // RUN: | FileCheck -check-prefix=GLTO_ONLY %s // RUN: %clang -### -c -g -fsave-optimization-record %s \ `` https://github.com/llvm/llvm-project/pull/95325 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "Bump the DWARF version number to 5 on Darwin." (PR #95325)
https://github.com/fmayer closed https://github.com/llvm/llvm-project/pull/95325 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] fcc4935 - Revert "Bump the DWARF version number to 5 on Darwin." (#95325)
Author: Florian Mayer Date: 2024-06-12T15:50:30-07:00 New Revision: fcc4935560720556defff25a9bd4fc44ffa3135b URL: https://github.com/llvm/llvm-project/commit/fcc4935560720556defff25a9bd4fc44ffa3135b DIFF: https://github.com/llvm/llvm-project/commit/fcc4935560720556defff25a9bd4fc44ffa3135b.diff LOG: Revert "Bump the DWARF version number to 5 on Darwin." (#95325) Reverts llvm/llvm-project#95164 This broke a buildbot: https://lab.llvm.org/buildbot/#/builders/37/builds/35987 Added: Modified: clang/lib/Driver/ToolChains/Darwin.cpp clang/test/Driver/debug-options.c Removed: diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index ca75a622b061e..ed5737915aa96 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1257,17 +1257,7 @@ unsigned DarwinClang::GetDefaultDwarfVersion() const { if ((isTargetMacOSBased() && isMacosxVersionLT(10, 11)) || (isTargetIOSBased() && isIPhoneOSVersionLT(9))) return 2; - // Default to use DWARF 4 on OS X 10.11 - macOS 14 / iOS 9 - iOS 17. - if ((isTargetMacOSBased() && isMacosxVersionLT(15)) || - (isTargetIOSBased() && isIPhoneOSVersionLT(18)) || - (isTargetWatchOSBased() && TargetVersion < llvm::VersionTuple(11)) || - (isTargetXROS() && TargetVersion < llvm::VersionTuple(2)) || - (isTargetDriverKit() && TargetVersion < llvm::VersionTuple(24)) || - (isTargetMacOSBased() && - TargetVersion.empty()) || // apple-darwin, no version. - (TargetPlatform == llvm::Triple::BridgeOS)) -return 4; - return 5; + return 4; } void MachO::AddLinkRuntimeLib(const ArgList , ArgStringList , diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index 0a665f7017d63..07f6ca9e3902f 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -68,32 +68,7 @@ // RUN: %clang -### -c -g %s -target x86_64-apple-driverkit19.0 2>&1 \ // RUN: | FileCheck -check-prefix=G_STANDALONE \ // RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -g %s -target x86_64-apple-macosx15 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64-apple-ios17.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -g %s -target arm64-apple-ios18.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64_32-apple-watchos11 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64-apple-tvos18.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target x86_64-apple-driverkit24.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64-apple-xros1 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -g %s -target arm64-apple-xros2 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// -// RUN: %clang -### -c -fsave-optimization-record %s\ +// RUN: %clang -### -c -fsave-optimization-record %s \ // RUN:-target x86_64-apple-darwin 2>&1 \ // RUN: | FileCheck -check-prefix=GLTO_ONLY %s // RUN: %clang -### -c -g -fsave-optimization-record %s \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Revert "Bump the DWARF version number to 5 on Darwin." (PR #95325)
https://github.com/fmayer created https://github.com/llvm/llvm-project/pull/95325 Reverts llvm/llvm-project#95164 This broke a buildbot: https://lab.llvm.org/buildbot/#/builders/37/builds/35987 >From fc671bbb1ceb94f8aac63bc0e4963e5894bc660e Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Wed, 12 Jun 2024 15:50:03 -0700 Subject: [PATCH] Revert "Bump the DWARF version number to 5 on Darwin. (#95164)" This reverts commit 8f6acd973a38da6dce45faa676cbb51da37f72e5. --- clang/lib/Driver/ToolChains/Darwin.cpp | 12 +--- clang/test/Driver/debug-options.c | 27 +- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index ca75a622b061e..ed5737915aa96 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1257,17 +1257,7 @@ unsigned DarwinClang::GetDefaultDwarfVersion() const { if ((isTargetMacOSBased() && isMacosxVersionLT(10, 11)) || (isTargetIOSBased() && isIPhoneOSVersionLT(9))) return 2; - // Default to use DWARF 4 on OS X 10.11 - macOS 14 / iOS 9 - iOS 17. - if ((isTargetMacOSBased() && isMacosxVersionLT(15)) || - (isTargetIOSBased() && isIPhoneOSVersionLT(18)) || - (isTargetWatchOSBased() && TargetVersion < llvm::VersionTuple(11)) || - (isTargetXROS() && TargetVersion < llvm::VersionTuple(2)) || - (isTargetDriverKit() && TargetVersion < llvm::VersionTuple(24)) || - (isTargetMacOSBased() && - TargetVersion.empty()) || // apple-darwin, no version. - (TargetPlatform == llvm::Triple::BridgeOS)) -return 4; - return 5; + return 4; } void MachO::AddLinkRuntimeLib(const ArgList , ArgStringList , diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index 0a665f7017d63..07f6ca9e3902f 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -68,32 +68,7 @@ // RUN: %clang -### -c -g %s -target x86_64-apple-driverkit19.0 2>&1 \ // RUN: | FileCheck -check-prefix=G_STANDALONE \ // RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -g %s -target x86_64-apple-macosx15 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64-apple-ios17.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -g %s -target arm64-apple-ios18.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64_32-apple-watchos11 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64-apple-tvos18.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target x86_64-apple-driverkit24.0 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// RUN: %clang -### -c -g %s -target arm64-apple-xros1 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -g %s -target arm64-apple-xros2 2>&1 \ -// RUN: | FileCheck -check-prefix=G_STANDALONE \ -// RUN: -check-prefix=G_DWARF5 %s -// -// RUN: %clang -### -c -fsave-optimization-record %s\ +// RUN: %clang -### -c -fsave-optimization-record %s \ // RUN:-target x86_64-apple-darwin 2>&1 \ // RUN: | FileCheck -check-prefix=GLTO_ONLY %s // RUN: %clang -### -c -g -fsave-optimization-record %s \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Bump the DWARF version number to 5 on Darwin. (PR #95164)
fmayer wrote: This broke our buildbot: https://lab.llvm.org/buildbot/#/builders/37/builds/35987 ``` FAILED: tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/Darwin.cpp.o CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /b/sanitizer-x86_64-linux/build/llvm_build0/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/sanitizer-x86_64-linux/build/build_symbolizer/tools/clang/lib/Driver -I/b/sanitizer-x86_64-linux/build/llvm-project/clang/lib/Driver -I/b/sanitizer-x86_64-linux/build/llvm-project/clang/include -I/b/sanitizer-x86_64-linux/build/build_symbolizer/tools/clang/include -I/b/sanitizer-x86_64-linux/build/build_symbolizer/include -I/b/sanitizer-x86_64-linux/build/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/Darwin.cpp.o -MF tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/Darwin.cpp.o.d -o tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/Darwin.cpp.o -c /b/sanitizer-x86_64-linux/build/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp /b/sanitizer-x86_64-linux/build/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp:1268:23: error: comparison of different enumeration types ('DarwinPlatformKind' and 'llvm::Triple::OSType') [-Werror,-Wenum-compare] 1268 | (TargetPlatform == llvm::Triple::BridgeOS)) |~~ ^ ~~ /b/sanitizer-x86_64-linux/build/llvm-project/clang/lib/Driver/ToolChains/Darwin.cpp:1268:23: error: result of comparison of constant 'BridgeOS' (28) with expression of type 'DarwinPlatformKind' is always false [-Werror,-Wtautological-constant-out-of-range-compare] 1268 | (TargetPlatform == llvm::Triple::BridgeOS)) |~~ ^ ~~ 2 errors generated. ninja: build stopped: subcommand failed. ``` https://github.com/llvm/llvm-project/pull/95164 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)
delcypher wrote: @pdherbemont Could you take a look at this? https://github.com/llvm/llvm-project/pull/94216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)
delcypher wrote: Reverted in c9d580033f29196223cd56a0fa238c3ba51d23e4 https://github.com/llvm/llvm-project/pull/94216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c9d5800 - Revert "Support `guarded_by` attribute and related attributes inside C structs and support late parsing them (#94216)"
Author: Dan Liew Date: 2024-06-12T15:43:12-07:00 New Revision: c9d580033f29196223cd56a0fa238c3ba51d23e4 URL: https://github.com/llvm/llvm-project/commit/c9d580033f29196223cd56a0fa238c3ba51d23e4 DIFF: https://github.com/llvm/llvm-project/commit/c9d580033f29196223cd56a0fa238c3ba51d23e4.diff LOG: Revert "Support `guarded_by` attribute and related attributes inside C structs and support late parsing them (#94216)" This reverts commit af0d7128c8fd053d3de8af208d7d1682bc7a525a. Reverting due to likely regression: https://github.com/llvm/llvm-project/pull/94216#issuecomment-2164013300 Added: Modified: clang/docs/ReleaseNotes.rst clang/docs/ThreadSafetyAnalysis.rst clang/include/clang/Basic/Attr.td clang/include/clang/Parse/Parser.h clang/include/clang/Sema/Sema.h clang/lib/Parse/ParseDecl.cpp clang/lib/Sema/SemaExpr.cpp clang/test/AST/ast-dump-color.cpp clang/test/Sema/warn-thread-safety-analysis.c clang/test/SemaCXX/warn-thread-safety-parsing.cpp Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index f17603a161668..cf1ba02cbc4b2 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -471,10 +471,6 @@ Attribute Changes in Clang size_t count; }; -- The ``guarded_by``, ``pt_guarded_by``, ``acquired_after``, ``acquired_before`` - attributes now support referencing struct members in C. The arguments are also - now late parsed when ``-fexperimental-late-parse-attributes`` is passed like - for ``counted_by``. Improvements to Clang's diagnostics --- diff --git a/clang/docs/ThreadSafetyAnalysis.rst b/clang/docs/ThreadSafetyAnalysis.rst index 6eefa306e3c89..dcde0c706c704 100644 --- a/clang/docs/ThreadSafetyAnalysis.rst +++ b/clang/docs/ThreadSafetyAnalysis.rst @@ -764,6 +764,12 @@ doesn't know that munl.mu == mutex. The SCOPED_CAPABILITY attribute handles aliasing for MutexLocker, but does so only for that particular pattern. +ACQUIRED_BEFORE(...) and ACQUIRED_AFTER(...) are currently unimplemented. +- + +To be fixed in a future update. + + .. _mutexheader: mutex.h diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 6032b934279dd..b70b0c8b836a5 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -3633,7 +3633,7 @@ def NoThreadSafetyAnalysis : InheritableAttr { def GuardedBy : InheritableAttr { let Spellings = [GNU<"guarded_by">]; let Args = [ExprArgument<"Arg">]; - let LateParsed = LateAttrParseExperimentalExt; + let LateParsed = LateAttrParseStandard; let TemplateDependent = 1; let ParseArgumentsAsUnevaluated = 1; let InheritEvenIfAlreadyPresent = 1; @@ -3644,7 +3644,7 @@ def GuardedBy : InheritableAttr { def PtGuardedBy : InheritableAttr { let Spellings = [GNU<"pt_guarded_by">]; let Args = [ExprArgument<"Arg">]; - let LateParsed = LateAttrParseExperimentalExt; + let LateParsed = LateAttrParseStandard; let TemplateDependent = 1; let ParseArgumentsAsUnevaluated = 1; let InheritEvenIfAlreadyPresent = 1; @@ -3655,7 +3655,7 @@ def PtGuardedBy : InheritableAttr { def AcquiredAfter : InheritableAttr { let Spellings = [GNU<"acquired_after">]; let Args = [VariadicExprArgument<"Args">]; - let LateParsed = LateAttrParseExperimentalExt; + let LateParsed = LateAttrParseStandard; let TemplateDependent = 1; let ParseArgumentsAsUnevaluated = 1; let InheritEvenIfAlreadyPresent = 1; @@ -3666,7 +3666,7 @@ def AcquiredAfter : InheritableAttr { def AcquiredBefore : InheritableAttr { let Spellings = [GNU<"acquired_before">]; let Args = [VariadicExprArgument<"Args">]; - let LateParsed = LateAttrParseExperimentalExt; + let LateParsed = LateAttrParseStandard; let TemplateDependent = 1; let ParseArgumentsAsUnevaluated = 1; let InheritEvenIfAlreadyPresent = 1; diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index 9e11078382756..d054b8cf0d240 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -3128,20 +3128,6 @@ class Parser : public CodeCompletionHandler { IdentifierInfo *ScopeName, SourceLocation ScopeLoc, ParsedAttr::Form Form); - void ParseGuardedByAttribute(IdentifierInfo , - SourceLocation AttrNameLoc, - ParsedAttributes , - IdentifierInfo *ScopeName, - SourceLocation ScopeLoc, SourceLocation *EndLoc, - ParsedAttr::Form Form); - - void ParseAcquiredAttribute(IdentifierInfo , - SourceLocation AttrNameLoc, -
[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)
delcypher wrote: @aeubanks I'll revert. Is this example C or C++? https://github.com/llvm/llvm-project/pull/94216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)
aeubanks wrote: reduced: ``` struct Lock {}; struct A { Lock lock; union { bool b __attribute__((guarded_by(lock))); }; }; ``` seems like a regression, can we revert for now? https://github.com/llvm/llvm-project/pull/94216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AMDGPU] Add a builtin for llvm.amdgcn.make.buffer.rsrc intrinsic (PR #95276)
@@ -0,0 +1,95 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py +// REQUIRES: amdgpu-registered-target +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu verde -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu tonga -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -cl-std=CL2.0 -target-cpu gfx1100 -emit-llvm -o - %s | FileCheck %s + +// CHECK-LABEL: @test_amdgcn_make_buffer_rsrc_p0( +// CHECK-NEXT: entry: +// CHECK-NEXT:[[TMP0:%.*]] = tail call ptr addrspace(8) @llvm.amdgcn.make.buffer.rsrc.p0(ptr [[P:%.*]], i16 [[STRIDE:%.*]], i32 [[NUM:%.*]], i32 [[FLAGS:%.*]]) +// CHECK-NEXT:ret ptr addrspace(8) [[TMP0]] +// +__buffer_rsrc_t test_amdgcn_make_buffer_rsrc_p0(void *p, short stride, int num, int flags) { + return __builtin_amdgcn_make_buffer_rsrc(p, stride, num, flags); arsenm wrote: The alternative would be to have a builtin address space fat pointer, but I assume that will be substantially more implementation work. https://github.com/llvm/llvm-project/pull/95276 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)
aeubanks wrote: this seems to have broken code like [this](https://crsrc.org/c/base/allocator/partition_allocator/src/partition_alloc/random.cc;drc=36293863bf9bbc8131797eb8f4d2bafe8af3de79;l=33) with ``` ../../base/allocator/partition_allocator/src/partition_alloc/random.cc:33:69: error: invalid use of non-static data member 'lock_' 33 | internal::base::InsecureRandomGenerator instance_ PA_GUARDED_BY(lock_); | ^ ../../base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/thread_annotations.h:59:70: note: expanded from macro 'PA_GUARDED_BY' 59 | #define PA_GUARDED_BY(x) PA_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) | ^ ../../base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/thread_annotations.h:44:60: note: expanded from macro 'PA_THREAD_ANNOTATION_ATTRIBUTE__' 44 | #define PA_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) |^ ../../base/allocator/partition_allocator/src/partition_alloc/random.cc:35:65: error: invalid use of non-static data member 'lock_' 35 | internal::base::InsecureRandomGenerator)] PA_GUARDED_BY(lock_) = {}; | ^ ../../base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/thread_annotations.h:59:70: note: expanded from macro 'PA_GUARDED_BY' 59 | #define PA_GUARDED_BY(x) PA_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x)) | ^ ../../base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/thread_annotations.h:44:60: note: expanded from macro 'PA_THREAD_ANNOTATION_ATTRIBUTE__' 44 | #define PA_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x)) |^ ``` is that intentional? https://github.com/llvm/llvm-project/pull/94216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)
@@ -9434,6 +9505,32 @@ ASTContext::getSubstTemplateTemplateParmPack(const TemplateArgument , return TemplateName(Subst); } +/// Retrieve the template name that represents a template name +/// deduced from a specialization. +TemplateName +ASTContext::getDeducedTemplateName(TemplateName Underlying, + DefaultArguments DefaultArgs) const { + if (!DefaultArgs) +return Underlying; + + auto = const_cast(*this); mizvekov wrote: This is done throughout the ASTContext and is not novel here. We wish to be able to create a new node from a const ASTContext reference. These creation functions mostly behave const-ish, they just use hash tables in the ASTContext for caching / identity purposes. The other alternative is to declare these hash tables as mutable, though this would necessitate a large noisy change to update everything at once. https://github.com/llvm/llvm-project/pull/94981 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (PR #94559)
farzonl wrote: @aeubanks The issue you are seeing here is because only aarch64 and x86 backends have tan intrinsic lowering support. This shouldn't be a regression because there never was a llvm.tan.v2f32 for ARMv7. That still needs to be add. Can you show me how you could have generated `llvm.tan.v2f32` for armv7 from clang? By default [TargetLoweringBase.cpp:1016-1022](https://github.com/llvm/llvm-project/blob/8f6acd973a38da6dce45faa676cbb51da37f72e5/llvm/lib/CodeGen/TargetLoweringBase.cpp#L1016C3-L1022C1) only supports lowering form f32, f64, and f128 scalars across all backends. The builtins that were added (`Builtin::BItanf`, `Builtin::BItanl`, `Builtin::BI__builtin_tan`, `Builtin::BI__builtin_tanf`, `Builtin::BI__builtin_tanf16`, `Builtin::BI__builtin_tanl`, and `Builtin::BI__builtin_tanf128`) should only cover scalar cases. So i'm not sure how this pr could have generate the intrinsic you have reported. https://github.com/llvm/llvm-project/pull/94559 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)
@@ -6371,6 +6376,70 @@ ASTContext::getCanonicalTemplateName(const TemplateName ) const { canonArgPack, subst->getAssociatedDecl()->getCanonicalDecl(), subst->getFinal(), subst->getIndex()); } + case TemplateName::DeducedTemplate: { +assert(IgnoreDeduced == false); +DeducedTemplateStorage *DTS = Name.getAsDeducedTemplateName(); +DefaultArguments DefArgs = DTS->getDefaultArguments(); +TemplateName Underlying = DTS->getUnderlying(); + +bool NonCanonical = false; +TemplateName CanonUnderlying = +getCanonicalTemplateName(Underlying, /*IgnoreDeduced=*/true); +NonCanonical |= CanonUnderlying != Underlying; +auto CanonArgs = +getCanonicalTemplateArguments(*this, DefArgs.Args, NonCanonical); +{ + unsigned NumArgs = CanonArgs.size() - 1; + auto handleParamDefArg = [&](const TemplateArgument , + unsigned I) { +auto CanonParamDefArg = getCanonicalTemplateArgument(ParamDefArg); +TemplateArgument = CanonArgs[I]; +if (CanonDefArg.structurallyEquals(CanonParamDefArg)) + return; +if (I == NumArgs) + CanonArgs.pop_back(); +NonCanonical = true; + }; + auto handleParam = [&](auto *TP, int I) -> bool { +if (!TP->hasDefaultArgument()) + return true; +handleParamDefArg(TP->getDefaultArgument().getArgument(), I); +return false; + }; + + ArrayRef Params = CanonUnderlying.getAsTemplateDecl() + ->getTemplateParameters() + ->asArray(); + assert(CanonArgs.size() <= Params.size()); + for (int I = NumArgs; I >= 0; --I) { mizvekov wrote: The code is correct, but the variable name is not right. Should have been `LastArgIndex` or some such. https://github.com/llvm/llvm-project/pull/94981 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)
@@ -6371,6 +6376,70 @@ ASTContext::getCanonicalTemplateName(const TemplateName ) const { canonArgPack, subst->getAssociatedDecl()->getCanonicalDecl(), subst->getFinal(), subst->getIndex()); } + case TemplateName::DeducedTemplate: { +assert(IgnoreDeduced == false); +DeducedTemplateStorage *DTS = Name.getAsDeducedTemplateName(); +DefaultArguments DefArgs = DTS->getDefaultArguments(); +TemplateName Underlying = DTS->getUnderlying(); mizvekov wrote: They are pointer sized, it's the same as a QualType, and we never take those by reference either. https://github.com/llvm/llvm-project/pull/94981 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add winsysroot alias to the GNU driver (PR #95320)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (Andarwinux) Changes fixes #91216 --- Full diff: https://github.com/llvm/llvm-project/pull/95320.diff 1 Files Affected: - (modified) clang/include/clang/Driver/Options.td (+2) ``diff diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index d44faa55c456f..1cce7a5146dd8 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8569,6 +8569,8 @@ def : Separate<["-"], "Xmicrosoft-windows-sdk-root">, Alias<_SLASH_winsdkdir>; def : Separate<["-"], "Xmicrosoft-windows-sdk-version">, Alias<_SLASH_winsdkversion>; +def : Separate<["-"], "Xmicrosoft-windows-sys-root">, +Alias<_SLASH_winsysroot>; // Ignored: `` https://github.com/llvm/llvm-project/pull/95320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add winsysroot alias to the GNU driver (PR #95320)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/95320 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add winsysroot alias to the GNU driver (PR #95320)
https://github.com/Andarwinux updated https://github.com/llvm/llvm-project/pull/95320 >From f71020889c8276e975336f921f647c9ab9863651 Mon Sep 17 00:00:00 2001 From: Andarwinux <144242044+andarwi...@users.noreply.github.com> Date: Fri, 7 Jun 2024 07:07:40 + Subject: [PATCH] [Driver] Add winsysroot alias to the GNU driver fixes #91216 --- clang/include/clang/Driver/Options.td | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index d44faa55c456f..1cce7a5146dd8 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8569,6 +8569,8 @@ def : Separate<["-"], "Xmicrosoft-windows-sdk-root">, Alias<_SLASH_winsdkdir>; def : Separate<["-"], "Xmicrosoft-windows-sdk-version">, Alias<_SLASH_winsdkversion>; +def : Separate<["-"], "Xmicrosoft-windows-sys-root">, +Alias<_SLASH_winsysroot>; // Ignored: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add winsysroot alias to the GNU driver (PR #95320)
https://github.com/Andarwinux created https://github.com/llvm/llvm-project/pull/95320 fixes #91216 >From f7f12f9b026c0c290456d403d59911734ba05b57 Mon Sep 17 00:00:00 2001 From: Andarwinux <144242044+andarwi...@users.noreply.github.com> Date: Fri, 7 Jun 2024 07:07:40 + Subject: [PATCH] [Driver] Add winsysroot alias to the GNU driver fixes #91216 --- clang/include/clang/Driver/Options.td | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 9f7904dd94b94..a512e5385d532 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -8575,6 +8575,8 @@ def : Separate<["-"], "Xmicrosoft-windows-sdk-root">, Alias<_SLASH_winsdkdir>; def : Separate<["-"], "Xmicrosoft-windows-sdk-version">, Alias<_SLASH_winsdkversion>; +def : Separate<["-"], "Xmicrosoft-windows-sys-root">, +Alias<_SLASH_winsysroot>; // Ignored: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Driver] Add winsysroot alias to the GNU driver (PR #94731)
https://github.com/Andarwinux closed https://github.com/llvm/llvm-project/pull/94731 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][TargetParser] move CPUInfo into tablegen [NFC] (PR #92145)
https://github.com/jthackray approved this pull request. LGTM, assuming it causes no regressions. https://github.com/llvm/llvm-project/pull/92145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Bump the DWARF version number to 5 on Darwin. (PR #95164)
https://github.com/adrian-prantl closed https://github.com/llvm/llvm-project/pull/95164 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8f6acd9 - Bump the DWARF version number to 5 on Darwin. (#95164)
Author: Adrian Prantl Date: 2024-06-12T14:36:56-07:00 New Revision: 8f6acd973a38da6dce45faa676cbb51da37f72e5 URL: https://github.com/llvm/llvm-project/commit/8f6acd973a38da6dce45faa676cbb51da37f72e5 DIFF: https://github.com/llvm/llvm-project/commit/8f6acd973a38da6dce45faa676cbb51da37f72e5.diff LOG: Bump the DWARF version number to 5 on Darwin. (#95164) The default debug info format for newer versions of Darwin is DWARF 5. https://developer.apple.com/documentation/xcode-release-notes/xcode-16-release-notes rdar://110925733 Added: Modified: clang/lib/Driver/ToolChains/Darwin.cpp clang/test/Driver/debug-options.c Removed: diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index ed5737915aa96..ca75a622b061e 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1257,7 +1257,17 @@ unsigned DarwinClang::GetDefaultDwarfVersion() const { if ((isTargetMacOSBased() && isMacosxVersionLT(10, 11)) || (isTargetIOSBased() && isIPhoneOSVersionLT(9))) return 2; - return 4; + // Default to use DWARF 4 on OS X 10.11 - macOS 14 / iOS 9 - iOS 17. + if ((isTargetMacOSBased() && isMacosxVersionLT(15)) || + (isTargetIOSBased() && isIPhoneOSVersionLT(18)) || + (isTargetWatchOSBased() && TargetVersion < llvm::VersionTuple(11)) || + (isTargetXROS() && TargetVersion < llvm::VersionTuple(2)) || + (isTargetDriverKit() && TargetVersion < llvm::VersionTuple(24)) || + (isTargetMacOSBased() && + TargetVersion.empty()) || // apple-darwin, no version. + (TargetPlatform == llvm::Triple::BridgeOS)) +return 4; + return 5; } void MachO::AddLinkRuntimeLib(const ArgList , ArgStringList , diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index 07f6ca9e3902f..0a665f7017d63 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/test/Driver/debug-options.c @@ -68,7 +68,32 @@ // RUN: %clang -### -c -g %s -target x86_64-apple-driverkit19.0 2>&1 \ // RUN: | FileCheck -check-prefix=G_STANDALONE \ // RUN: -check-prefix=G_DWARF4 %s -// RUN: %clang -### -c -fsave-optimization-record %s \ +// RUN: %clang -### -c -g %s -target x86_64-apple-macosx15 2>&1 \ +// RUN: | FileCheck -check-prefix=G_STANDALONE \ +// RUN: -check-prefix=G_DWARF5 %s +// RUN: %clang -### -c -g %s -target arm64-apple-ios17.0 2>&1 \ +// RUN: | FileCheck -check-prefix=G_STANDALONE \ +// RUN: -check-prefix=G_DWARF4 %s +// RUN: %clang -### -c -g %s -target arm64-apple-ios18.0 2>&1 \ +// RUN: | FileCheck -check-prefix=G_STANDALONE \ +// RUN: -check-prefix=G_DWARF5 %s +// RUN: %clang -### -c -g %s -target arm64_32-apple-watchos11 2>&1 \ +// RUN: | FileCheck -check-prefix=G_STANDALONE \ +// RUN: -check-prefix=G_DWARF5 %s +// RUN: %clang -### -c -g %s -target arm64-apple-tvos18.0 2>&1 \ +// RUN: | FileCheck -check-prefix=G_STANDALONE \ +// RUN: -check-prefix=G_DWARF5 %s +// RUN: %clang -### -c -g %s -target x86_64-apple-driverkit24.0 2>&1 \ +// RUN: | FileCheck -check-prefix=G_STANDALONE \ +// RUN: -check-prefix=G_DWARF5 %s +// RUN: %clang -### -c -g %s -target arm64-apple-xros1 2>&1 \ +// RUN: | FileCheck -check-prefix=G_STANDALONE \ +// RUN: -check-prefix=G_DWARF4 %s +// RUN: %clang -### -c -g %s -target arm64-apple-xros2 2>&1 \ +// RUN: | FileCheck -check-prefix=G_STANDALONE \ +// RUN: -check-prefix=G_DWARF5 %s +// +// RUN: %clang -### -c -fsave-optimization-record %s\ // RUN:-target x86_64-apple-darwin 2>&1 \ // RUN: | FileCheck -check-prefix=GLTO_ONLY %s // RUN: %clang -### -c -g -fsave-optimization-record %s \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits