[clang] [llvm] [Transforms][Utils][PromoteMem2Reg] Propagate nnan flag on par with the nsz flag (PR #114271)
pawosm-arm wrote: > We should probably also handle `no-infs-fp-math` to save the next person the > trouble. I'd leave it to a separate PR, as this one has a specific story behind the proposed change, anything extra would go beyond it. https://github.com/llvm/llvm-project/pull/114271 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix the post-filtering heuristic for GSLPointer. (PR #114044)
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/114044 >From 1252cfdea59e94a91750a49fd5aaab4a6c2650b6 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Fri, 1 Nov 2024 16:51:03 +0100 Subject: [PATCH 1/3] [clang] Fix the post-filtering heuristics for GSLPointer case. --- clang/docs/ReleaseNotes.rst | 2 + clang/lib/Sema/CheckExprLifetime.cpp | 113 ++ .../Sema/warn-lifetime-analysis-nocfg.cpp | 48 +++- 3 files changed, 139 insertions(+), 24 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 4e555914caee8a..166aeb1bf6f3da 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -464,6 +464,8 @@ Improvements to Clang's diagnostics - Clang now diagnoses ``[[deprecated]]`` attribute usage on local variables (#GH90073). +- Fix false positives when `[[gsl::Owner/Pointer]]` and `[[clang::lifetimebound]]` are used together. + Improvements to Clang's time-trace -- diff --git a/clang/lib/Sema/CheckExprLifetime.cpp b/clang/lib/Sema/CheckExprLifetime.cpp index a1a402b4a2b530..d1e8cc9f9b075c 100644 --- a/clang/lib/Sema/CheckExprLifetime.cpp +++ b/clang/lib/Sema/CheckExprLifetime.cpp @@ -1093,6 +1093,87 @@ static bool pathOnlyHandlesGslPointer(const IndirectLocalPath &Path) { } return false; } +// Result of analyzing the Path for GSLPointer. +enum AnalysisResult { + // Path does not correspond to a GSLPointer. + NotGSLPointer, + + // A relevant case was identified. + Report, + // Stop the entire traversal. + Abandon, + // Skip this step and continue traversing inner AST nodes. + Skip, +}; +// Analyze cases where a GSLPointer is initialized or assigned from a +// temporary owner object. +static AnalysisResult analyzePathForGSLPointer(const IndirectLocalPath &Path, + Local L) { + if (!pathOnlyHandlesGslPointer(Path)) +return NotGSLPointer; + + // At this point, Path represents a series of operations involving a + // GSLPointer, either in the process of initialization or assignment. + + // Note: A LifetimeBoundCall can appear interleaved in this sequence. + // For example: + //const std::string& Ref(const std::string& a [[clang::lifetimebound]]); + //string_view abc = Ref(std::string()); + // The "Path" is [GSLPointerInit, LifetimeboundCall], where "L" is the + // temporary "std::string()" object. We need to check if the function with the + // lifetimebound attribute returns a "owner" type. + if (Path.back().Kind == IndirectLocalPathEntry::LifetimeBoundCall) { +// The lifetimebound applies to the implicit object parameter of a method. +if (const auto *Method = llvm::dyn_cast(Path.back().D)) { + if (Method->getReturnType()->isReferenceType() && + isRecordWithAttr( + Method->getReturnType()->getPointeeType())) +return Report; + return Abandon; +} +// The lifetimebound applies to a function parameter. +const auto *PD = llvm::dyn_cast(Path.back().D); +if (const auto *FD = llvm::dyn_cast(PD->getDeclContext())) { + if (isa(FD)) { +// Constructor case: the parameter is annotated with lifetimebound +// e.g., GSLPointer(const S& s [[clang::lifetimebound]]) +// We still respect this case even the type S is not an owner. +return Report; + } + // For regular functions, check if the return type has an Owner attribute. + // e.g., const GSLOwner& func(const Foo& foo [[clang::lifetimebound]]) + if (FD->getReturnType()->isReferenceType() && + isRecordWithAttr(FD->getReturnType()->getPointeeType())) +return Report; +} +return Abandon; + } + + if (isa(L)) { +// We do not want to follow the references when returning a pointer +// originating from a local owner to avoid the following false positive: +// int &p = *localUniquePtr; +// someContainer.add(std::move(localUniquePtr)); +// return p; +if (!pathContainsInit(Path) && isRecordWithAttr(L->getType())) + return Report; +return Abandon; + } + + // The GSLPointer is from a temporary object. + auto *MTE = dyn_cast(L); + + bool IsGslPtrValueFromGslTempOwner = + MTE && !MTE->getExtendingDecl() && + isRecordWithAttr(MTE->getType()); + // Skipping a chain of initializing gsl::Pointer annotated objects. + // We are looking only for the final source to find out if it was + // a local or temporary owner or the address of a local + // variable/param. + if (!IsGslPtrValueFromGslTempOwner) +return Skip; + return Report; +} static bool isAssignmentOperatorLifetimeBound(CXXMethodDecl *CMD) { if (!CMD) @@ -1131,27 +1212,17 @@ static void checkExprLifetimeImpl(Sema &SemaRef, auto *MTE = dyn_cast(L); -bool IsGslPtrValueFromGslTempOwner = false; -if (pathOnlyHandlesGslPointer(Path)) { - if (isa(L))
[clang] [llvm] [Transforms][Utils][PromoteMem2Reg] Propagate nnan flag on par with the nsz flag (PR #114271)
paulwalker-arm wrote: > Yet we see a value in the change proposed here too hence a good reason for > merging it. I've clearly misunderstood the context of the rebase. What is the value in merging this change if the original issue has already been resolved? I guess this fix is simpler and thus might help compiler time but then that wasn't the original intent. https://github.com/llvm/llvm-project/pull/114271 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Add Mariya as maintainer for constant expressions & Sema (PR #114974)
https://github.com/AaronBallman created https://github.com/llvm/llvm-project/pull/114974 Mariya has extensive knowledge of the constant expression evaluator and has done a lot of reviewing in Sema over the past year or so. >From 4c1e1ac48afe4f873355c7e8a7e54f7506ab1014 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Tue, 5 Nov 2024 07:19:32 -0500 Subject: [PATCH] Add Mariya as maintainer for constant expressions & Sema Mariya has extensive knowledge of the constant expression evaluator and has done a lot of reviewing in Sema over the past year or so. --- clang/Maintainers.rst | 9 + 1 file changed, 9 insertions(+) diff --git a/clang/Maintainers.rst b/clang/Maintainers.rst index 27255a9c0319b4..d42c0cf96040ab 100644 --- a/clang/Maintainers.rst +++ b/clang/Maintainers.rst @@ -68,6 +68,9 @@ Sema | Sirraide | aeternalmail\@gmail.com (email), Sirraide (GitHub), Ætérnal (Discord), Sirraide (Discourse) +| Mariya Podchishchaeva +| mariya.podchishchaeva\@intel.com (email), Fznamznon (GitHub), fznamznon (Discord), Fznamznon (Discourse) + Recovery AST @@ -150,6 +153,12 @@ Driver parts not covered by someone else | i\@maskray.me (email), MaskRay (Phabricator), MaskRay (GitHub) +Constant Expressions + +| Mariya Podchishchaeva +| mariya.podchishchaeva\@intel.com (email), Fznamznon (GitHub), fznamznon (Discord), Fznamznon (Discourse) + + Tools - These maintainers are responsible for user-facing tools under the Clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Transforms][Utils][PromoteMem2Reg] Propagate nnan flag on par with the nsz flag (PR #114271)
pawosm-arm wrote: > > Yet we see a value in the change proposed here too hence a good reason for > > merging it. > > I've clearly misunderstood the context of the rebase. What is the value in > merging this change if the original issue has already been resolved? I guess > this fix is simpler and thus might help compile time but then that wasn't the > original intent. There are two views at this situation: One, I can imagine many ways the `nnan` flag could not be retrieved if it isn't ensured (the way my patch is doing it), Dave's patch solves the problem more elaborate way we know it works in specific situations, yet how can we be sure there aren't other places in which `nnan` should be easily visible if a transformation should succeed? The other is that there's a general movement away from having the function attributes (in favor of using only the instruction flags) and thus by adding another use we make this transition harder. My PR will catch all cases and has very low complexity. Seems I need @nikic opinion on the subject, whether we should land it or abandon it. https://github.com/llvm/llvm-project/pull/114271 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix name lookup for dependent bases (PR #114978)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Vladislav Belov (vbe-sc) Changes Currently the following example is a compilation failure: ``` templatestruct A { typedef int M; struct B { typedef void M; struct C; }; }; template struct A ::B::C : A { M m; // void or int ? }; ``` According to the point 13.8.3.2 ``` A dependent base class is a base class that is a dependent type and is not the current instantiation. Note 2 : A base class can be the current instantiation in the case of a nested class naming an enclosing class as a base. ``` The base class `A` is the current instantiation, because `C` is a nested class for an enclosing class `A `, it's is the not-dependent base class and we need to search the names through its scope. This patch makes this example compile --- Full diff: https://github.com/llvm/llvm-project/pull/114978.diff 2 Files Affected: - (modified) clang/lib/AST/CXXInheritance.cpp (+8-5) - (modified) clang/test/CXX/drs/cwg5xx.cpp (+6-2) ``diff diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp index eb265a872c1259..049532f942d051 100644 --- a/clang/lib/AST/CXXInheritance.cpp +++ b/clang/lib/AST/CXXInheritance.cpp @@ -169,6 +169,9 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, // Find the record of the base class subobjects for this type. QualType BaseType = Context.getCanonicalType(BaseSpec.getType()).getUnqualifiedType(); +bool isCurrentInstantiation = false; +if (auto *TST = BaseSpec.getType()->getAs()) + isCurrentInstantiation = TST->isCurrentInstantiation(); // C++ [temp.dep]p3: // In the definition of a class template or a member of a class template, @@ -176,7 +179,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, // the base class scope is not examined during unqualified name lookup // either at the point of definition of the class template or member or // during an instantiation of the class tem- plate or member. -if (!LookupInDependent && BaseType->isDependentType()) +if (!LookupInDependent && +(BaseType->isDependentType() && !isCurrentInstantiation)) continue; // Determine whether we need to visit this base class at all, @@ -244,9 +248,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, return FoundPath; } } else if (VisitBase) { - CXXRecordDecl *BaseRecord; + CXXRecordDecl *BaseRecord = nullptr; if (LookupInDependent) { -BaseRecord = nullptr; const TemplateSpecializationType *TST = BaseSpec.getType()->getAs(); if (!TST) { @@ -265,8 +268,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, BaseRecord = nullptr; } } else { -BaseRecord = cast( -BaseSpec.getType()->castAs()->getDecl()); +if (auto *RT = BaseSpec.getType()->getAs()) + BaseRecord = cast(RT->getDecl()); } if (BaseRecord && lookupInBases(Context, BaseRecord, BaseMatches, LookupInDependent)) { diff --git a/clang/test/CXX/drs/cwg5xx.cpp b/clang/test/CXX/drs/cwg5xx.cpp index ed0c7159dfc889..b283684aef2f7e 100644 --- a/clang/test/CXX/drs/cwg5xx.cpp +++ b/clang/test/CXX/drs/cwg5xx.cpp @@ -1178,17 +1178,21 @@ namespace cwg590 { // cwg590: yes template typename A::B::C A::B::C::f(A::B::C) {} } -namespace cwg591 { // cwg591: no +namespace cwg591 { // cwg591: yes template struct A { typedef int M; struct B { typedef void M; struct C; + struct D; }; }; template struct A::B::C : A { -// FIXME: Should find member of non-dependent base class A. +M m; + }; + + template struct A::B::D : A { M m; // expected-error@-1 {{field has incomplete type 'M' (aka 'void'}} }; `` https://github.com/llvm/llvm-project/pull/114978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Transforms][Utils][PromoteMem2Reg] Propagate nnan flag on par with the nsz flag (PR #114271)
nikic wrote: I do think this change still makes sense, especially from a consistency point of view. If SROA sets one of the value-based FMF flags (nsz) then it stands to reason that it should also set the other two (nnan and ninf). Unless there is some reason why nsz would be more problematic than nnan/ninf in this context (it does have substantially different semantics). https://github.com/llvm/llvm-project/pull/114271 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Fix name lookup for dependent bases (PR #114978)
https://github.com/Endilll edited https://github.com/llvm/llvm-project/pull/114978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][Driver] When linking with the Fortran runtime, the `addArchSpecificRPath()` should be called too (PR #114837)
https://github.com/Meinersbur commented: `addSanitizerRuntime` and `addOpenMPRuntime` are already calling `addArchSpecificRPath`. It it a problem if rpath is added multiple times? Compiler-rt libs (`libclang_rt.*.a`) are added as absolute paths, shouldn't the Fortran-runtime do the same? https://github.com/llvm/llvm-project/pull/114837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [llvm] [FMV][AArch64] Remove features which expose non exploitable runtime behavior. (PR #114387)
https://github.com/labrinea ready_for_review https://github.com/llvm/llvm-project/pull/114387 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [WIP][lldb][Expression] More reliable function call resolution (PR #114529)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/114529 >From 9337e170d920eaabe2b59a25622f0c554ca5afcf Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 20 Oct 2024 11:35:15 +0100 Subject: [PATCH 1/2] [WIP][lldb][Expression] More reliable function call resolution Implements all the parts of following RFC: https://discourse.llvm.org/t/rfc-lldb-handling-abi-tagged-constructors-destructors-in-expression-evaluator/82816 Main changes: 1. Instead of relying on linkage names to resolve function symbols, encode the exact function DIE and module in the `AsmLabelAttr` 2. Teach the LLDB symbol resolve about (1) 3. Introduce new Clang attribute to allow specifying multiple `asm` labels for ctors/dtors (one for each variant) 4. Attach the new attribute in (3), where the mangled names use the format from (1). To determine which variant a DIE corresponds to we add a new API to the `ItaniumPartialDemangler` (though could be made into a DWARF attribute for quicker determination). --- clang/include/clang/Basic/Attr.td | 8 ++ clang/include/clang/Basic/AttrDocs.td | 5 ++ clang/lib/AST/Mangle.cpp | 69 +++- clang/lib/Sema/SemaDeclAttr.cpp | 22 + lldb/source/Expression/IRExecutionUnit.cpp| 36 + .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 80 +++ .../TypeSystem/Clang/TypeSystemClang.cpp | 15 +++- .../TypeSystem/Clang/TypeSystemClang.h| 3 +- lldb/test/Shell/Expr/TestAbiTagCtorsDtors.cpp | 28 +++ llvm/include/llvm/Demangle/Demangle.h | 3 + llvm/include/llvm/Demangle/ItaniumDemangle.h | 2 + llvm/lib/Demangle/ItaniumDemangle.cpp | 18 +++-- 12 files changed, 264 insertions(+), 25 deletions(-) create mode 100644 lldb/test/Shell/Expr/TestAbiTagCtorsDtors.cpp diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 70fad60d4edbb5..407eece2a728a2 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -784,6 +784,14 @@ def AbiTag : Attr { let Documentation = [AbiTagsDocs]; } +def StructorMangledNames : Attr { + let Spellings = [Clang<"structor_names">]; + let Args = [VariadicStringArgument<"MangledNames">]; + let Subjects = SubjectList<[Function], ErrorDiag>; + let Documentation = [StructorMangledNamesDocs]; +} + + def AddressSpace : TypeAttr { let Spellings = [Clang<"address_space">]; let Args = [IntArgument<"AddressSpace">]; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 546e5100b79dd9..2b886aecd193de 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -3568,6 +3568,11 @@ manipulating bits of the enumerator when issuing warnings. }]; } +def StructorMangledNamesDocs : Documentation { + let Category = DocCatDecl; + let Content = [{ TODO }]; +} + def AsmLabelDocs : Documentation { let Category = DocCatDecl; let Content = [{ diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp index 4875e8537b3c11..9b304d28113625 100644 --- a/clang/lib/AST/Mangle.cpp +++ b/clang/lib/AST/Mangle.cpp @@ -9,19 +9,20 @@ // Implements generic name mangling support for blocks and Objective-C. // //===--===// -#include "clang/AST/Attr.h" +#include "clang/AST/Mangle.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/Attr.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/ExprCXX.h" -#include "clang/AST/Mangle.h" #include "clang/AST/VTableBuilder.h" #include "clang/Basic/ABI.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Mangler.h" #include "llvm/Support/ErrorHandling.h" @@ -126,7 +127,7 @@ bool MangleContext::shouldMangleDeclName(const NamedDecl *D) { // Any decl can be declared with __asm("foo") on it, and this takes precedence // over all other naming in the .o file. - if (D->hasAttr()) + if (D->hasAttr() || D->hasAttr()) return true; // Declarations that don't have identifier names always need to be mangled. @@ -140,6 +141,68 @@ void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) { const ASTContext &ASTContext = getASTContext(); const NamedDecl *D = cast(GD.getDecl()); + if (const StructorMangledNamesAttr *SMA = + D->getAttr()) { +CXXConstructorDecl const *Ctor = dyn_cast(D); +CXXDestructorDecl const *Dtor = dyn_cast(D); +assert(Ctor || Dtor); +enum CtorDtor { + None = -1, + Deleting = 0, + Base, + Complete, + Allocating +} CtorDtorVariant = None; + +// Map ctor/dtor variant to a the variant that LLDB encoded in the
[clang] [compiler-rt] [llvm] [FMV][AArch64] Remove features which expose non exploitable runtime behavior. (PR #114387)
https://github.com/labrinea updated https://github.com/llvm/llvm-project/pull/114387 >From 71786e09b65da73e998cbce32386a54e9eb3ee1e Mon Sep 17 00:00:00 2001 From: Alexandros Lamprineas Date: Tue, 29 Oct 2024 16:45:47 + Subject: [PATCH 1/2] [FMV][AArch64] Remove features which expose non exploitable runtime behavior. Features dit, ebf16, memtag3, and rpres allow existing instructions to behave differently depending on the value of certain control registers. FMV does not read the content of control registers making these features unsuitable for runtime dispatch. See the ACLE patch for more info: https://github.com/ARM-software/acle/pull/355 --- .../CodeGen/aarch64-cpu-supports-target.c | 6 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 17 + clang/test/CodeGen/attr-target-version.c | 62 +-- clang/test/CodeGenCXX/attr-target-version.cpp | 10 +-- clang/test/Sema/aarch64-cpu-supports.c| 2 +- clang/test/Sema/attr-target-clones-aarch64.c | 4 +- clang/test/Sema/attr-target-version.c | 4 +- clang/test/SemaCXX/attr-target-version.cpp| 2 +- .../builtins/cpu_model/AArch64CPUFeatures.inc | 8 +-- .../builtins/cpu_model/aarch64/fmv/apple.inc | 2 - .../builtins/cpu_model/aarch64/fmv/mrs.inc| 8 --- .../llvm/TargetParser/AArch64CPUFeatures.inc | 8 +-- llvm/lib/Target/AArch64/AArch64FMV.td | 4 -- 13 files changed, 55 insertions(+), 82 deletions(-) diff --git a/clang/test/CodeGen/aarch64-cpu-supports-target.c b/clang/test/CodeGen/aarch64-cpu-supports-target.c index e3a75e9a1fc7d3..72a1ea29570749 100644 --- a/clang/test/CodeGen/aarch64-cpu-supports-target.c +++ b/clang/test/CodeGen/aarch64-cpu-supports-target.c @@ -5,11 +5,11 @@ int check_all_feature() { return 1; else if (__builtin_cpu_supports("rdm+lse+fp+simd+crc+sha1+sha2+sha3")) return 2; - else if (__builtin_cpu_supports("aes+pmull+fp16+dit+dpb+dpb2+jscvt")) + else if (__builtin_cpu_supports("aes+pmull+fp16+dpb+dpb2+jscvt")) return 3; else if (__builtin_cpu_supports("fcma+rcpc+rcpc2+rcpc3+frintts+dgh")) return 4; - else if (__builtin_cpu_supports("i8mm+bf16+ebf16+rpres+sve")) + else if (__builtin_cpu_supports("i8mm+bf16+sve")) return 5; else if (__builtin_cpu_supports("sve+ebf16+i8mm+f32mm+f64mm")) return 6; @@ -17,7 +17,7 @@ int check_all_feature() { return 7; else if (__builtin_cpu_supports("sve2-bitperm+sve2-sha3+sve2-sm4")) return 8; - else if (__builtin_cpu_supports("sme+memtag+memtag3+sb")) + else if (__builtin_cpu_supports("sme+memtag+sb")) return 9; else if (__builtin_cpu_supports("predres+ssbs+ssbs2+bti+ls64+ls64_v")) return 10; diff --git a/clang/test/CodeGen/aarch64-fmv-dependencies.c b/clang/test/CodeGen/aarch64-fmv-dependencies.c index db6be423b99f78..4b6abffa6c05db 100644 --- a/clang/test/CodeGen/aarch64-fmv-dependencies.c +++ b/clang/test/CodeGen/aarch64-fmv-dependencies.c @@ -6,7 +6,7 @@ // CHECK: define dso_local i32 @fmv._Maes() #[[aes:[0-9]+]] { __attribute__((target_version("aes"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16:[0-9]+]] { __attribute__((target_version("bf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mbti() #[[bti:[0-9]+]] { @@ -18,9 +18,6 @@ __attribute__((target_version("crc"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdgh() #[[ATTR0:[0-9]+]] { __attribute__((target_version("dgh"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mdit() #[[dit:[0-9]+]] { -__attribute__((target_version("dit"))) int fmv(void) { return 0; } - // CHECK: define dso_local i32 @fmv._Mdotprod() #[[dotprod:[0-9]+]] { __attribute__((target_version("dotprod"))) int fmv(void) { return 0; } @@ -30,9 +27,6 @@ __attribute__((target_version("dpb"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdpb2() #[[dpb2:[0-9]+]] { __attribute__((target_version("dpb2"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mebf16() #[[bf16_ebf16:[0-9]+]] { -__attribute__((target_version("ebf16"))) int fmv(void) { return 0; } - // CHECK: define dso_local i32 @fmv._Mf32mm() #[[f32mm:[0-9]+]] { __attribute__((target_version("f32mm"))) int fmv(void) { return 0; } @@ -75,9 +69,6 @@ __attribute__((target_version("lse"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mmemtag() #[[memtag:[0-9]+]] { __attribute__((target_version("memtag"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mmemtag3() #[[memtag:[0-9]+]] { -__attribute__((target_version("memtag3"))) int fmv(void) { return 0; } - // CHECK: define dso_local i32 @fmv._Mmops() #[[mops:[0-9]+]] { __attribute__((target_version("mops"))) int fmv(void) { return 0; } @@ -99,9 +90,6 @@ __attribute__((target_version("rdm"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @
[clang] Add Mariya as maintainer for constant expressions & Sema (PR #114974)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Aaron Ballman (AaronBallman) Changes Mariya has extensive knowledge of the constant expression evaluator and has done a lot of reviewing in Sema over the past year or so. --- Full diff: https://github.com/llvm/llvm-project/pull/114974.diff 1 Files Affected: - (modified) clang/Maintainers.rst (+9) ``diff diff --git a/clang/Maintainers.rst b/clang/Maintainers.rst index 27255a9c0319b4..d42c0cf96040ab 100644 --- a/clang/Maintainers.rst +++ b/clang/Maintainers.rst @@ -68,6 +68,9 @@ Sema | Sirraide | aeternalmail\@gmail.com (email), Sirraide (GitHub), Ætérnal (Discord), Sirraide (Discourse) +| Mariya Podchishchaeva +| mariya.podchishchaeva\@intel.com (email), Fznamznon (GitHub), fznamznon (Discord), Fznamznon (Discourse) + Recovery AST @@ -150,6 +153,12 @@ Driver parts not covered by someone else | i\@maskray.me (email), MaskRay (Phabricator), MaskRay (GitHub) +Constant Expressions + +| Mariya Podchishchaeva +| mariya.podchishchaeva\@intel.com (email), Fznamznon (GitHub), fznamznon (Discord), Fznamznon (Discourse) + + Tools - These maintainers are responsible for user-facing tools under the Clang `` https://github.com/llvm/llvm-project/pull/114974 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix the post-filtering heuristic for GSLPointer. (PR #114044)
https://github.com/Xazax-hun approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/114044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Add Mariya as maintainer for constant expressions & Sema (PR #114974)
https://github.com/tbaederr approved this pull request. https://github.com/llvm/llvm-project/pull/114974 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Check for editsNearCursor client capability under experimental capabilities (PR #114699)
rchl wrote: Personally I haven't yet looked if other custom capabilities are relevant for the editor I use (Sublime Text) but I also think it would makes sense to be with all of them (and follow the spec). https://github.com/llvm/llvm-project/pull/114699 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [XRay][AArch64] Support -fxray-shared (PR #114431)
juliannagele wrote: Unfortunately it looks like this has broken building compiler-rt on green dragon: https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA/2606/console ``` :1:1: error: unrecognized instruction mnemonic pushfq ^ /Users/ec2-user/jenkins/workspace/llvm.org/clang-stage1-RA/llvm-project/compiler-rt/lib/xray/xray_trampoline_x86_64.S:129:2: note: while in macro instantiation SAVE_REGISTERS ^ ... ``` https://github.com/llvm/llvm-project/pull/114431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Add -mno-unaligned-access and -mbig-endian to ARM and AArch64 multilib flags (PR #114782)
https://github.com/pratlucas approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/114782 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [WIP][lldb][Expression] More reliable function call resolution (PR #114529)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/114529 >From 9337e170d920eaabe2b59a25622f0c554ca5afcf Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 20 Oct 2024 11:35:15 +0100 Subject: [PATCH 1/2] [WIP][lldb][Expression] More reliable function call resolution Implements all the parts of following RFC: https://discourse.llvm.org/t/rfc-lldb-handling-abi-tagged-constructors-destructors-in-expression-evaluator/82816 Main changes: 1. Instead of relying on linkage names to resolve function symbols, encode the exact function DIE and module in the `AsmLabelAttr` 2. Teach the LLDB symbol resolve about (1) 3. Introduce new Clang attribute to allow specifying multiple `asm` labels for ctors/dtors (one for each variant) 4. Attach the new attribute in (3), where the mangled names use the format from (1). To determine which variant a DIE corresponds to we add a new API to the `ItaniumPartialDemangler` (though could be made into a DWARF attribute for quicker determination). --- clang/include/clang/Basic/Attr.td | 8 ++ clang/include/clang/Basic/AttrDocs.td | 5 ++ clang/lib/AST/Mangle.cpp | 69 +++- clang/lib/Sema/SemaDeclAttr.cpp | 22 + lldb/source/Expression/IRExecutionUnit.cpp| 36 + .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 80 +++ .../TypeSystem/Clang/TypeSystemClang.cpp | 15 +++- .../TypeSystem/Clang/TypeSystemClang.h| 3 +- lldb/test/Shell/Expr/TestAbiTagCtorsDtors.cpp | 28 +++ llvm/include/llvm/Demangle/Demangle.h | 3 + llvm/include/llvm/Demangle/ItaniumDemangle.h | 2 + llvm/lib/Demangle/ItaniumDemangle.cpp | 18 +++-- 12 files changed, 264 insertions(+), 25 deletions(-) create mode 100644 lldb/test/Shell/Expr/TestAbiTagCtorsDtors.cpp diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 70fad60d4edbb5..407eece2a728a2 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -784,6 +784,14 @@ def AbiTag : Attr { let Documentation = [AbiTagsDocs]; } +def StructorMangledNames : Attr { + let Spellings = [Clang<"structor_names">]; + let Args = [VariadicStringArgument<"MangledNames">]; + let Subjects = SubjectList<[Function], ErrorDiag>; + let Documentation = [StructorMangledNamesDocs]; +} + + def AddressSpace : TypeAttr { let Spellings = [Clang<"address_space">]; let Args = [IntArgument<"AddressSpace">]; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 546e5100b79dd9..2b886aecd193de 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -3568,6 +3568,11 @@ manipulating bits of the enumerator when issuing warnings. }]; } +def StructorMangledNamesDocs : Documentation { + let Category = DocCatDecl; + let Content = [{ TODO }]; +} + def AsmLabelDocs : Documentation { let Category = DocCatDecl; let Content = [{ diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp index 4875e8537b3c11..9b304d28113625 100644 --- a/clang/lib/AST/Mangle.cpp +++ b/clang/lib/AST/Mangle.cpp @@ -9,19 +9,20 @@ // Implements generic name mangling support for blocks and Objective-C. // //===--===// -#include "clang/AST/Attr.h" +#include "clang/AST/Mangle.h" #include "clang/AST/ASTContext.h" +#include "clang/AST/Attr.h" #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/DeclTemplate.h" #include "clang/AST/ExprCXX.h" -#include "clang/AST/Mangle.h" #include "clang/AST/VTableBuilder.h" #include "clang/Basic/ABI.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Mangler.h" #include "llvm/Support/ErrorHandling.h" @@ -126,7 +127,7 @@ bool MangleContext::shouldMangleDeclName(const NamedDecl *D) { // Any decl can be declared with __asm("foo") on it, and this takes precedence // over all other naming in the .o file. - if (D->hasAttr()) + if (D->hasAttr() || D->hasAttr()) return true; // Declarations that don't have identifier names always need to be mangled. @@ -140,6 +141,68 @@ void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) { const ASTContext &ASTContext = getASTContext(); const NamedDecl *D = cast(GD.getDecl()); + if (const StructorMangledNamesAttr *SMA = + D->getAttr()) { +CXXConstructorDecl const *Ctor = dyn_cast(D); +CXXDestructorDecl const *Dtor = dyn_cast(D); +assert(Ctor || Dtor); +enum CtorDtor { + None = -1, + Deleting = 0, + Base, + Complete, + Allocating +} CtorDtorVariant = None; + +// Map ctor/dtor variant to a the variant that LLDB encoded in the
[clang] Nominate Saleem and myself as maintainers for API Notes (PR #114981)
https://github.com/egorzhdan updated https://github.com/llvm/llvm-project/pull/114981 >From 1bf3932e901177518632eeaa05b21a05f3d43880 Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Mon, 4 Nov 2024 19:52:37 + Subject: [PATCH] Nominate Saleem and myself as maintainers for API Notes --- clang/Maintainers.rst | 8 1 file changed, 8 insertions(+) diff --git a/clang/Maintainers.rst b/clang/Maintainers.rst index 694ebc691107cb..23eed49c5414a3 100644 --- a/clang/Maintainers.rst +++ b/clang/Maintainers.rst @@ -132,6 +132,14 @@ Compiler options | jan_svoboda\@apple.com (email), jansvoboda11 (Phabricator), jansvoboda11 (GitHub) +API Notes + +| Egor Zhdan +| e_zhdan\@apple.com (email), egorzhdan (GitHub), egor.zhdan (Discourse) + +| Saleem Abdulrasool +| compnerd\@compnerd.org (email), compnerd (GitHub), compnerd (Discourse) + OpenBSD driver ~~ | Brad Smith ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Nominate Saleem and myself as maintainers for API Notes (PR #114981)
https://github.com/egorzhdan created https://github.com/llvm/llvm-project/pull/114981 Saleem has upstreamed a large chunk of API Notes infrastructure from the Apple fork, and over the past year I've upstreamed the remaining part of API Notes, added new annotations and improved C++ language support. https://github.com/llvm/llvm-project/commits/main/clang/lib/APINotes >From 77be63ca7c75538b8c6c45527e7ff3ca966af9c1 Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Mon, 4 Nov 2024 19:52:37 + Subject: [PATCH] Nominate Saleem and myself as maintainers for API Notes --- clang/Maintainers.rst | 8 1 file changed, 8 insertions(+) diff --git a/clang/Maintainers.rst b/clang/Maintainers.rst index 694ebc691107cb..0fcbbbf31005e7 100644 --- a/clang/Maintainers.rst +++ b/clang/Maintainers.rst @@ -132,6 +132,14 @@ Compiler options | jan_svoboda\@apple.com (email), jansvoboda11 (Phabricator), jansvoboda11 (GitHub) +API Notes + +| Egor Zhdan +| e_zhdan\@apple.com (email), egorzhdan (GitHub), egor.zhdan (Discourse) + +| Saleem Abdulrasool +| compn...@compnerd.org (email), compnerd (GitHub), compnerd (Discourse) + OpenBSD driver ~~ | Brad Smith ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-query] add basic profiling on matching each ASTs (PR #114806)
https://github.com/AaronBallman approved this pull request. LGTM, thank you! https://github.com/llvm/llvm-project/pull/114806 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang][Driver] When linking with the Fortran runtime, the `addArchSpecificRPath()` should be called too (PR #114837)
pawosm-arm wrote: > `addSanitizerRuntime` and `addOpenMPRuntime` are already calling > `addArchSpecificRPath`. It it a problem if rpath is added multiple times? > I've been testing it with and without -fopenmp and didn't observe any problem > Compiler-rt libs (`libclang_rt.*.a`) are added as absolute paths, shouldn't > the Fortran-runtime do the same? This makes sense for static libraries, Fortran-runtime can be built static or shared, and in case of shared lib, the rpath issue starts to kick in. https://github.com/llvm/llvm-project/pull/114837 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] update reasoned delete diagnostic kind to use Extension, making it pedantic only (PR #114713)
@@ -464,6 +464,8 @@ Improvements to Clang's diagnostics - Clang now diagnoses ``[[deprecated]]`` attribute usage on local variables (#GH90073). +- Clang now diagnoses misused reasoned ``delete("reason")`` warnings only in pedantic mode. (#GH109311). AaronBallman wrote: At this point, I'd prefer if you'd obtain commit privileges and land the changes yourself -- you have a number of patches under your belt, and it's better for folks to land their own changes in case of needing reverts, etc. If there's a reason you don't want/can't get commit rights, feel free to let me know privately or otherwise, and I can certainly land the changes for you. https://github.com/llvm/llvm-project/pull/114713 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64]Fix Name and Mangle name for scalar fp8 (PR #114983)
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (CarolineConcatto) Changes The scalar __mfp8 type has the wrong name and mangle name in AArch64SVEACLETypes.def According to the ACLE[1] the name should be __mfp8, then mangle name __u6mfp8. This patch fixes this problem by replacing the Name __MFloat8_t by __mfp8 and the Mangle Name __MFloat8_t by __u6mfp8 And we revert the incorrect typedef in NeonEmitter. [1]https://github.com/ARM-software/acle --- Full diff: https://github.com/llvm/llvm-project/pull/114983.diff 7 Files Affected: - (modified) clang/include/clang/Basic/AArch64SVEACLETypes.def (+1-1) - (modified) clang/test/AST/arm-mfp8.cpp (+28-29) - (modified) clang/test/CodeGen/aarch64-debug-types.c (+3-3) - (modified) clang/test/CodeGen/arm-mfp8.c (+1-1) - (modified) clang/test/Sema/arm-mfp8.c (+2-2) - (modified) clang/test/Sema/arm-mfp8.cpp (+33-32) - (modified) clang/utils/TableGen/NeonEmitter.cpp (+1-1) ``diff diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 62f6087e962466..cec5ab19a01730 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -200,7 +200,7 @@ SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4T SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy) -AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8_t", "__MFloat8_t", MFloat8, MFloat8Ty, 1, 8, 1) +AARCH64_VECTOR_TYPE_MFLOAT("__mfp8", "__u6mfp8", MFloat8, MFloat8Ty, 1, 8, 1) AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x8_t", "__MFloat8x8_t", MFloat8x8, MFloat8x8Ty, 8, 8, 1) AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x16_t", "__MFloat8x16_t", MFloat8x16, MFloat8x16Ty, 16, 8, 1) diff --git a/clang/test/AST/arm-mfp8.cpp b/clang/test/AST/arm-mfp8.cpp index 51bebba067eb9f..195c734fc753e5 100644 --- a/clang/test/AST/arm-mfp8.cpp +++ b/clang/test/AST/arm-mfp8.cpp @@ -5,7 +5,6 @@ /* Various contexts where type __mfp8 can appear. */ -#include /* Namespace */ namespace { __mfp8 f2n; @@ -13,7 +12,7 @@ namespace { } //CHECK: |-NamespaceDecl {{.*}} -//CHECK-NEXT: | |-VarDecl {{.*}} f2n '__mfp8':'__MFloat8_t' +//CHECK-NEXT: | |-VarDecl {{.*}} f2n '__mfp8' //CHECK-NEXT: | `-VarDecl {{.*}} arr1n '__mfp8[10]' @@ -24,14 +23,14 @@ namespace { return f1n; } //CHECK:|-FunctionDecl {{.*}} func1n 'const __mfp8 (const __mfp8)' -//CHECK:| `-VarDecl {{.*}} f1n '__mfp8':'__MFloat8_t' -//CHECK-NEXT: |-BinaryOperator {{.*}} '__mfp8':'__MFloat8_t' lvalue '=' -//CHECK-NEXT: | |-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue Var {{.*}} 'f1n' '__mfp8':'__MFloat8_t' -//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' -//CHECK-NEXT: | `-DeclRefExpr {{.*}} 'const __mfp8':'const __MFloat8_t' lvalue ParmVar {{.*}} 'mfp8' 'const __mfp8':'const __MFloat8_t' +//CHECK:| `-VarDecl {{.*}} f1n '__mfp8' +//CHECK-NEXT: |-BinaryOperator {{.*}} '__mfp8' lvalue '=' +//CHECK-NEXT: | |-DeclRefExpr {{.*}} '__mfp8' lvalue Var {{.*}} 'f1n' '__mfp8' +//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8' +//CHECK-NEXT: | `-DeclRefExpr {{.*}} 'const __mfp8' lvalue ParmVar {{.*}} 'mfp8' 'const __mfp8' //CHECK-NEXT:`-ReturnStmt {{.*}} -//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' -//CHECK-NEXT: `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue Var {{.*}} 'f1n' '__mfp8':'__MFloat8_t' +//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '__mfp8' +//CHECK-NEXT: `-DeclRefExpr {{.*}} '__mfp8' lvalue Var {{.*}} 'f1n' '__mfp8' /* Class */ @@ -39,7 +38,7 @@ namespace { class C1 { __mfp8 f1c; static const __mfp8 f2c; - volatile __MFloat8_t f3c; + volatile __mfp8 f3c; public: C1(__mfp8 arg) : f1c(arg), f3c(arg) { } __mfp8 func1c(__mfp8 arg ) { @@ -51,31 +50,31 @@ class C1 { }; //CHECK: | |-CXXRecordDecl {{.*}} referenced class C1 -//CHECK-NEXT: | |-FieldDecl {{.*}} f1c '__mfp8':'__MFloat8_t' -//CHECK-NEXT: | |-VarDecl {{.*}} f2c 'const __mfp8':'const __MFloat8_t' static -//CHECK-NEXT: | |-FieldDecl {{.*}} f3c 'volatile __MFloat8_t' +//CHECK-NEXT: | |-FieldDecl {{.*}} f1c '__mfp8' +//CHECK-NEXT: | |-VarDecl {{.*}} f2c 'const __mfp8' static +//CHECK-NEXT: | |-FieldDecl {{.*}} f3c 'volatile __mfp8' //CHECK-NEXT: | |-AccessSpecDecl {{.*}} //CHECK-NEXT: | |-CXXConstructorDecl {{.*}} C1 'void (__mfp8)' implicit-inline -//CHECK-NEXT: | | |-ParmVarDecl {{.*}} arg '__mfp8':'__MFloat8_t' -//CHECK-NEXT: | | |-CXXCtorInitializer {{.*}} 'f1c' '__mfp8':'__MFloat8_t' -//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' -//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue ParmVar {{.*}} 'arg' '__mfp8':'__MFloat8_t' -//CHECK-NEXT: | | |-CXXCtorInitializer {{.*}} 'f3c' 'volatile __MFloat8_t' -//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}}
[clang] [Clang] Fix name lookup for dependent bases (PR #114978)
https://github.com/vbe-sc created https://github.com/llvm/llvm-project/pull/114978 Currently the following example is a compilation failure: ``` template struct A { typedef int M; struct B { typedef void M; struct C; }; }; template struct A::B::C : A { M m; // void or int ? }; ``` According to the point 13.8.3.2 ``` A dependent base class is a base class that is a dependent type and is not the current instantiation. Note 2 : A base class can be the current instantiation in the case of a nested class naming an enclosing class as a base. ``` The base class `A` is the current instantiation, because `C` is a nested class for an enclosing class `A`, it's is the not-dependent base class and we need to search the names through its scope. This patch makes this example compile >From 4eb7be671dee117f8185423b177c014edd310b48 Mon Sep 17 00:00:00 2001 From: vb-sc Date: Tue, 5 Nov 2024 15:46:57 +0300 Subject: [PATCH] [clang] Fix name lookup for dependent bases --- clang/lib/AST/CXXInheritance.cpp | 13 - clang/test/CXX/drs/cwg5xx.cpp| 8 ++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp index eb265a872c1259..049532f942d051 100644 --- a/clang/lib/AST/CXXInheritance.cpp +++ b/clang/lib/AST/CXXInheritance.cpp @@ -169,6 +169,9 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, // Find the record of the base class subobjects for this type. QualType BaseType = Context.getCanonicalType(BaseSpec.getType()).getUnqualifiedType(); +bool isCurrentInstantiation = false; +if (auto *TST = BaseSpec.getType()->getAs()) + isCurrentInstantiation = TST->isCurrentInstantiation(); // C++ [temp.dep]p3: // In the definition of a class template or a member of a class template, @@ -176,7 +179,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, // the base class scope is not examined during unqualified name lookup // either at the point of definition of the class template or member or // during an instantiation of the class tem- plate or member. -if (!LookupInDependent && BaseType->isDependentType()) +if (!LookupInDependent && +(BaseType->isDependentType() && !isCurrentInstantiation)) continue; // Determine whether we need to visit this base class at all, @@ -244,9 +248,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, return FoundPath; } } else if (VisitBase) { - CXXRecordDecl *BaseRecord; + CXXRecordDecl *BaseRecord = nullptr; if (LookupInDependent) { -BaseRecord = nullptr; const TemplateSpecializationType *TST = BaseSpec.getType()->getAs(); if (!TST) { @@ -265,8 +268,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context, BaseRecord = nullptr; } } else { -BaseRecord = cast( -BaseSpec.getType()->castAs()->getDecl()); +if (auto *RT = BaseSpec.getType()->getAs()) + BaseRecord = cast(RT->getDecl()); } if (BaseRecord && lookupInBases(Context, BaseRecord, BaseMatches, LookupInDependent)) { diff --git a/clang/test/CXX/drs/cwg5xx.cpp b/clang/test/CXX/drs/cwg5xx.cpp index ed0c7159dfc889..b283684aef2f7e 100644 --- a/clang/test/CXX/drs/cwg5xx.cpp +++ b/clang/test/CXX/drs/cwg5xx.cpp @@ -1178,17 +1178,21 @@ namespace cwg590 { // cwg590: yes template typename A::B::C A::B::C::f(A::B::C) {} } -namespace cwg591 { // cwg591: no +namespace cwg591 { // cwg591: yes template struct A { typedef int M; struct B { typedef void M; struct C; + struct D; }; }; template struct A::B::C : A { -// FIXME: Should find member of non-dependent base class A. +M m; + }; + + template struct A::B::D : A { M m; // expected-error@-1 {{field has incomplete type 'M' (aka 'void'}} }; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Nominate Saleem and myself as maintainers for API Notes (PR #114981)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Egor Zhdan (egorzhdan) Changes Saleem has upstreamed a large chunk of API Notes infrastructure from the Apple fork, and over the past year I've upstreamed the remaining part of API Notes, added new annotations and improved C++ language support. https://github.com/llvm/llvm-project/commits/main/clang/lib/APINotes --- Full diff: https://github.com/llvm/llvm-project/pull/114981.diff 1 Files Affected: - (modified) clang/Maintainers.rst (+8) ``diff diff --git a/clang/Maintainers.rst b/clang/Maintainers.rst index 694ebc691107cb..0fcbbbf31005e7 100644 --- a/clang/Maintainers.rst +++ b/clang/Maintainers.rst @@ -132,6 +132,14 @@ Compiler options | jan_svoboda\@apple.com (email), jansvoboda11 (Phabricator), jansvoboda11 (GitHub) +API Notes + +| Egor Zhdan +| e_zhdan\@apple.com (email), egorzhdan (GitHub), egor.zhdan (Discourse) + +| Saleem Abdulrasool +| compn...@compnerd.org (email), compnerd (GitHub), compnerd (Discourse) + OpenBSD driver ~~ | Brad Smith `` https://github.com/llvm/llvm-project/pull/114981 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Nominate Saleem and myself as maintainers for API Notes (PR #114981)
@@ -132,6 +132,14 @@ Compiler options | jan_svoboda\@apple.com (email), jansvoboda11 (Phabricator), jansvoboda11 (GitHub) +API Notes + +| Egor Zhdan +| e_zhdan\@apple.com (email), egorzhdan (GitHub), egor.zhdan (Discourse) + +| Saleem Abdulrasool +| compnerd\@compnerd.org (email), compnerd (GitHub), compnerd (Discourse) + AaronBallman wrote: ```suggestion ``` https://github.com/llvm/llvm-project/pull/114981 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Nominate Saleem and myself as maintainers for API Notes (PR #114981)
https://github.com/AaronBallman approved this pull request. LGTM (with a minor whitespace nit for consistency with the rest of the file), though please wait to land until after @compnerd has accepted the nomination as well. Thank you for volunteering! https://github.com/llvm/llvm-project/pull/114981 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Nominate Saleem and myself as maintainers for API Notes (PR #114981)
https://github.com/AaronBallman edited https://github.com/llvm/llvm-project/pull/114981 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Call code gen; create empty cir.func op (PR #113483)
@@ -52,10 +62,33 @@ class CIRGenModule : public CIRGenTypeCache { /// A "module" matches a c/cpp source file: containing a list of functions. mlir::ModuleOp theModule; + clang::DiagnosticsEngine &diags; + const clang::TargetInfo ⌖ public: + mlir::ModuleOp getModule() const { return theModule; } + + /// Helpers to convert Clang's SourceLocation to an MLIR Location. AaronBallman wrote: I don't know the details about CIR, so it's hard for me to say for certain. Maybe an example will help tease this out? Given: ``` #define ten 10 #define foo(x) (x + ten) int y = foo(12); ``` you get source locations like: https://godbolt.org/z/oG7fq9b1K Notice how you get `Loc=<:3:9 :2:16>>` or similar where the source location of the final expanded token and the spelling location of where the pre-preprocessed token lives are different -- which location does MLIR expect to work with? It could work with the spelling location (where tokens physically reside in the source file), or it could work with the expansion locations (where the tokens logically reside in the source file after preprocessing), or it could be ambivalent about which form it uses and will happily work with whatever. https://github.com/llvm/llvm-project/pull/113483 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CIR] Call code gen; create empty cir.func op (PR #113483)
@@ -24,9 +27,140 @@ CIRGenModule::CIRGenModule(mlir::MLIRContext &context, clang::ASTContext &astctx, const clang::CodeGenOptions &cgo, DiagnosticsEngine &diags) -: astCtx(astctx), langOpts(astctx.getLangOpts()), - theModule{mlir::ModuleOp::create(mlir::UnknownLoc())}, - target(astCtx.getTargetInfo()) {} +: builder(&context), astCtx(astctx), langOpts(astctx.getLangOpts()), + theModule{mlir::ModuleOp::create(mlir::UnknownLoc::get(&context))}, + diags(diags), target(astCtx.getTargetInfo()) {} + +mlir::Location CIRGenModule::getLoc(SourceLocation cLoc) { + assert(cLoc.isValid() && "expected valid source location"); + const SourceManager &sm = astCtx.getSourceManager(); + PresumedLoc pLoc = sm.getPresumedLoc(cLoc); + StringRef filename = pLoc.getFilename(); + return mlir::FileLineColLoc::get(builder.getStringAttr(filename), + pLoc.getLine(), pLoc.getColumn()); +} AaronBallman wrote: > SourceLocation is more of an implementation detail than mlir::Location is. That depends on perspective, IMO. From our perspective, CIR is the way in which we lower Clang's AST to an IR that eventually ends up in LLVM. The public entrypoints into CIR from Clang's perspective should be using Clang's data structures. If those need to be converted internally into MLIR-specific data structures, that's fine, but that should not leak out into the public interfaces that Clang can interact with. However, I see now that I missed something important here -- this code is under `clang/lib/CIR` and not `clang/include/clang/CIR`, so it *isn't* in the public interfaces that Clang interacts with, it is (sufficiently) hidden as an implementation detail. Sorry for missing that! > We should solve the problem of getting good diagnostics during the MLIR > passes when we actually run into the problem. It is only then that we will > know how serious the problem is, how best to solve it, and how much effort to > put into it. Solving that problem now is premature and will miss the mark in > some way. The point to these initial PRs is to ensure the community is comfortable with the design and doesn't see any glaring design concerns, so saying "we'll solve it when we get to it" on a situation we know we will hit sort of defeats the purpose. We already know the problem exists because it's one we fight with today and we already know a better way to solve it is to use source location information with at least as much fidelity as Clang is able to handle. Given that one of the benefits to CIR is for better codegen analysis that can lead to improved diagnostics, having this as an early design concern is pretty reasonable IMO. That said, we're not insisting on a change as part of this PR -- just that the CIR folks understand that this is a design concern with the facilities and at some point it may go from "concern" to "required to improve before we can proceed." https://github.com/llvm/llvm-project/pull/113483 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [Windows] Add support for emitting PGO/LTO magic strings in the Windows PE debug directory (PR #114260)
https://github.com/mikolaj-pirog updated https://github.com/llvm/llvm-project/pull/114260 From f903e7e2effbd9675d0977dc1fd176ce97f11778 Mon Sep 17 00:00:00 2001 From: "Pirog, Mikolaj Maciej" Date: Wed, 30 Oct 2024 16:30:39 +0100 Subject: [PATCH 1/8] Correct test --- clang/test/CodeGen/debug-dir-win-pe-pgi-string.c | 14 ++ 1 file changed, 14 insertions(+) create mode 100644 clang/test/CodeGen/debug-dir-win-pe-pgi-string.c diff --git a/clang/test/CodeGen/debug-dir-win-pe-pgi-string.c b/clang/test/CodeGen/debug-dir-win-pe-pgi-string.c new file mode 100644 index 00..7f1e9e35aaf120 --- /dev/null +++ b/clang/test/CodeGen/debug-dir-win-pe-pgi-string.c @@ -0,0 +1,14 @@ +// This test checks if Windows PE file compiled with +// -fprofile-generate has magic string "PGI" to indicate so. + + +// REQUIRES: system-windows + +// RUN: %clang --target=x86_64-pc-windows-msvc -fprofile-generate -fuse-ld=lld %s -o %t.exe +// RUN: dumpbin /HEADERS %t.exe | FileCheck --check-prefix=CHECK2 %s +// CHECK2: {{.*}}PGI{{.*}} + +int main(void) { + + return 0; +} From 9dfc603efb9d826c782a5b2919f910bbb6b0d4ff Mon Sep 17 00:00:00 2001 From: "Pirog, Mikolaj Maciej" Date: Wed, 30 Oct 2024 16:42:07 +0100 Subject: [PATCH 2/8] Add emitting of Windows PE PGO/LTO strings --- clang/lib/CodeGen/BackendUtil.cpp | 3 + .../CodeGen/debug-dir-win-pe-ltcg-string.c| 13 + .../CodeGen/debug-dir-win-pe-pgu-string.c | 18 ++ lld/COFF/Writer.cpp | 56 ++- ...debug_dir_magic_strings_from_section_pgi.s | 18 ++ ...debug_dir_magic_strings_from_section_pgu.s | 17 ++ llvm/include/llvm/MC/MCTargetOptions.h| 3 +- llvm/lib/MC/WinCOFFObjectWriter.cpp | 13 + 8 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 clang/test/CodeGen/debug-dir-win-pe-ltcg-string.c create mode 100644 clang/test/CodeGen/debug-dir-win-pe-pgu-string.c create mode 100644 lld/test/COFF/debug_dir_magic_strings_from_section_pgi.s create mode 100644 lld/test/COFF/debug_dir_magic_strings_from_section_pgu.s diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index f018130807519d..fcf3dc25d95fc0 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -525,6 +525,9 @@ static bool initTargetOptions(DiagnosticsEngine &Diags, Options.MCOptions.PPCUseFullRegisterNames = CodeGenOpts.PPCUseFullRegisterNames; Options.MisExpect = CodeGenOpts.MisExpect; + Options.MCOptions.PgoInstrumentation = CodeGenOpts.getProfileInstr() > 0; + Options.MCOptions.PgoUse = + CodeGenOpts.getProfileUse() > 0 || !CodeGenOpts.SampleProfileFile.empty(); return true; } diff --git a/clang/test/CodeGen/debug-dir-win-pe-ltcg-string.c b/clang/test/CodeGen/debug-dir-win-pe-ltcg-string.c new file mode 100644 index 00..a121ab8c9acc45 --- /dev/null +++ b/clang/test/CodeGen/debug-dir-win-pe-ltcg-string.c @@ -0,0 +1,13 @@ +// This test checks if Window PE file compiled with -flto option contains a magic +// string "LTCG" to indicate LTO compilation. + +// REQUIRES: system-windows + +// RUN: %clang --target=x86_64-pc-windows-msvc -flto -fuse-ld=lld %s -o %t.exe +// RUN: dumpbin /HEADERS %t.exe | FileCheck %s +// CHECK: {{.*}}LTCG{{.*}} + +int main(void) { + + return 0; +} diff --git a/clang/test/CodeGen/debug-dir-win-pe-pgu-string.c b/clang/test/CodeGen/debug-dir-win-pe-pgu-string.c new file mode 100644 index 00..12c63425aee0f5 --- /dev/null +++ b/clang/test/CodeGen/debug-dir-win-pe-pgu-string.c @@ -0,0 +1,18 @@ +// This test checks if Windows PE file contains a "PGU" string to indicate that +// it was compiled using profiling data. + +// REQUIRES: system-windows + +// RUN: %clang --target=x86_64-pc-windows-msvc -fprofile-instr-generate="%profdata" -fuse-ld=lld %s -o %t.exe +// RUN: %t.exe +// RUN: llvm-profdata merge -output=%code.profdata %profdata +// RUN: %clang --target=x86_64-pc-windows-msvc -fprofile-use=%code.profdata -fuse-ld=lld %s -o %t.exe +// RUN: dumpbin /HEADERS %t.exe | FileCheck %s + +// CHECK: {{.*}}PGU{{.*}} + +int main(void) { + + return 0; +} + diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp index 71ee5ce4685553..0ce62ad21c4634 100644 --- a/lld/COFF/Writer.cpp +++ b/lld/COFF/Writer.cpp @@ -77,6 +77,12 @@ static unsigned char dosProgram[] = { static_assert(sizeof(dosProgram) % 8 == 0, "DOSProgram size must be multiple of 8"); +static char ltcg[] = "LTCG"; +static char pgi[] = "PGI"; +static char pgu[] = "PGU"; +static char pgiSectionName[] = ".pgi"; +static char pguSectionName[] = ".pgu"; + static const int dosStubSize = sizeof(dos_header) + sizeof(dosProgram); static_assert(dosStubSize % 8 == 0, "DOSStub size must be multiple of 8"); @@ -179,6 +185,23 @@ class ExtendedDllCharacteristicsChunk : public NonSectionChunk { uint32_t characteristics = 0; }; +class DebugDirStringChunk :
[compiler-rt] [libunwind] [llvm] [cmake] Remove obsolete files, docs and CMake variables related to the standalone build (PR #112741)
ldionne wrote: Both CI failures seem to be unrelated. https://github.com/llvm/llvm-project/pull/112741 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix the post-filtering heuristic for GSLPointer. (PR #114044)
@@ -793,3 +794,44 @@ void test13() { } } // namespace GH100526 + +namespace LifetimeboundInterleave { + +const std::string& Ref(const std::string& abc [[clang::lifetimebound]]); usx95 wrote: Can you also add the following tests: `std::string_view TakeSv(std::string_view abc [[clang::lifetimebound]]);` `std::string_view sv = TakeSv(std::string()); // warning.` `std::string_view TakeStrRef(const std::string& abc [[clang::lifetimebound]]);` `std::string_view sv = TakeStrRef(std::string()); // warning.` `std::string_view TakeStr(std::string abc [[clang::lifetimebound]]);` `std::string_view sv = TakeStr(std::string()); // Ok.` https://github.com/llvm/llvm-project/pull/114044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Fix the post-filtering heuristic for GSLPointer. (PR #114044)
https://github.com/usx95 edited https://github.com/llvm/llvm-project/pull/114044 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [libcxx] [llvm] [libc++] Replace LIBCXX_ENABLE_STATIC_ABI_LIBRARY & friends by a new LIBCXX_CXX_ABI choice (PR #112978)
@@ -230,11 +230,22 @@ else() endif() set(LIBCXX_SUPPORTED_ABI_LIBRARIES none libcxxabi system-libcxxabi libcxxrt libstdc++ libsupc++ vcruntime) -set(LIBCXX_CXX_ABI "${LIBCXX_DEFAULT_ABI_LIBRARY}" CACHE STRING "Specify C++ ABI library to use. Supported values are ${LIBCXX_SUPPORTED_ABI_LIBRARIES}.") -if (NOT "${LIBCXX_CXX_ABI}" IN_LIST LIBCXX_SUPPORTED_ABI_LIBRARIES) - message(FATAL_ERROR "Unsupported C++ ABI library: '${LIBCXX_CXX_ABI}'. Supported values are ${LIBCXX_SUPPORTED_ABI_LIBRARIES}.") -endif() - +set(LIBCXX_CXX_ABI "${LIBCXX_DEFAULT_ABI_LIBRARY}" CACHE STRING + "Specify the C++ ABI library to use for the shared and the static libc++ libraries. Supported values are ${LIBCXX_SUPPORTED_ABI_LIBRARIES}. + This CMake option also supports \"consumption specifiers\", which specify how the selected ABI library should be consumed by + libc++. The supported specifiers are: + - `shared`: The selected ABI library should be used as a shared library. + - `static`: The selected ABI library should be used as a static library. + - `merged`: The selected ABI library should be a static library whose object files will be merged directly into the produced libc++ library. ldionne wrote: I did, in fact I started with that but eventually renamed it to `merged` since it's not necessarily implemented with CMake object libraries. Possibilities: ``` merged-libcxxabi object-libcxxabi ``` Or we can swap it around and have this instead: ``` libcxxabi-merged libcxxabi-objects ``` IMO `merged` makes more sense than `object` because for e.g. `libsupcxx-objects` it makes it look as-if we were using the object files of the library, when in reality we're using the static archive and merging it into our dylib (in practice I guess those are the same thing under the hood, but I have a different mental model). https://github.com/llvm/llvm-project/pull/112978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix for codegen Crash in Clang when using locator omp_all_memory with depobj construct (PR #114221)
@@ -36,6 +36,8 @@ int main(int argc, char **argv) { #pragma omp depobj(b) update(mutexinoutset) #pragma omp depobj(a) depend(iterator(char *p = argv[argc]:argv[0]:-1), out: p[0]) (void)tmain(a), tmain(b); + omp_depend_t obj; shiltian wrote: Auto-gen check lines please. You might want do do a pre-commit for existing test. https://github.com/llvm/llvm-project/pull/114221 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Make source locations space usage diagnostics numbers easier to read (PR #114999)
https://github.com/bricknerb created https://github.com/llvm/llvm-project/pull/114999 Instead of writing "12345678B", write "12345678B (12.34MB)". >From 6f3c9f95f7ad558659bc7d868ab4d5e5f6af05c0 Mon Sep 17 00:00:00 2001 From: Boaz Brickner Date: Tue, 5 Nov 2024 15:29:10 +0100 Subject: [PATCH] [clang] Make source locations space usage diagnostics numbers easier to read Instead of write "12345678B", write "12345678B (12.34MB)". --- .../clang/Basic/DiagnosticCommonKinds.td | 11 --- clang/lib/Basic/SourceManager.cpp | 33 +-- clang/test/Lexer/SourceLocationsOverflow.c| 10 +++--- clang/test/Misc/sloc-usage.cpp| 4 +-- 4 files changed, 43 insertions(+), 15 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td b/clang/include/clang/Basic/DiagnosticCommonKinds.td index ae709e45a700a1..457abea0b81471 100644 --- a/clang/include/clang/Basic/DiagnosticCommonKinds.td +++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td @@ -389,13 +389,14 @@ def remark_sloc_usage : Remark< "source manager location address space usage:">, InGroup>, DefaultRemark, ShowInSystemHeader; def note_total_sloc_usage : Note< - "%0B in local locations, %1B in locations loaded from AST files, for a total " - "of %2B (%3%% of available space)">; + "%0B (%1B) in local locations, %2B (%3B) " + "in locations loaded from AST files, for a total of %4B (%5B) " + "(%6%% of available space)">; def note_file_sloc_usage : Note< - "file entered %0 time%s0 using %1B of space" - "%plural{0:|: plus %2B for macro expansions}2">; + "file entered %0 time%s0 using %1B (%2B) of space" + "%plural{0:|: plus %3B (%4B) for macro expansions}3">; def note_file_misc_sloc_usage : Note< - "%0 additional files entered using a total of %1B of space">; + "%0 additional files entered using a total of %1B (%2B) of space">; // Modules def err_module_format_unhandled : Error< diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 65a8a7253e054f..cbc2b840150321 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -2227,6 +2227,28 @@ LLVM_DUMP_METHOD void SourceManager::dump() const { } } +static std::string NumberToHumanString(uint64_t number) { + static constexpr std::array, 4> Units = { + {{1'000'000'000'000UL, 'T'}, + {1'000'000'000UL, 'G'}, + {1'000'000UL, 'M'}, + {1'000UL, 'k'}}}; + + std::string human_string; + llvm::raw_string_ostream human_string_stream(human_string); + for (const auto &[UnitSize, UnitSign] : Units) { +if (number >= UnitSize) { + human_string_stream << llvm::format( + "%.2f%c", number / static_cast(UnitSize), UnitSign); + break; +} + } + if (human_string.empty()) { +human_string_stream << number; + } + return human_string; +} + void SourceManager::noteSLocAddressSpaceUsage( DiagnosticsEngine &Diag, std::optional MaxNotes) const { struct Info { @@ -2296,7 +2318,9 @@ void SourceManager::noteSLocAddressSpaceUsage( int UsagePercent = static_cast(100.0 * double(LocalUsage + LoadedUsage) / MaxLoadedOffset); Diag.Report(SourceLocation(), diag::note_total_sloc_usage) -<< LocalUsage << LoadedUsage << (LocalUsage + LoadedUsage) << UsagePercent; + << LocalUsage << NumberToHumanString(LocalUsage) << LoadedUsage + << NumberToHumanString(LoadedUsage) << (LocalUsage + LoadedUsage) + << NumberToHumanString(LocalUsage + LoadedUsage) << UsagePercent; // Produce notes on sloc address space usage for each file with a high usage. uint64_t ReportedSize = 0; @@ -2304,14 +2328,17 @@ void SourceManager::noteSLocAddressSpaceUsage( llvm::make_range(SortedUsage.begin(), SortedEnd)) { Diag.Report(FileInfo.Loc, diag::note_file_sloc_usage) << FileInfo.Inclusions << FileInfo.DirectSize -<< (FileInfo.TotalSize - FileInfo.DirectSize); +<< NumberToHumanString(FileInfo.DirectSize) +<< (FileInfo.TotalSize - FileInfo.DirectSize) +<< NumberToHumanString(FileInfo.TotalSize - FileInfo.DirectSize); ReportedSize += FileInfo.TotalSize; } // Describe any remaining usage not reported in the per-file usage. if (ReportedSize != CountedSize) { Diag.Report(SourceLocation(), diag::note_file_misc_sloc_usage) -<< (SortedUsage.end() - SortedEnd) << CountedSize - ReportedSize; +<< (SortedUsage.end() - SortedEnd) << CountedSize - ReportedSize +<< NumberToHumanString(CountedSize - ReportedSize); } } diff --git a/clang/test/Lexer/SourceLocationsOverflow.c b/clang/test/Lexer/SourceLocationsOverflow.c index f058c09428e6e7..26b0d204c49ff5 100644 --- a/clang/test/Lexer/SourceLocationsOverflow.c +++ b/clang/test/Lexer/SourceLocationsOverflow.c @@ -3,17 +3,17 @@ // CHECK-NEXT: inc1.h{{.*}}: fatal error: translation unit is too large for Clang to process: ran out of source location
[clang] [ASTWriter] Detect more non-affecting FileIDs to reduce source location duplication (PR #112015)
ilya-biryukov wrote: > This is unexpected and I think it breaks the correctness of clang-scan-deps. > I think we might need to take your patch a bit further and make it so that > `ASTWriter::WriteInputFiles()` doesn't care whether the SLocEntry associated > with the file through `Module::DefinitionLoc` is loaded or local. I want to dig into it a little more, but the problem is not introduced with this PR, so I suggest to do this in a follow-up in the interest of keeping this PR focused. The particular challenge on my mind that makes it worth exploring in a different PR is that `InputFileRef`s that are written for two purposes: - as ways to implement clang-scan-deps (e.g. `IsModuleMapFile` and `IsTopLevel` flags seem to be used solely by clang-scan-deps), - as a way to write internal `SourceManager` data structures (`SLocEntry`). This seems to be the primary purposes for which they were introduced into the serialized format (I didn't check the history, though, it's just a guess). It might be desirable to write some loaded locations for the former, but it goes against the idea for the latter. https://github.com/llvm/llvm-project/pull/112015 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64]Fix Name and Mangle name for scalar fp8 (PR #114983)
https://github.com/CarolineConcatto edited https://github.com/llvm/llvm-project/pull/114983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Correctly initialize placeholder fields from their initializers (PR #114196)
@@ -5560,6 +5560,25 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc, Init, InitializationContext->Context); } +static FieldDecl *FindFieldDeclInstantiationPattern(const ASTContext &Ctx, +FieldDecl *Field) { + if (FieldDecl *Pattern = Ctx.getInstantiatedFromUnnamedFieldDecl(Field)) +return Pattern; + auto *ParentRD = cast(Field->getParent()); + CXXRecordDecl *ClassPattern = ParentRD->getTemplateInstantiationPattern(); + DeclContext::lookup_result Lookup = + ClassPattern->lookup(Field->getDeclName()); + auto Rng = llvm::make_filter_range(Lookup, [] (auto && L) { erichkeane wrote: Oh wait, disregard. The `L` is a `lookup_result`, not a thing, so I dont think IsaPred works. https://github.com/llvm/llvm-project/pull/114196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [compiler-rt] [libcxx] [llvm] [libc++] Replace LIBCXX_ENABLE_STATIC_ABI_LIBRARY & friends by a new LIBCXX_CXX_ABI choice (PR #112978)
@@ -230,11 +230,22 @@ else() endif() set(LIBCXX_SUPPORTED_ABI_LIBRARIES none libcxxabi system-libcxxabi libcxxrt libstdc++ libsupc++ vcruntime) -set(LIBCXX_CXX_ABI "${LIBCXX_DEFAULT_ABI_LIBRARY}" CACHE STRING "Specify C++ ABI library to use. Supported values are ${LIBCXX_SUPPORTED_ABI_LIBRARIES}.") -if (NOT "${LIBCXX_CXX_ABI}" IN_LIST LIBCXX_SUPPORTED_ABI_LIBRARIES) - message(FATAL_ERROR "Unsupported C++ ABI library: '${LIBCXX_CXX_ABI}'. Supported values are ${LIBCXX_SUPPORTED_ABI_LIBRARIES}.") -endif() - +set(LIBCXX_CXX_ABI "${LIBCXX_DEFAULT_ABI_LIBRARY}" CACHE STRING + "Specify the C++ ABI library to use for the shared and the static libc++ libraries. Supported values are ${LIBCXX_SUPPORTED_ABI_LIBRARIES}. + This CMake option also supports \"consumption specifiers\", which specify how the selected ABI library should be consumed by + libc++. The supported specifiers are: + - `shared`: The selected ABI library should be used as a shared library. + - `static`: The selected ABI library should be used as a static library. + - `merged`: The selected ABI library should be a static library whose object files will be merged directly into the produced libc++ library. + + A consumption specifier is provided by appending it to the name of the library, such as `LIBCXX_CXX_ABI=merged-libcxxabi`. + If no consumption specifier is provided, the libc++ shared library will default to using a shared ABI library, and the + libc++ static library will default to using a static ABI library.") +set(LIBCXX_ABILIB_FOR_SHARED "${LIBCXX_CXX_ABI}" CACHE STRING "C++ ABI library to use for the shared libc++ library.") +set(LIBCXX_ABILIB_FOR_STATIC "${LIBCXX_CXX_ABI}" CACHE STRING "C++ ABI library to use for the static libc++ library.") ldionne wrote: I actually wanted to rename `LIBCXX_CXX_ABI` to `LIBCXX_ABILIB` in a future patch, that's why I went with `LIBCXX_ABILIB_foo`. I am not a huge fan of `LIBCXX_CXX_ABI` since I find it easily confused with the various `LIBCXXABI_` variables, for example `LIBCXXABI_LIBCXX_PATH` (which makes my head spin). `LIBCXX_CXX_ABI` could also be a choice of e.g. Itanium ABI vs MSVC ABI instead of the library implementing the ABI. The second aspect of this name choice is to disambiguate what the setting is *used for* vs the type of ABI library we're searching. For example, `LIBCXX_CXX_ABI_STATIC` could either represent the abilib to use for linking into the static library (which it is), or it could represent the static variant of the abilib we've found (which it isn't). By using `FOR_SHARED` and `FOR_STATIC` as a suffix, I felt that it disambiguated this pretty clearly (although it makes the names less cute). Let me know if that makes sense to you or if you still prefer `LIBCXX_CXX_ABI` -- if so, we might be able to figure out another naming scheme altogether. https://github.com/llvm/llvm-project/pull/112978 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] [libcxxabi] [libunwind] [llvm] [libc++] Unify the benchmarks with the test suite (PR #101399)
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/101399 >From 504518235aa19ab517b59e41c003b86dc610bbb0 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 25 Jul 2024 10:41:10 -0400 Subject: [PATCH] [libc++] Unify the benchmarks with the test suite Instead of building the benchmarks separately via CMake and running them separately from the test suite, this patch merges the benchmarks into the test suite and handles both uniformly. As a result: - It is now possible to run individual benchmarks like we run tests (e.g. using libcxx-lit), which is a huge quality-of-life improvement. - The benchmarks will be run under exactly the same configuration as the rest of the tests, which is a nice simplification. This does mean that one has to be careful to enable the desired optimization flags when running benchmarks, but that is easy with e.g. `libcxx-lit <...> --param optimization=speed`. - Benchmarks can use the same annotations as the rest of the test suite, such as `// UNSUPPORTED` & friends. When running the tests via `check-cxx`, we only compile the benchmarks because running them would be too time consuming. This introduces a bit of complexity in the testing setup, and instead it would be better to allow passing a --dry-run flag to GoogleBenchmark executables, which is the topic of a GoogleBenchmark issue. I am not really satisfied with the layering violation of adding the %{benchmark_flags} substitution to cmake-bridge, however I believe this can be improved in the future. --- .github/workflows/libcxx-build-and-test.yaml | 3 - libcxx/CMakeLists.txt | 13 +- libcxx/docs/TestingLibcxx.rst | 49 ++--- libcxx/docs/VendorDocumentation.rst | 12 +- libcxx/test/CMakeLists.txt| 15 +- libcxx/test/benchmarks/CMakeLists.txt | 185 +- .../atomic_wait_vs_mutex_lock.bench.cpp | 4 - libcxx/test/benchmarks/lit.cfg.py.in | 23 --- libcxx/test/benchmarks/lit.site.cfg.py.in | 10 - libcxx/test/configs/cmake-bridge.cfg.in | 1 + libcxx/utils/ci/run-buildbot | 10 - libcxx/utils/libcxx/test/config.py| 2 +- libcxx/utils/libcxx/test/format.py| 31 ++- libcxx/utils/libcxx/test/googlebenchmark.py | 125 libcxx/utils/libcxx/test/params.py| 10 + libcxxabi/test/configs/cmake-bridge.cfg.in| 1 + libunwind/test/configs/cmake-bridge.cfg.in| 1 + 17 files changed, 88 insertions(+), 407 deletions(-) delete mode 100644 libcxx/test/benchmarks/lit.cfg.py.in delete mode 100644 libcxx/test/benchmarks/lit.site.cfg.py.in delete mode 100644 libcxx/utils/libcxx/test/googlebenchmark.py diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml index 657e7f1e7f0f7e..32e9350d7353da 100644 --- a/.github/workflows/libcxx-build-and-test.yaml +++ b/.github/workflows/libcxx-build-and-test.yaml @@ -157,9 +157,6 @@ jobs: 'generic-no-rtti', 'generic-optimized-speed', 'generic-static', - # TODO Find a better place for the benchmark and bootstrapping builds to live. They're either very expensive - # or don't provide much value since the benchmark run results are too noise on the bots. - 'benchmarks', 'bootstrapping-build' ] machine: [ 'libcxx-runners-8-set' ] diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 95a7d10f055ea7..4993e73e7841ce 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -150,12 +150,13 @@ message(STATUS "Using libc++ testing configuration: ${LIBCXX_TEST_CONFIG}") set(LIBCXX_TEST_PARAMS "" CACHE STRING "A list of parameters to run the Lit test suite with.") -# Benchmark options --- -option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependencies" ON) - -set(LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT --benchmark_min_time=0.01) -set(LIBCXX_BENCHMARK_TEST_ARGS "${LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT}" CACHE STRING -"Arguments to pass when running the benchmarks using check-cxx-benchmarks") +# TODO: On Windows and MinGW, disable the benchmarks since we don't know how to build GoogleBenchmark yet +if (WIN32 OR MINGW) + set(_include_benchmarks OFF) +else() + set(_include_benchmarks ON) +endif() +option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependencies" ${_include_benchmarks}) option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS}) set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING diff --git a/libcxx/docs/TestingLibcxx.rst b/libcxx/docs/TestingLibcxx.rst index 3d43a66745bedf..6d2c954489f62e 100644 --- a/libcxx/docs/TestingLibcxx.rst +++ b/libcxx/docs/TestingLibcxx.rst @@ -392,6 +392,10 @@ Test Filenames`_ when determining the names for new test files.
[clang] [HLSL] add IsTypedResourceElementCompatible type trait (PR #114864)
@@ -2163,6 +2163,50 @@ static void BuildFlattenedTypeList(QualType BaseTy, } } +bool SemaHLSL::IsTypedResourceElementCompatible(clang::QualType QT) { + if (QT.isNull()) +return false; + + // check if the outer type was an array type + if (QT->isArrayType()) +return false; + + llvm::SmallVector QTTypes; + BuildFlattenedTypeList(QT, QTTypes); + + assert(QTTypes.size() > 0 && llvm-beanz wrote: That's an incomplete type, not an empty struct. What about something like: ```hlsl struct EmptyStruct {}; _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(EmptyStruct), ""); struct EmptyDerived : EmptyStruct {}; _Static_assert(!__builtin_hlsl_is_typed_resource_element_compatible(EmptyDerived), ""); struct EmptyBase : EmptyStruct { int4 V; }; _Static_assert(__builtin_hlsl_is_typed_resource_element_compatible(EmptyBase), ""); ``` We frequently find bugs in DXC with cases of empty structs, empty base classes, etc. https://github.com/llvm/llvm-project/pull/114864 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add steakhal to the Clang Static Analyzer maintainers (PR #114991)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Balazs Benics (steakhal) Changes I've been contributing to the Clang Static Analyzer for a while now. I think from 2019, or something like that. I've ensured the quality of the Static Analyzer releases for the last ~4-6 releases now, with testing, fixing and backporting patches; also writing comprehensive release notes for each release. I have a strong sense of ownership of the code I contribute. I follow the issue tracker, and also try to follow and participate in RFCs on Discourse if I'm not overloaded. I also check Discord time-to-time, but I rarely see anything there. You can find the maintainer section of the LLVM DeveloperPolicy [here](https://llvm.org/docs/DeveloperPolicy.html#maintainers) to read more about the responsibilities. --- Full diff: https://github.com/llvm/llvm-project/pull/114991.diff 1 Files Affected: - (modified) clang/Maintainers.rst (+2) ``diff diff --git a/clang/Maintainers.rst b/clang/Maintainers.rst index 27255a9c0319b4..4d865c3a6889e5 100644 --- a/clang/Maintainers.rst +++ b/clang/Maintainers.rst @@ -131,6 +131,8 @@ Clang static analyzer | Gábor Horváth | xazax.hun\@gmail.com (email), xazax.hun (Phabricator), Xazax-hun (GitHub) +| Balázs Benics +| benicsbalazs\@gmail.com (email), steakhal (Phabricator), steakhal (GitHub) Compiler options `` https://github.com/llvm/llvm-project/pull/114991 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64]Fix Name and Mangle name for scalar fp8 (PR #114983)
https://github.com/CarolineConcatto updated https://github.com/llvm/llvm-project/pull/114983 >From 3839546afb0136507e8220803389e1ef5571f1bf Mon Sep 17 00:00:00 2001 From: Caroline Concatto Date: Tue, 5 Nov 2024 09:53:08 + Subject: [PATCH 1/2] [Clang][AArch64]Fix Name and Mangle name for scalar fp8 The scalar __mfp8 type has the wrong name and mangle name in AArch64SVEACLETypes.def According to the ACLE[1] the name should be __mfp8, then mangle name __u6mfp8. This patch fixes this problem by replacing the Name __MFloat8_t by __mfp8 and the Mangle Name __MFloat8_t by __u6mfp8 And we revert the incorrect typedef in NeonEmitter. [1]https://github.com/ARM-software/acle --- .../clang/Basic/AArch64SVEACLETypes.def | 2 +- clang/test/AST/arm-mfp8.cpp | 57 clang/test/CodeGen/aarch64-debug-types.c | 6 +- clang/test/CodeGen/arm-mfp8.c | 2 +- clang/test/Sema/arm-mfp8.c| 4 +- clang/test/Sema/arm-mfp8.cpp | 65 ++- clang/utils/TableGen/NeonEmitter.cpp | 2 +- 7 files changed, 69 insertions(+), 69 deletions(-) diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def index 62f6087e962466..cec5ab19a01730 100644 --- a/clang/include/clang/Basic/AArch64SVEACLETypes.def +++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def @@ -200,7 +200,7 @@ SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", SveBoolx4, SveBoolx4T SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy) -AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8_t", "__MFloat8_t", MFloat8, MFloat8Ty, 1, 8, 1) +AARCH64_VECTOR_TYPE_MFLOAT("__mfp8", "__u6mfp8", MFloat8, MFloat8Ty, 1, 8, 1) AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x8_t", "__MFloat8x8_t", MFloat8x8, MFloat8x8Ty, 8, 8, 1) AARCH64_VECTOR_TYPE_MFLOAT("__MFloat8x16_t", "__MFloat8x16_t", MFloat8x16, MFloat8x16Ty, 16, 8, 1) diff --git a/clang/test/AST/arm-mfp8.cpp b/clang/test/AST/arm-mfp8.cpp index 51bebba067eb9f..195c734fc753e5 100644 --- a/clang/test/AST/arm-mfp8.cpp +++ b/clang/test/AST/arm-mfp8.cpp @@ -5,7 +5,6 @@ /* Various contexts where type __mfp8 can appear. */ -#include /* Namespace */ namespace { __mfp8 f2n; @@ -13,7 +12,7 @@ namespace { } //CHECK: |-NamespaceDecl {{.*}} -//CHECK-NEXT: | |-VarDecl {{.*}} f2n '__mfp8':'__MFloat8_t' +//CHECK-NEXT: | |-VarDecl {{.*}} f2n '__mfp8' //CHECK-NEXT: | `-VarDecl {{.*}} arr1n '__mfp8[10]' @@ -24,14 +23,14 @@ namespace { return f1n; } //CHECK:|-FunctionDecl {{.*}} func1n 'const __mfp8 (const __mfp8)' -//CHECK:| `-VarDecl {{.*}} f1n '__mfp8':'__MFloat8_t' -//CHECK-NEXT: |-BinaryOperator {{.*}} '__mfp8':'__MFloat8_t' lvalue '=' -//CHECK-NEXT: | |-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue Var {{.*}} 'f1n' '__mfp8':'__MFloat8_t' -//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' -//CHECK-NEXT: | `-DeclRefExpr {{.*}} 'const __mfp8':'const __MFloat8_t' lvalue ParmVar {{.*}} 'mfp8' 'const __mfp8':'const __MFloat8_t' +//CHECK:| `-VarDecl {{.*}} f1n '__mfp8' +//CHECK-NEXT: |-BinaryOperator {{.*}} '__mfp8' lvalue '=' +//CHECK-NEXT: | |-DeclRefExpr {{.*}} '__mfp8' lvalue Var {{.*}} 'f1n' '__mfp8' +//CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '__mfp8' +//CHECK-NEXT: | `-DeclRefExpr {{.*}} 'const __mfp8' lvalue ParmVar {{.*}} 'mfp8' 'const __mfp8' //CHECK-NEXT:`-ReturnStmt {{.*}} -//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' -//CHECK-NEXT: `-DeclRefExpr {{.*}} '__mfp8':'__MFloat8_t' lvalue Var {{.*}} 'f1n' '__mfp8':'__MFloat8_t' +//CHECK-NEXT: `-ImplicitCastExpr {{.*}} '__mfp8' +//CHECK-NEXT: `-DeclRefExpr {{.*}} '__mfp8' lvalue Var {{.*}} 'f1n' '__mfp8' /* Class */ @@ -39,7 +38,7 @@ namespace { class C1 { __mfp8 f1c; static const __mfp8 f2c; - volatile __MFloat8_t f3c; + volatile __mfp8 f3c; public: C1(__mfp8 arg) : f1c(arg), f3c(arg) { } __mfp8 func1c(__mfp8 arg ) { @@ -51,31 +50,31 @@ class C1 { }; //CHECK: | |-CXXRecordDecl {{.*}} referenced class C1 -//CHECK-NEXT: | |-FieldDecl {{.*}} f1c '__mfp8':'__MFloat8_t' -//CHECK-NEXT: | |-VarDecl {{.*}} f2c 'const __mfp8':'const __MFloat8_t' static -//CHECK-NEXT: | |-FieldDecl {{.*}} f3c 'volatile __MFloat8_t' +//CHECK-NEXT: | |-FieldDecl {{.*}} f1c '__mfp8' +//CHECK-NEXT: | |-VarDecl {{.*}} f2c 'const __mfp8' static +//CHECK-NEXT: | |-FieldDecl {{.*}} f3c 'volatile __mfp8' //CHECK-NEXT: | |-AccessSpecDecl {{.*}} //CHECK-NEXT: | |-CXXConstructorDecl {{.*}} C1 'void (__mfp8)' implicit-inline -//CHECK-NEXT: | | |-ParmVarDecl {{.*}} arg '__mfp8':'__MFloat8_t' -//CHECK-NEXT: | | |-CXXCtorInitializer {{.*}} 'f1c' '__mfp8':'__MFloat8_t' -//CHECK-NEXT: | | | `-ImplicitCastExpr {{.*}} '__mfp8':'__MFloat8_t' -//CHECK-NEXT: | | | `-DeclRefExpr {{.*}} '__mfp8':'_
[clang] [ASTWriter] Detect more non-affecting FileIDs to reduce source location duplication (PR #112015)
@@ -43,7 +43,7 @@ module third {} // CHECK-NEXT: "command-line": [ // CHECK-NEXT: "-cc1", // CHECK: "-fmodule-map-file=[[PREFIX]]/second/second/module.modulemap" -// CHECK-NOT: "-fmodule-map-file=[[PREFIX]]/second/second/sub.modulemap" +// CHECK-NEXT: "-fmodule-map-file=[[PREFIX]]/second/second/sub.modulemap" ilya-biryukov wrote: I've updated the code to keep the old behavior in that case, PTAL. https://github.com/llvm/llvm-project/pull/112015 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][AArch64]Fix Name and Mangle name for scalar fp8 (PR #114983)
https://github.com/CarolineConcatto edited https://github.com/llvm/llvm-project/pull/114983 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ba60f6d - Remove leftover uses of llvm::Type::getPointerTo() (#114993)
Author: Youngsuk Kim Date: 2024-11-05T10:00:23-05:00 New Revision: ba60f6dc03126d8b26bba5be6338fd8b3580bd25 URL: https://github.com/llvm/llvm-project/commit/ba60f6dc03126d8b26bba5be6338fd8b3580bd25 DIFF: https://github.com/llvm/llvm-project/commit/ba60f6dc03126d8b26bba5be6338fd8b3580bd25.diff LOG: Remove leftover uses of llvm::Type::getPointerTo() (#114993) `llvm::Type::getPointerTo()` is to be deprecated. Replace remaining uses of it. Added: Modified: clang/lib/CodeGen/CGObjCMac.cpp llvm/tools/bugpoint/CrashDebugger.cpp Removed: diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 47ea636c756438..7caf801d22e0b1 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -365,7 +365,7 @@ class ObjCCommonTypesHelper { /// GcReadWeakFn -- LLVM objc_read_weak (id *src) function. llvm::FunctionCallee getGcReadWeakFn() { // id objc_read_weak (id *) -llvm::Type *args[] = { ObjectPtrTy->getPointerTo() }; +llvm::Type *args[] = {CGM.UnqualPtrTy}; llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false); return CGM.CreateRuntimeFunction(FTy, "objc_read_weak"); @@ -374,7 +374,7 @@ class ObjCCommonTypesHelper { /// GcAssignWeakFn -- LLVM objc_assign_weak function. llvm::FunctionCallee getGcAssignWeakFn() { // id objc_assign_weak (id, id *) -llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo() }; +llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false); return CGM.CreateRuntimeFunction(FTy, "objc_assign_weak"); @@ -383,7 +383,7 @@ class ObjCCommonTypesHelper { /// GcAssignGlobalFn -- LLVM objc_assign_global function. llvm::FunctionCallee getGcAssignGlobalFn() { // id objc_assign_global(id, id *) -llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo() }; +llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false); return CGM.CreateRuntimeFunction(FTy, "objc_assign_global"); @@ -392,7 +392,7 @@ class ObjCCommonTypesHelper { /// GcAssignThreadLocalFn -- LLVM objc_assign_threadlocal function. llvm::FunctionCallee getGcAssignThreadLocalFn() { // id objc_assign_threadlocal(id src, id * dest) -llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo() }; +llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false); return CGM.CreateRuntimeFunction(FTy, "objc_assign_threadlocal"); @@ -401,8 +401,7 @@ class ObjCCommonTypesHelper { /// GcAssignIvarFn -- LLVM objc_assign_ivar function. llvm::FunctionCallee getGcAssignIvarFn() { // id objc_assign_ivar(id, id *, ptr diff _t) -llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo(), - CGM.PtrDiffTy }; +llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy, CGM.PtrDiffTy}; llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false); return CGM.CreateRuntimeFunction(FTy, "objc_assign_ivar"); @@ -419,7 +418,7 @@ class ObjCCommonTypesHelper { /// GcAssignStrongCastFn -- LLVM objc_assign_strongCast function. llvm::FunctionCallee getGcAssignStrongCastFn() { // id objc_assign_strongCast(id, id *) -llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo() }; +llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false); return CGM.CreateRuntimeFunction(FTy, "objc_assign_strongCast"); @@ -554,7 +553,7 @@ class ObjCTypesHelper : public ObjCCommonTypesHelper { /// ExceptionTryEnterFn - LLVM objc_exception_try_enter function. llvm::FunctionCallee getExceptionTryEnterFn() { -llvm::Type *params[] = { ExceptionDataTy->getPointerTo() }; +llvm::Type *params[] = {CGM.UnqualPtrTy}; return CGM.CreateRuntimeFunction( llvm::FunctionType::get(CGM.VoidTy, params, false), "objc_exception_try_enter"); @@ -562,7 +561,7 @@ class ObjCTypesHelper : public ObjCCommonTypesHelper { /// ExceptionTryExitFn - LLVM objc_exception_try_exit function. llvm::FunctionCallee getExceptionTryExitFn() { -llvm::Type *params[] = { ExceptionDataTy->getPointerTo() }; +llvm::Type *params[] = {CGM.UnqualPtrTy}; return CGM.CreateRuntimeFunction( llvm::FunctionType::get(CGM.VoidTy, params, false), "objc_exception_try_exit"); @@ -570,7 +569,7 @@ class ObjCTypesHelper : public ObjCCommonTypesHelper { /// ExceptionExtractFn - LLVM objc_exception_extract function. llvm::FunctionCallee getExceptionExtractFn() { -llvm::Type *params[] = { ExceptionDataTy->getPointerTo() }; +llvm::Type *params[] = {CGM.Unqual
[clang] [llvm] Remove leftover uses of llvm::Type::getPointerTo() (PR #114993)
https://github.com/JOE1994 closed https://github.com/llvm/llvm-project/pull/114993 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Correctly initialize placeholder fields from their initializers (PR #114196)
@@ -5560,6 +5560,25 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc, Init, InitializationContext->Context); } +static FieldDecl *FindFieldDeclInstantiationPattern(const ASTContext &Ctx, +FieldDecl *Field) { + if (FieldDecl *Pattern = Ctx.getInstantiatedFromUnnamedFieldDecl(Field)) +return Pattern; + auto *ParentRD = cast(Field->getParent()); + CXXRecordDecl *ClassPattern = ParentRD->getTemplateInstantiationPattern(); + DeclContext::lookup_result Lookup = + ClassPattern->lookup(Field->getDeclName()); + auto Rng = llvm::make_filter_range(Lookup, [] (auto && L) { + return isa(*L); + }); + // FIXME: this breaks clang/test/Modules/pr28812.cpp + // assert(std::distance(Rng.begin(), Rng.end()) <= 1 + // && "Duplicated instantiation pattern for field decl"); + if(Rng.empty()) erichkeane wrote: woops, I meant 'below'. Basically, just move 5577 to above 5574. Sorry about that :/ Basically, doing the `std::distance` check (when we re-enable it) before checking for `empty` seems silly. https://github.com/llvm/llvm-project/pull/114196 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [emacs][clang-format] Add elisp API for clang-format on git diffs (PR #112792)
https://github.com/goldsteinn updated https://github.com/llvm/llvm-project/pull/112792 >From 802764e879862541e205ba1a070824b71d2fef9a Mon Sep 17 00:00:00 2001 From: Noah Goldstein Date: Thu, 17 Oct 2024 17:31:24 -0500 Subject: [PATCH 01/10] [emacs][clang-format] Add elisp API for clang-format on git diffs New proposed function `clang-format-git-diffs`. It is the same as calling `clang-format-region` on all diffs between the content of a buffer-file and the content of the file at git revision HEAD. This is essentially the same thing as: `git-clang-format -f {filename}` If the current buffer is saved. The motivation is many project (LLVM included) both have code that is non-compliant with there clang-format style and disallow unrelated format diffs in PRs. This means users can't just run `clang-format-buffer` on the buffer they are working on, and need to manually go through all the regions by hand to get them formatted. This is both an error prone and annoying workflow. --- clang/tools/clang-format/clang-format.el | 159 --- 1 file changed, 144 insertions(+), 15 deletions(-) diff --git a/clang/tools/clang-format/clang-format.el b/clang/tools/clang-format/clang-format.el index fb943b7b722f8a..d3f874de41c550 100644 --- a/clang/tools/clang-format/clang-format.el +++ b/clang/tools/clang-format/clang-format.el @@ -146,18 +146,97 @@ is a zero-based file offset, assuming ‘utf-8-unix’ coding." (lambda (byte &optional _quality _coding-system) (byte-to-position (1+ byte) -;;;###autoload -(defun clang-format-region (start end &optional style assume-file-name) - "Use clang-format to format the code between START and END according to STYLE. -If called interactively uses the region or the current statement if there is no -no active region. If no STYLE is given uses `clang-format-style'. Use -ASSUME-FILE-NAME to locate a style config file, if no ASSUME-FILE-NAME is given -uses the function `buffer-file-name'." - (interactive - (if (use-region-p) - (list (region-beginning) (region-end)) - (list (point) (point - +(defun clang-format--git-diffs-get-diff-lines (file-orig file-new) + "Return all line regions that contain diffs between FILE-ORIG and +FILE-NEW. If there is no diff 'nil' is returned. Otherwise the +return is a 'list' of lines in the format '--lines=:' +which can be passed directly to 'clang-format'" + ;; Temporary buffer for output of diff. + (with-temp-buffer +(let ((status (call-process + "diff" + nil + (current-buffer) + nil + ;; Binary diff has different behaviors that we + ;; aren't interested in. + "-a" + ;; Printout changes as only the line groups. + "--changed-group-format=--lines=%dF:%dL " + ;; Ignore unchanged content. + "--unchanged-group-format=" + file-orig + file-new + ) + ) + (stderr (concat (if (zerop (buffer-size)) "" ": ") + (buffer-substring-no-properties + (point-min) (line-end-position) + (when (stringp status) +(error "(diff killed by signal %s%s)" status stderr)) + (unless (= status 0) +(unless (= status 1) + (error "(diff returned unsuccessfully %s%s)" status stderr))) + + + (if (= status 0) + ;; Status == 0 -> no Diff. + nil +(progn + ;; Split "--lines=:... --lines=:" output to + ;; a list for return. + (s-split + " " + (string-trim +(buffer-substring-no-properties + (point-min) (point-max) + +(defun clang-format--git-diffs-get-git-head-file () + "Returns a temporary file with the content of 'buffer-file-name' at +git revision HEAD. If the current buffer is either not a file or not +in a git repo, this results in an error" + ;; Needs current buffer to be a file + (unless (buffer-file-name) +(error "Buffer is not visiting a file")) + ;; Need to be able to find version control (git) root + (unless (vc-root-dir) +(error "File not known to git")) + ;; Need version control to in fact be git + (unless (string-equal (vc-backend (buffer-file-name)) "Git") +(error "Not using git")) + + (let ((tmpfile-git-head (make-temp-file "clang-format-tmp-git-head-content"))) +;; Get filename relative to git root +(let ((git-file-name (substring + (expand-file-name (buffer-file-name)) + (string-width (expand-file-name (vc-root-dir))) + nil))) + (let ((status (call-process + "git" + nil + `(:file, tmpfile-git-head) + nil + "show" (concat "HEAD:" git-file-nam
[clang] [Clang] Correctly initialize placeholder fields from their initializers (PR #114196)
https://github.com/cor3ntin updated https://github.com/llvm/llvm-project/pull/114196 >From e8fe0b3e63cdf9a2e16f680d59705074da10338e Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Wed, 30 Oct 2024 10:25:42 +0100 Subject: [PATCH] [Clang] Correctly initialize placeholder fields from their initializers We made the incorrect assumption that names of fields are unique when creating their default initializers. We fix that by keeping track of the instantiaation pattern for field decls that are placeholder vars, like we already do for unamed fields. Fixes #114069 --- clang/docs/ReleaseNotes.rst | 1 + clang/include/clang/AST/ASTContext.h | 2 +- clang/lib/AST/ASTContext.cpp | 9 +++-- clang/lib/Sema/SemaExpr.cpp | 30 +++- .../lib/Sema/SemaTemplateInstantiateDecl.cpp | 2 +- clang/lib/Serialization/ASTReaderDecl.cpp | 3 +- clang/lib/Serialization/ASTWriterDecl.cpp | 2 +- clang/test/SemaCXX/cxx2c-placeholder-vars.cpp | 36 ++- 8 files changed, 68 insertions(+), 17 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 6085352dfafe6b..eea757b8334150 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -574,6 +574,7 @@ Bug Fixes to C++ Support (#GH95854). - Fixed an assertion failure when evaluating an invalid expression in an array initializer. (#GH112140) - Fixed an assertion failure in range calculations for conditional throw expressions. (#GH111854) +- Name independent data members were not correctly initialized from default member initializers. (#GH114069) Bug Fixes to AST Handling ^ diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 07b4e36f3ef05e..aa3c3734cef166 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1037,7 +1037,7 @@ class ASTContext : public RefCountedBase { void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern); - FieldDecl *getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field); + FieldDecl *getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const; void setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl); diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 1c3f771f417ccf..7dd646c3a50b34 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1583,14 +1583,17 @@ ASTContext::setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, InstantiatedFromUsingShadowDecl[Inst] = Pattern; } -FieldDecl *ASTContext::getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) { +FieldDecl * +ASTContext::getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) const { return InstantiatedFromUnnamedFieldDecl.lookup(Field); } void ASTContext::setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst, FieldDecl *Tmpl) { - assert(!Inst->getDeclName() && "Instantiated field decl is not unnamed"); - assert(!Tmpl->getDeclName() && "Template field decl is not unnamed"); + assert((!Inst->getDeclName() || Inst->isPlaceholderVar(getLangOpts())) && + "Instantiated field decl is not unnamed"); + assert((!Inst->getDeclName() || Inst->isPlaceholderVar(getLangOpts())) && + "Template field decl is not unnamed"); assert(!InstantiatedFromUnnamedFieldDecl[Inst] && "Already noted what unnamed field was instantiated from"); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index ff6616901016ab..158e35af534445 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -5560,6 +5560,25 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc, Init, InitializationContext->Context); } +static FieldDecl *FindFieldDeclInstantiationPattern(const ASTContext &Ctx, +FieldDecl *Field) { + if (FieldDecl *Pattern = Ctx.getInstantiatedFromUnnamedFieldDecl(Field)) +return Pattern; + auto *ParentRD = cast(Field->getParent()); + CXXRecordDecl *ClassPattern = ParentRD->getTemplateInstantiationPattern(); + DeclContext::lookup_result Lookup = + ClassPattern->lookup(Field->getDeclName()); + auto Rng = llvm::make_filter_range(Lookup, [] (auto && L) { + return isa(*L); + }); + if(Rng.empty()) + return nullptr; + // FIXME: this breaks clang/test/Modules/pr28812.cpp + // assert(std::distance(Rng.begin(), Rng.end()) <= 1 + // && "Duplicated instantiation pattern for field decl"); + return cast(*Rng.begin()); +} + ExprResult Sema::BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field) { assert(Field->hasInClassInitializer()); @@ -5588,15 +5607,8 @@ ExprResult Sema::BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *F
[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
https://github.com/kuilpd created https://github.com/llvm/llvm-project/pull/115005 The information about an enum's best promotion type is discarded after compilation and is not present in debug info. This patch repeats the same analysis of each enum value as in the front-end to determine the best promotion type during DWARF info parsing. Fixes #86989 >From 5290832b802d98b9d293b6910c0837911ec490c4 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 1/3] [lldb] Analyze enum promotion type during parsing --- clang/include/clang/AST/Decl.h| 2 +- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 95 ++- .../TypeSystem/Clang/TypeSystemClang.cpp | 29 +- 3 files changed, 100 insertions(+), 26 deletions(-) diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 8c39ef3d5a9fa6..a78e6c92abb22b 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -3891,6 +3891,7 @@ class EnumDecl : public TagDecl { void setInstantiationOfMemberEnum(ASTContext &C, EnumDecl *ED, TemplateSpecializationKind TSK); +public: /// Sets the width in bits required to store all the /// non-negative enumerators of this enum. void setNumPositiveBits(unsigned Num) { @@ -3902,7 +3903,6 @@ class EnumDecl : public TagDecl { /// negative enumerators of this enum. (see getNumNegativeBits) void setNumNegativeBits(unsigned Num) { EnumDeclBits.NumNegativeBits = Num; } -public: /// True if this tag declaration is a scoped enumeration. Only /// possible in C++11 mode. void setScoped(bool Scoped = true) { EnumDeclBits.IsScoped = Scoped; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index a30d898a93cc4d..a21607c2020161 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2248,6 +2248,8 @@ size_t DWARFASTParserClang::ParseChildEnumerators( return 0; size_t enumerators_added = 0; + unsigned NumNegativeBits = 0; + unsigned NumPositiveBits = 0; for (DWARFDIE die : parent_die.children()) { const dw_tag_t tag = die.Tag(); @@ -2299,11 +2301,102 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( clang_type, decl, name, enum_value, enumerator_byte_size * 8); ++enumerators_added; + + llvm::APSInt InitVal = ECD->getInitVal(); + // Keep track of the size of positive and negative values. + if (InitVal.isUnsigned() || InitVal.isNonNegative()) { +// If the enumerator is zero that should still be counted as a positive +// bit since we need a bit to store the value zero. +unsigned ActiveBits = InitVal.getActiveBits(); +NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u}); + } else { +NumNegativeBits = +std::max(NumNegativeBits, (unsigned)InitVal.getSignificantBits()); + } } } + + /// The following code follows the same logic as in Sema::ActOnEnumBody + /// clang/lib/Sema/SemaDecl.cpp + // If we have an empty set of enumerators we still need one bit. + // From [dcl.enum]p8 + // If the enumerator-list is empty, the values of the enumeration are as if + // the enumeration had a single enumerator with value 0 + if (!NumPositiveBits && !NumNegativeBits) +NumPositiveBits = 1; + + clang::QualType qual_type(ClangUtil::GetQualType(clang_type)); + clang::EnumDecl *enum_decl = qual_type->getAs()->getDecl(); + enum_decl->setNumPositiveBits(NumPositiveBits); + enum_decl->setNumNegativeBits(NumNegativeBits); + + // C++0x N3000 [conv.prom]p3: + // An rvalue of an unscoped enumeration type whose underlying + // type is not fixed can be converted to an rvalue of the first + // of the following types that can represent all the values of + // the enumeration: int, unsigned int, long int, unsigned long + // int, long long int, or unsigned long long int. + // C99 6.4.4.3p2: + // An identifier declared as an enumeration constant has type int. + // The C99 rule is modified by C23. + clang::QualType BestPromotionType; + unsigned BestWidth; + + auto &Context = m_ast.getASTContext(); + unsigned LongWidth = Context.getTargetInfo().getLongWidth(); + unsigned IntWidth = Context.getTargetInfo().getIntWidth(); + unsigned CharWidth = Context.getTargetInfo().getCharWidth(); + unsigned ShortWidth = Context.getTargetInfo().getShortWidth(); + + bool is_cpp = Language::LanguageIsCPlusPlus( + SymbolFileDWARF::GetLanguage(*parent_die.GetCU())); + + if (NumNegativeBits) { +// If there is a negative value, figure out the smallest integer type (of +// int/long/longl
[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Ilia Kuklin (kuilpd) Changes The information about an enum's best promotion type is discarded after compilation and is not present in debug info. This patch repeats the same analysis of each enum value as in the front-end to determine the best promotion type during DWARF info parsing. Fixes #86989 --- Full diff: https://github.com/llvm/llvm-project/pull/115005.diff 6 Files Affected: - (modified) clang/include/clang/AST/Decl.h (+1-1) - (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp (+95-1) - (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+5-24) - (added) lldb/test/API/lang/cpp/enum_promotion/Makefile (+3) - (added) lldb/test/API/lang/cpp/enum_promotion/TestCPPEnumPromotion.py (+37) - (added) lldb/test/API/lang/cpp/enum_promotion/main.cpp (+22) ``diff diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 8c39ef3d5a9fa6..a78e6c92abb22b 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -3891,6 +3891,7 @@ class EnumDecl : public TagDecl { void setInstantiationOfMemberEnum(ASTContext &C, EnumDecl *ED, TemplateSpecializationKind TSK); +public: /// Sets the width in bits required to store all the /// non-negative enumerators of this enum. void setNumPositiveBits(unsigned Num) { @@ -3902,7 +3903,6 @@ class EnumDecl : public TagDecl { /// negative enumerators of this enum. (see getNumNegativeBits) void setNumNegativeBits(unsigned Num) { EnumDeclBits.NumNegativeBits = Num; } -public: /// True if this tag declaration is a scoped enumeration. Only /// possible in C++11 mode. void setScoped(bool Scoped = true) { EnumDeclBits.IsScoped = Scoped; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index a30d898a93cc4d..520fd40eda4825 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2248,6 +2248,8 @@ size_t DWARFASTParserClang::ParseChildEnumerators( return 0; size_t enumerators_added = 0; + unsigned NumNegativeBits = 0; + unsigned NumPositiveBits = 0; for (DWARFDIE die : parent_die.children()) { const dw_tag_t tag = die.Tag(); @@ -2299,11 +2301,103 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( clang_type, decl, name, enum_value, enumerator_byte_size * 8); ++enumerators_added; + + llvm::APSInt InitVal = ECD->getInitVal(); + // Keep track of the size of positive and negative values. + if (InitVal.isUnsigned() || InitVal.isNonNegative()) { +// If the enumerator is zero that should still be counted as a positive +// bit since we need a bit to store the value zero. +unsigned ActiveBits = InitVal.getActiveBits(); +NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u}); + } else { +NumNegativeBits = +std::max(NumNegativeBits, (unsigned)InitVal.getSignificantBits()); + } } } + + /// The following code follows the same logic as in Sema::ActOnEnumBody + /// clang/lib/Sema/SemaDecl.cpp + // If we have an empty set of enumerators we still need one bit. + // From [dcl.enum]p8 + // If the enumerator-list is empty, the values of the enumeration are as if + // the enumeration had a single enumerator with value 0 + if (!NumPositiveBits && !NumNegativeBits) +NumPositiveBits = 1; + + clang::EnumDecl *enum_decl = + ClangUtil::GetQualType(clang_type)->getAs()->getDecl(); + enum_decl->setNumPositiveBits(NumPositiveBits); + enum_decl->setNumNegativeBits(NumNegativeBits); + + // C++0x N3000 [conv.prom]p3: + // An rvalue of an unscoped enumeration type whose underlying + // type is not fixed can be converted to an rvalue of the first + // of the following types that can represent all the values of + // the enumeration: int, unsigned int, long int, unsigned long + // int, long long int, or unsigned long long int. + // C99 6.4.4.3p2: + // An identifier declared as an enumeration constant has type int. + // The C99 rule is modified by C23. + clang::QualType BestPromotionType; + unsigned BestWidth; + + auto &Context = m_ast.getASTContext(); + unsigned LongWidth = Context.getTargetInfo().getLongWidth(); + unsigned IntWidth = Context.getTargetInfo().getIntWidth(); + unsigned CharWidth = Context.getTargetInfo().getCharWidth(); + unsigned ShortWidth = Context.getTargetInfo().getShortWidth(); + + bool is_cpp = Language::LanguageIsCPlusPlus( + SymbolFileDWARF::GetLanguage(*parent_die.GetCU())); + + if (NumNegativeBits) { +// If there is a negative value, figure out t
[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
kuilpd wrote: My thought process for this patch: https://github.com/llvm/llvm-project/issues/86989#issuecomment-2438116468 https://github.com/llvm/llvm-project/pull/115005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Multilib] Custom flags YAML parsing (PR #110657)
vhscampos wrote: Created PR to amend `Multilib.rst`: https://github.com/llvm/llvm-project/pull/114998 https://github.com/llvm/llvm-project/pull/110657 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
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 b2d2494731976ab7aa9702f3134472db694b9332 62c801145a2312d2c9339d30cf116fc2e709d630 --extensions h,cpp -- lldb/test/API/lang/cpp/enum_promotion/main.cpp clang/include/clang/AST/Decl.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/test/API/lang/cpp/enum_promotion/main.cpp b/lldb/test/API/lang/cpp/enum_promotion/main.cpp index fafb96f6c7..bcdb0adff5 100644 --- a/lldb/test/API/lang/cpp/enum_promotion/main.cpp +++ b/lldb/test/API/lang/cpp/enum_promotion/main.cpp @@ -4,7 +4,7 @@ enum EnumUInt { UInt = 0x10001 }; enum EnumSLong { SLong = 0x10001 }; enum EnumULong { ULong = 0xFFF0 }; enum EnumNChar { NChar = -1 }; -enum EnumNShort { NShort= -0x101 }; +enum EnumNShort { NShort = -0x101 }; enum EnumNInt { NInt = -0x10001 }; enum EnumNLong { NLong = -0x10001 }; `` https://github.com/llvm/llvm-project/pull/115005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r b2d2494731976ab7aa9702f3134472db694b9332...62c801145a2312d2c9339d30cf116fc2e709d630 lldb/test/API/lang/cpp/enum_promotion/TestCPPEnumPromotion.py `` View the diff from darker here. ``diff --- TestCPPEnumPromotion.py 2024-11-05 14:20:51.00 + +++ TestCPPEnumPromotion.py 2024-11-05 15:10:22.755529 + @@ -5,12 +5,12 @@ import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class TestCPPEnumPromotion(TestBase): - @skipIf(debug_info=no_match(["dwarf", "dwo"])) def test(self): self.build() lldbutil.run_to_source_breakpoint( self, "// break here", lldb.SBFileSpec("main.cpp") `` https://github.com/llvm/llvm-project/pull/115005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/115005 >From 5290832b802d98b9d293b6910c0837911ec490c4 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 1/4] [lldb] Analyze enum promotion type during parsing --- clang/include/clang/AST/Decl.h| 2 +- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 95 ++- .../TypeSystem/Clang/TypeSystemClang.cpp | 29 +- 3 files changed, 100 insertions(+), 26 deletions(-) diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 8c39ef3d5a9fa6..a78e6c92abb22b 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -3891,6 +3891,7 @@ class EnumDecl : public TagDecl { void setInstantiationOfMemberEnum(ASTContext &C, EnumDecl *ED, TemplateSpecializationKind TSK); +public: /// Sets the width in bits required to store all the /// non-negative enumerators of this enum. void setNumPositiveBits(unsigned Num) { @@ -3902,7 +3903,6 @@ class EnumDecl : public TagDecl { /// negative enumerators of this enum. (see getNumNegativeBits) void setNumNegativeBits(unsigned Num) { EnumDeclBits.NumNegativeBits = Num; } -public: /// True if this tag declaration is a scoped enumeration. Only /// possible in C++11 mode. void setScoped(bool Scoped = true) { EnumDeclBits.IsScoped = Scoped; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index a30d898a93cc4d..a21607c2020161 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2248,6 +2248,8 @@ size_t DWARFASTParserClang::ParseChildEnumerators( return 0; size_t enumerators_added = 0; + unsigned NumNegativeBits = 0; + unsigned NumPositiveBits = 0; for (DWARFDIE die : parent_die.children()) { const dw_tag_t tag = die.Tag(); @@ -2299,11 +2301,102 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( clang_type, decl, name, enum_value, enumerator_byte_size * 8); ++enumerators_added; + + llvm::APSInt InitVal = ECD->getInitVal(); + // Keep track of the size of positive and negative values. + if (InitVal.isUnsigned() || InitVal.isNonNegative()) { +// If the enumerator is zero that should still be counted as a positive +// bit since we need a bit to store the value zero. +unsigned ActiveBits = InitVal.getActiveBits(); +NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u}); + } else { +NumNegativeBits = +std::max(NumNegativeBits, (unsigned)InitVal.getSignificantBits()); + } } } + + /// The following code follows the same logic as in Sema::ActOnEnumBody + /// clang/lib/Sema/SemaDecl.cpp + // If we have an empty set of enumerators we still need one bit. + // From [dcl.enum]p8 + // If the enumerator-list is empty, the values of the enumeration are as if + // the enumeration had a single enumerator with value 0 + if (!NumPositiveBits && !NumNegativeBits) +NumPositiveBits = 1; + + clang::QualType qual_type(ClangUtil::GetQualType(clang_type)); + clang::EnumDecl *enum_decl = qual_type->getAs()->getDecl(); + enum_decl->setNumPositiveBits(NumPositiveBits); + enum_decl->setNumNegativeBits(NumNegativeBits); + + // C++0x N3000 [conv.prom]p3: + // An rvalue of an unscoped enumeration type whose underlying + // type is not fixed can be converted to an rvalue of the first + // of the following types that can represent all the values of + // the enumeration: int, unsigned int, long int, unsigned long + // int, long long int, or unsigned long long int. + // C99 6.4.4.3p2: + // An identifier declared as an enumeration constant has type int. + // The C99 rule is modified by C23. + clang::QualType BestPromotionType; + unsigned BestWidth; + + auto &Context = m_ast.getASTContext(); + unsigned LongWidth = Context.getTargetInfo().getLongWidth(); + unsigned IntWidth = Context.getTargetInfo().getIntWidth(); + unsigned CharWidth = Context.getTargetInfo().getCharWidth(); + unsigned ShortWidth = Context.getTargetInfo().getShortWidth(); + + bool is_cpp = Language::LanguageIsCPlusPlus( + SymbolFileDWARF::GetLanguage(*parent_die.GetCU())); + + if (NumNegativeBits) { +// If there is a negative value, figure out the smallest integer type (of +// int/long/longlong) that fits. +if (NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) { + BestWidth = CharWidth; +} else if (NumNegativeBits <= ShortWidth && NumPositiveBits < ShortWidth) { + BestWidth = ShortWidth; +} else if (NumNegativeBits <= IntWidth &
[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
Michael137 wrote: I haven't done an in-depth review of the patch yet but my first instinct here is that this looks like a lot of work for LLDB which the compiler has already done, so we ideally don't want to repeat. Where is this actually an issue from a user perspective? In the example you gave one could just cast to the appropriate enum type and get the bit-mask style presentation: ``` (lldb) expr (UnscopedEnum) (-enum_one) (UnscopedEnum) $0 = One | 0xfffe ``` Not that this shouldn't be fixed, just weighing of the amount of complexity added here versus the benefit. Also, is this promotion-type something that can be encoded in DWARF? GCC generates the same DWARF as Clang here. What happens if we make the type of the `DW_TAG_variable`s be `UnscopedEnum` instead of `int`? I guess that wouldn't help with ``` (lldb) expr UnscopedEnum::One + 1 ``` https://github.com/llvm/llvm-project/pull/115005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PS5][Driver] Pass `-z rodynamic` to the linker (PR #115009)
https://github.com/playstation-edd created https://github.com/llvm/llvm-project/pull/115009 Until now, suppression of `DT_DEBUG` has been hardcoded as a downstream patch in lld. This can instead be achieved by passing `-z rodynamic`. Have the driver do this so that the private patch can be removed. If the scope of lld's `-z rodynamic` is broadened (within reason) to do more in future, that's likely to be fine as `PT_DYNAMIC` isn't writable on PlayStation. PS5 only. On PS4, the equivalent hardcoded configuration will remain in the proprietary linker. SIE tracker: TOOLCHAIN-16704 >From e171d531a2d39998e8e82dd5fbd96315c0581fd7 Mon Sep 17 00:00:00 2001 From: Edd Dawson Date: Tue, 5 Nov 2024 14:51:36 + Subject: [PATCH] [PS5][Driver] Pass `-z rodynamic` to the linker Until now, suppression of `DT_DEBUG` has been hardcoded as a downstream patch in lld. This can instead be achieved by passing `-z rodynamic`. Have the driver do this so that the private patch can be removed. If the scope of lld's `-z rodynamic` is broadened (within reason) to do more in future, that's likely to be fine as `PT_DYNAMIC` isn't writable on PlayStation. PS5 only. On PS4, the equivalent hardcoded configuration will remain in the proprietary linker. SIE tracker: TOOLCHAIN-16704 --- clang/lib/Driver/ToolChains/PS4CPU.cpp | 4 clang/test/Driver/ps5-linker.c | 1 + 2 files changed, 5 insertions(+) diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp index c5299d606f2386..261c136de782e7 100644 --- a/clang/lib/Driver/ToolChains/PS4CPU.cpp +++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -277,6 +277,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-z"); CmdArgs.push_back("start-stop-visibility=hidden"); +// DT_DEBUG is not supported on PlayStation. +CmdArgs.push_back("-z"); +CmdArgs.push_back("rodynamic"); + CmdArgs.push_back("-z"); CmdArgs.push_back("common-page-size=0x4000"); diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c index 363c431b6937eb..8a0ade91871295 100644 --- a/clang/test/Driver/ps5-linker.c +++ b/clang/test/Driver/ps5-linker.c @@ -53,6 +53,7 @@ // CHECK-EXE-SAME: "--unresolved-symbols=report-all" // CHECK-EXE-SAME: "-z" "now" // CHECK-EXE-SAME: "-z" "start-stop-visibility=hidden" +// CHECK-EXE-SAME: "-z" "rodynamic" // CHECK-EXE-SAME: "-z" "common-page-size=0x4000" // CHECK-EXE-SAME: "-z" "max-page-size=0x4000" // CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_*=0x" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PS5][Driver] Pass `-z rodynamic` to the linker (PR #115009)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Edd Dawson (playstation-edd) Changes Until now, suppression of `DT_DEBUG` has been hardcoded as a downstream patch in lld. This can instead be achieved by passing `-z rodynamic`. Have the driver do this so that the private patch can be removed. If the scope of lld's `-z rodynamic` is broadened (within reason) to do more in future, that's likely to be fine as `PT_DYNAMIC` isn't writable on PlayStation. PS5 only. On PS4, the equivalent hardcoded configuration will remain in the proprietary linker. SIE tracker: TOOLCHAIN-16704 --- Full diff: https://github.com/llvm/llvm-project/pull/115009.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/PS4CPU.cpp (+4) - (modified) clang/test/Driver/ps5-linker.c (+1) ``diff diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp index c5299d606f2386..261c136de782e7 100644 --- a/clang/lib/Driver/ToolChains/PS4CPU.cpp +++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -277,6 +277,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-z"); CmdArgs.push_back("start-stop-visibility=hidden"); +// DT_DEBUG is not supported on PlayStation. +CmdArgs.push_back("-z"); +CmdArgs.push_back("rodynamic"); + CmdArgs.push_back("-z"); CmdArgs.push_back("common-page-size=0x4000"); diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c index 363c431b6937eb..8a0ade91871295 100644 --- a/clang/test/Driver/ps5-linker.c +++ b/clang/test/Driver/ps5-linker.c @@ -53,6 +53,7 @@ // CHECK-EXE-SAME: "--unresolved-symbols=report-all" // CHECK-EXE-SAME: "-z" "now" // CHECK-EXE-SAME: "-z" "start-stop-visibility=hidden" +// CHECK-EXE-SAME: "-z" "rodynamic" // CHECK-EXE-SAME: "-z" "common-page-size=0x4000" // CHECK-EXE-SAME: "-z" "max-page-size=0x4000" // CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_*=0x" `` https://github.com/llvm/llvm-project/pull/115009 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] [libclc] Move abs/abs_diff to CLC library (PR #114960)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/114960 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [PS5][Driver] Pass `-z rodynamic` to the linker (PR #115009)
llvmbot wrote: @llvm/pr-subscribers-clang-driver Author: Edd Dawson (playstation-edd) Changes Until now, suppression of `DT_DEBUG` has been hardcoded as a downstream patch in lld. This can instead be achieved by passing `-z rodynamic`. Have the driver do this so that the private patch can be removed. If the scope of lld's `-z rodynamic` is broadened (within reason) to do more in future, that's likely to be fine as `PT_DYNAMIC` isn't writable on PlayStation. PS5 only. On PS4, the equivalent hardcoded configuration will remain in the proprietary linker. SIE tracker: TOOLCHAIN-16704 --- Full diff: https://github.com/llvm/llvm-project/pull/115009.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/PS4CPU.cpp (+4) - (modified) clang/test/Driver/ps5-linker.c (+1) ``diff diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp index c5299d606f2386..261c136de782e7 100644 --- a/clang/lib/Driver/ToolChains/PS4CPU.cpp +++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -277,6 +277,10 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-z"); CmdArgs.push_back("start-stop-visibility=hidden"); +// DT_DEBUG is not supported on PlayStation. +CmdArgs.push_back("-z"); +CmdArgs.push_back("rodynamic"); + CmdArgs.push_back("-z"); CmdArgs.push_back("common-page-size=0x4000"); diff --git a/clang/test/Driver/ps5-linker.c b/clang/test/Driver/ps5-linker.c index 363c431b6937eb..8a0ade91871295 100644 --- a/clang/test/Driver/ps5-linker.c +++ b/clang/test/Driver/ps5-linker.c @@ -53,6 +53,7 @@ // CHECK-EXE-SAME: "--unresolved-symbols=report-all" // CHECK-EXE-SAME: "-z" "now" // CHECK-EXE-SAME: "-z" "start-stop-visibility=hidden" +// CHECK-EXE-SAME: "-z" "rodynamic" // CHECK-EXE-SAME: "-z" "common-page-size=0x4000" // CHECK-EXE-SAME: "-z" "max-page-size=0x4000" // CHECK-EXE-SAME: "-z" "dead-reloc-in-nonalloc=.debug_*=0x" `` https://github.com/llvm/llvm-project/pull/115009 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
https://github.com/kuilpd updated https://github.com/llvm/llvm-project/pull/115005 >From 5290832b802d98b9d293b6910c0837911ec490c4 Mon Sep 17 00:00:00 2001 From: Ilia Kuklin Date: Mon, 4 Nov 2024 14:33:45 +0500 Subject: [PATCH 1/4] [lldb] Analyze enum promotion type during parsing --- clang/include/clang/AST/Decl.h| 2 +- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 95 ++- .../TypeSystem/Clang/TypeSystemClang.cpp | 29 +- 3 files changed, 100 insertions(+), 26 deletions(-) diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 8c39ef3d5a9fa6..a78e6c92abb22b 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -3891,6 +3891,7 @@ class EnumDecl : public TagDecl { void setInstantiationOfMemberEnum(ASTContext &C, EnumDecl *ED, TemplateSpecializationKind TSK); +public: /// Sets the width in bits required to store all the /// non-negative enumerators of this enum. void setNumPositiveBits(unsigned Num) { @@ -3902,7 +3903,6 @@ class EnumDecl : public TagDecl { /// negative enumerators of this enum. (see getNumNegativeBits) void setNumNegativeBits(unsigned Num) { EnumDeclBits.NumNegativeBits = Num; } -public: /// True if this tag declaration is a scoped enumeration. Only /// possible in C++11 mode. void setScoped(bool Scoped = true) { EnumDeclBits.IsScoped = Scoped; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index a30d898a93cc4d..a21607c2020161 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2248,6 +2248,8 @@ size_t DWARFASTParserClang::ParseChildEnumerators( return 0; size_t enumerators_added = 0; + unsigned NumNegativeBits = 0; + unsigned NumPositiveBits = 0; for (DWARFDIE die : parent_die.children()) { const dw_tag_t tag = die.Tag(); @@ -2299,11 +2301,102 @@ size_t DWARFASTParserClang::ParseChildEnumerators( } if (name && name[0] && got_value) { - m_ast.AddEnumerationValueToEnumerationType( + auto ECD = m_ast.AddEnumerationValueToEnumerationType( clang_type, decl, name, enum_value, enumerator_byte_size * 8); ++enumerators_added; + + llvm::APSInt InitVal = ECD->getInitVal(); + // Keep track of the size of positive and negative values. + if (InitVal.isUnsigned() || InitVal.isNonNegative()) { +// If the enumerator is zero that should still be counted as a positive +// bit since we need a bit to store the value zero. +unsigned ActiveBits = InitVal.getActiveBits(); +NumPositiveBits = std::max({NumPositiveBits, ActiveBits, 1u}); + } else { +NumNegativeBits = +std::max(NumNegativeBits, (unsigned)InitVal.getSignificantBits()); + } } } + + /// The following code follows the same logic as in Sema::ActOnEnumBody + /// clang/lib/Sema/SemaDecl.cpp + // If we have an empty set of enumerators we still need one bit. + // From [dcl.enum]p8 + // If the enumerator-list is empty, the values of the enumeration are as if + // the enumeration had a single enumerator with value 0 + if (!NumPositiveBits && !NumNegativeBits) +NumPositiveBits = 1; + + clang::QualType qual_type(ClangUtil::GetQualType(clang_type)); + clang::EnumDecl *enum_decl = qual_type->getAs()->getDecl(); + enum_decl->setNumPositiveBits(NumPositiveBits); + enum_decl->setNumNegativeBits(NumNegativeBits); + + // C++0x N3000 [conv.prom]p3: + // An rvalue of an unscoped enumeration type whose underlying + // type is not fixed can be converted to an rvalue of the first + // of the following types that can represent all the values of + // the enumeration: int, unsigned int, long int, unsigned long + // int, long long int, or unsigned long long int. + // C99 6.4.4.3p2: + // An identifier declared as an enumeration constant has type int. + // The C99 rule is modified by C23. + clang::QualType BestPromotionType; + unsigned BestWidth; + + auto &Context = m_ast.getASTContext(); + unsigned LongWidth = Context.getTargetInfo().getLongWidth(); + unsigned IntWidth = Context.getTargetInfo().getIntWidth(); + unsigned CharWidth = Context.getTargetInfo().getCharWidth(); + unsigned ShortWidth = Context.getTargetInfo().getShortWidth(); + + bool is_cpp = Language::LanguageIsCPlusPlus( + SymbolFileDWARF::GetLanguage(*parent_die.GetCU())); + + if (NumNegativeBits) { +// If there is a negative value, figure out the smallest integer type (of +// int/long/longlong) that fits. +if (NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) { + BestWidth = CharWidth; +} else if (NumNegativeBits <= ShortWidth && NumPositiveBits < ShortWidth) { + BestWidth = ShortWidth; +} else if (NumNegativeBits <= IntWidth &
[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
kuilpd wrote: > Not that this shouldn't be fixed, just weighing of the amount of complexity > added here versus the benefit. I don't really know how useful it is in general to know the actual promotion type of the enum, I guess only for using enum values in expressions without explicit casting. > Also, is this promotion-type something that can be encoded in DWARF? GCC > generates the same DWARF as Clang here. >From what I could tell there is nothing in the DWARF spec that allows to hold >a promotion type of an enum. We could just use some undocumented field, but >then it wouldn't work with GCC binaries. > My question is: if the promotion type can be computed from the information in > dwarf (can it always?), and clang already has code to compute it (not from > DWARF, but from.. clang AST I guess), can we refactor that code somehow so > that it is usable from lldb as well? It can be computed if all the enum values are present in DWARF. I thought about reusing the code from Sema as well, but it uses different interface to iterate through every value, and does other analysis along the way which is not needed during debugging anymore. Plus the patch allows to remove some of the erroneous analysis in [TypeSystemClang.cpp](https://github.com/llvm/llvm-project/pull/115005/files#diff-3a759ae917207e962f79e48fa280277099a587c11bc1f1385e64000c03d6b6a2) https://github.com/llvm/llvm-project/pull/115005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 44f49b5 - [NFC] Move RegisterBuiltinMacro function into the Preprocessor class (#100142)
Author: muiez Date: 2024-11-05T10:32:21-05:00 New Revision: 44f49b551df8152a3e1e84705e116f8a20f62295 URL: https://github.com/llvm/llvm-project/commit/44f49b551df8152a3e1e84705e116f8a20f62295 DIFF: https://github.com/llvm/llvm-project/commit/44f49b551df8152a3e1e84705e116f8a20f62295.diff LOG: [NFC] Move RegisterBuiltinMacro function into the Preprocessor class (#100142) The `RegisterBuiltinMacro` function has been moved to the Preprocessor class for accessibility and has been refactored for readability. Added: Modified: clang/include/clang/Lex/Preprocessor.h clang/lib/Lex/PPMacroExpansion.cpp Removed: diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h index 38a527d2324ffe..3312d4ed1d798d 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -2617,6 +2617,19 @@ class Preprocessor { /// \#pragma GCC poison/system_header/dependency and \#pragma once. void RegisterBuiltinPragmas(); + /// RegisterBuiltinMacro - Register the specified identifier in the identifier + /// table and mark it as a builtin macro to be expanded. + IdentifierInfo *RegisterBuiltinMacro(const char *Name) { +// Get the identifier. +IdentifierInfo *Id = getIdentifierInfo(Name); + +// Mark it as being a macro that is builtin. +MacroInfo *MI = AllocateMacroInfo(SourceLocation()); +MI->setIsBuiltinMacro(); +appendDefMacroDirective(Id, MI); +return Id; + } + /// Register builtin macros such as __LINE__ with the identifier table. void RegisterBuiltinMacros(); diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 3eef3dc9b0f344..b757e20f71ffca 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -323,84 +323,69 @@ void Preprocessor::dumpMacroInfo(const IdentifierInfo *II) { } } -/// RegisterBuiltinMacro - Register the specified identifier in the identifier -/// table and mark it as a builtin macro to be expanded. -static IdentifierInfo *RegisterBuiltinMacro(Preprocessor &PP, const char *Name){ - // Get the identifier. - IdentifierInfo *Id = PP.getIdentifierInfo(Name); - - // Mark it as being a macro that is builtin. - MacroInfo *MI = PP.AllocateMacroInfo(SourceLocation()); - MI->setIsBuiltinMacro(); - PP.appendDefMacroDirective(Id, MI); - return Id; -} - /// RegisterBuiltinMacros - Register builtin macros, such as __LINE__ with the /// identifier table. void Preprocessor::RegisterBuiltinMacros() { - Ident__LINE__ = RegisterBuiltinMacro(*this, "__LINE__"); - Ident__FILE__ = RegisterBuiltinMacro(*this, "__FILE__"); - Ident__DATE__ = RegisterBuiltinMacro(*this, "__DATE__"); - Ident__TIME__ = RegisterBuiltinMacro(*this, "__TIME__"); - Ident__COUNTER__ = RegisterBuiltinMacro(*this, "__COUNTER__"); - Ident_Pragma = RegisterBuiltinMacro(*this, "_Pragma"); - Ident__FLT_EVAL_METHOD__ = RegisterBuiltinMacro(*this, "__FLT_EVAL_METHOD__"); + Ident__LINE__ = RegisterBuiltinMacro("__LINE__"); + Ident__FILE__ = RegisterBuiltinMacro("__FILE__"); + Ident__DATE__ = RegisterBuiltinMacro("__DATE__"); + Ident__TIME__ = RegisterBuiltinMacro("__TIME__"); + Ident__COUNTER__ = RegisterBuiltinMacro("__COUNTER__"); + Ident_Pragma = RegisterBuiltinMacro("_Pragma"); + Ident__FLT_EVAL_METHOD__ = RegisterBuiltinMacro("__FLT_EVAL_METHOD__"); // C++ Standing Document Extensions. if (getLangOpts().CPlusPlus) -Ident__has_cpp_attribute = -RegisterBuiltinMacro(*this, "__has_cpp_attribute"); +Ident__has_cpp_attribute = RegisterBuiltinMacro("__has_cpp_attribute"); else Ident__has_cpp_attribute = nullptr; // GCC Extensions. - Ident__BASE_FILE__ = RegisterBuiltinMacro(*this, "__BASE_FILE__"); - Ident__INCLUDE_LEVEL__ = RegisterBuiltinMacro(*this, "__INCLUDE_LEVEL__"); - Ident__TIMESTAMP__ = RegisterBuiltinMacro(*this, "__TIMESTAMP__"); + Ident__BASE_FILE__ = RegisterBuiltinMacro("__BASE_FILE__"); + Ident__INCLUDE_LEVEL__ = RegisterBuiltinMacro("__INCLUDE_LEVEL__"); + Ident__TIMESTAMP__ = RegisterBuiltinMacro("__TIMESTAMP__"); // Microsoft Extensions. if (getLangOpts().MicrosoftExt) { -Ident__identifier = RegisterBuiltinMacro(*this, "__identifier"); -Ident__pragma = RegisterBuiltinMacro(*this, "__pragma"); +Ident__identifier = RegisterBuiltinMacro("__identifier"); +Ident__pragma = RegisterBuiltinMacro("__pragma"); } else { Ident__identifier = nullptr; Ident__pragma = nullptr; } // Clang Extensions. - Ident__FILE_NAME__ = RegisterBuiltinMacro(*this, "__FILE_NAME__"); - Ident__has_feature = RegisterBuiltinMacro(*this, "__has_feature"); - Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension"); - Ident__has_builtin = RegisterBuiltinMacro(*this, "__has_builtin"); + Ident__FILE_NAME__ = RegisterBuiltinMacr
[clang] [NFC] Move RegisterBuiltinMacro function into the Preprocessor class (PR #100142)
https://github.com/muiez closed https://github.com/llvm/llvm-project/pull/100142 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [lldb] Analyze enum promotion type during parsing (PR #115005)
labath wrote: I'm worried about the same thing as Michael. My question is: if the promotion type can be computed from the information in dwarf (can it always?), and clang already has code to compute it (not from DWARF, but from.. clang AST I guess), can we refactor that code somehow so that it is usable from lldb as well? https://github.com/llvm/llvm-project/pull/115005 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [HLSL][SPIRV][DXIL] Implement `dot4add_i8packed` intrinsic (PR #113623)
@@ -1694,6 +1701,112 @@ bool SPIRVInstructionSelector::selectIntegerDot(Register ResVReg, return Result; } +template +bool SPIRVInstructionSelector::selectDot4AddPacked(Register ResVReg, + const SPIRVType *ResType, + MachineInstr &I) const { + assert(I.getNumOperands() == 5); + assert(I.getOperand(2).isReg()); + assert(I.getOperand(3).isReg()); + assert(I.getOperand(4).isReg()); + MachineBasicBlock &BB = *I.getParent(); + + auto DotOp = Signed ? SPIRV::OpSDot : SPIRV::OpUDot; + Register Dot = MRI->createVirtualRegister(&SPIRV::IDRegClass); s-perron wrote: That is good to know. I had not learned about the different register classes yet. Thanks for catching that. https://github.com/llvm/llvm-project/pull/113623 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][IR] Use splat syntax when printing Constant[Data]Vector. (PR #112548)
https://github.com/arsenm approved this pull request. https://github.com/llvm/llvm-project/pull/112548 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Make source locations space usage diagnostics numbers easier to read (PR #114999)
ilya-biryukov wrote: Do we really care about the exact byte numbers? Maybe we should only show the human-friendly version? It's appealing to have less noise if we can. https://github.com/llvm/llvm-project/pull/114999 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Transforms][Utils][PromoteMem2Reg] Propagate nnan flag on par with the nsz flag (PR #114271)
https://github.com/pawosm-arm updated https://github.com/llvm/llvm-project/pull/114271 >From a426e17ed3c3cad6b3c813bd996e649a2e544591 Mon Sep 17 00:00:00 2001 From: Pawel Osmialowski Date: Wed, 30 Oct 2024 14:30:08 + Subject: [PATCH] [Transforms][Utils][PromoteMem2Reg] Propagate nnan and ninf flags on par with the nsz flag Following the change introduced by the PR #83381, this patch extends it with the same treatment of the nnan and ninf fast-math flags. This is to address the performance drop caused by PR#83200 which prevented vital InstCombine transformation due to the lack of the relevant fast-math flag. The PromoteMem2Reg utility is used by the SROA pass, where Phi nodes are being created. Proposed change allows propagation of the nnan and ninf flags down to these Phi nodes. --- clang/test/Headers/__clang_hip_math.hip | 8 +- .../Utils/PromoteMemoryToRegister.cpp | 17 +++ .../SROA/propagate-fast-math-flags-on-phi.ll | 134 ++ 3 files changed, 155 insertions(+), 4 deletions(-) diff --git a/clang/test/Headers/__clang_hip_math.hip b/clang/test/Headers/__clang_hip_math.hip index e4254d1e64bec9..f64165e2e4bc62 100644 --- a/clang/test/Headers/__clang_hip_math.hip +++ b/clang/test/Headers/__clang_hip_math.hip @@ -1727,7 +1727,7 @@ extern "C" __device__ double test_j1(double x) { // FINITEONLY-NEXT:[[EXITCOND_NOT:%.*]] = icmp eq i32 [[INC_I]], [[X]] // FINITEONLY-NEXT:br i1 [[EXITCOND_NOT]], label [[_ZL3JNFIF_EXIT]], label [[FOR_BODY_I]], !llvm.loop [[LOOP14:![0-9]+]] // FINITEONLY: _ZL3jnfif.exit: -// FINITEONLY-NEXT:[[RETVAL_0_I:%.*]] = phi float [ [[CALL_I20_I]], [[IF_THEN_I]] ], [ [[CALL_I22_I]], [[IF_THEN2_I]] ], [ [[CALL_I21_I]], [[IF_END4_I]] ], [ [[SUB_I]], [[FOR_BODY_I]] ] +// FINITEONLY-NEXT:[[RETVAL_0_I:%.*]] = phi nnan ninf float [ [[CALL_I20_I]], [[IF_THEN_I]] ], [ [[CALL_I22_I]], [[IF_THEN2_I]] ], [ [[CALL_I21_I]], [[IF_END4_I]] ], [ [[SUB_I]], [[FOR_BODY_I]] ] // FINITEONLY-NEXT:ret float [[RETVAL_0_I]] // // APPROX-LABEL: @test_jnf( @@ -1830,7 +1830,7 @@ extern "C" __device__ float test_jnf(int x, float y) { // FINITEONLY-NEXT:[[EXITCOND_NOT:%.*]] = icmp eq i32 [[INC_I]], [[X]] // FINITEONLY-NEXT:br i1 [[EXITCOND_NOT]], label [[_ZL2JNID_EXIT]], label [[FOR_BODY_I]], !llvm.loop [[LOOP15:![0-9]+]] // FINITEONLY: _ZL2jnid.exit: -// FINITEONLY-NEXT:[[RETVAL_0_I:%.*]] = phi double [ [[CALL_I20_I]], [[IF_THEN_I]] ], [ [[CALL_I22_I]], [[IF_THEN2_I]] ], [ [[CALL_I21_I]], [[IF_END4_I]] ], [ [[SUB_I]], [[FOR_BODY_I]] ] +// FINITEONLY-NEXT:[[RETVAL_0_I:%.*]] = phi nnan ninf double [ [[CALL_I20_I]], [[IF_THEN_I]] ], [ [[CALL_I22_I]], [[IF_THEN2_I]] ], [ [[CALL_I21_I]], [[IF_END4_I]] ], [ [[SUB_I]], [[FOR_BODY_I]] ] // FINITEONLY-NEXT:ret double [[RETVAL_0_I]] // // APPROX-LABEL: @test_jn( @@ -4461,7 +4461,7 @@ extern "C" __device__ double test_y1(double x) { // FINITEONLY-NEXT:[[EXITCOND_NOT:%.*]] = icmp eq i32 [[INC_I]], [[X]] // FINITEONLY-NEXT:br i1 [[EXITCOND_NOT]], label [[_ZL3YNFIF_EXIT]], label [[FOR_BODY_I]], !llvm.loop [[LOOP24:![0-9]+]] // FINITEONLY: _ZL3ynfif.exit: -// FINITEONLY-NEXT:[[RETVAL_0_I:%.*]] = phi float [ [[CALL_I20_I]], [[IF_THEN_I]] ], [ [[CALL_I22_I]], [[IF_THEN2_I]] ], [ [[CALL_I21_I]], [[IF_END4_I]] ], [ [[SUB_I]], [[FOR_BODY_I]] ] +// FINITEONLY-NEXT:[[RETVAL_0_I:%.*]] = phi nnan ninf float [ [[CALL_I20_I]], [[IF_THEN_I]] ], [ [[CALL_I22_I]], [[IF_THEN2_I]] ], [ [[CALL_I21_I]], [[IF_END4_I]] ], [ [[SUB_I]], [[FOR_BODY_I]] ] // FINITEONLY-NEXT:ret float [[RETVAL_0_I]] // // APPROX-LABEL: @test_ynf( @@ -4564,7 +4564,7 @@ extern "C" __device__ float test_ynf(int x, float y) { // FINITEONLY-NEXT:[[EXITCOND_NOT:%.*]] = icmp eq i32 [[INC_I]], [[X]] // FINITEONLY-NEXT:br i1 [[EXITCOND_NOT]], label [[_ZL2YNID_EXIT]], label [[FOR_BODY_I]], !llvm.loop [[LOOP25:![0-9]+]] // FINITEONLY: _ZL2ynid.exit: -// FINITEONLY-NEXT:[[RETVAL_0_I:%.*]] = phi double [ [[CALL_I20_I]], [[IF_THEN_I]] ], [ [[CALL_I22_I]], [[IF_THEN2_I]] ], [ [[CALL_I21_I]], [[IF_END4_I]] ], [ [[SUB_I]], [[FOR_BODY_I]] ] +// FINITEONLY-NEXT:[[RETVAL_0_I:%.*]] = phi nnan ninf double [ [[CALL_I20_I]], [[IF_THEN_I]] ], [ [[CALL_I22_I]], [[IF_THEN2_I]] ], [ [[CALL_I21_I]], [[IF_END4_I]] ], [ [[SUB_I]], [[FOR_BODY_I]] ] // FINITEONLY-NEXT:ret double [[RETVAL_0_I]] // // APPROX-LABEL: @test_yn( diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index 656bb1ebd1161e..d8657de3e58b09 100644 --- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -394,6 +394,12 @@ struct PromoteMem2Reg { /// Whether the function has the no-signed-zeros-fp-math attribute set. bool NoSignedZeros = false; + /// Whether the function has the no-nans-fp-math attribute set. + bool NoNaNs = false; + + /// Whether th
[clang] [llvm] [AArch64] Reduce +sve2-aes to an alias of +sve-aes+sve2 (PR #114293)
@@ -369,9 +369,12 @@ def FeatureSVE2 : ExtensionWithMArch<"sve2", "SVE2", "FEAT_SVE2", "Enable Scalable Vector Extension 2 (SVE2) instructions", [FeatureSVE, FeatureUseScalarIncVL]>; -def FeatureSVE2AES : ExtensionWithMArch<"sve2-aes", "SVE2AES", +def FeatureSVEAES : ExtensionWithMArch<"sve-aes", "SVEAES", "FEAT_SVE_AES, FEAT_SVE_PMULL128", - "Enable AES SVE2 instructions", [FeatureSVE2, FeatureAES]>; + "Enable SVE AES and 128-bit PMULL instructions", [FeatureAES]>; + +def FeatureSVE2AES : ExtensionWithMArch<"sve2-aes", "SVE2AES", "", Lukacma wrote: I agree that renaming it to the Alias might be a good idea. https://github.com/llvm/llvm-project/pull/114293 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Make source locations space usage diagnostics numbers easier to read (PR #114999)
bricknerb wrote: > Do we really care about the exact byte numbers? Maybe we should only show the > human-friendly version? It's appealing to have less noise if we can. Yes, I was considering both options. It might be useful to see the full number in case you want to diff between logs, and the diff would be relatively small (people might care about zero diff vs. tiny diff), so I decided to make this change not lose any information. https://github.com/llvm/llvm-project/pull/114999 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 34b0bb5 - Add Chris as the HLSL maintainer (#114863)
Author: Aaron Ballman Date: 2024-11-05T11:01:58-05:00 New Revision: 34b0bb51213d0c4e3afa128d6107884cd7138cf2 URL: https://github.com/llvm/llvm-project/commit/34b0bb51213d0c4e3afa128d6107884cd7138cf2 DIFF: https://github.com/llvm/llvm-project/commit/34b0bb51213d0c4e3afa128d6107884cd7138cf2.diff LOG: Add Chris as the HLSL maintainer (#114863) Chris has extensive knowledge of HLSL and a long track-record of quality reviews in Clang. Added: Modified: clang/Maintainers.rst Removed: diff --git a/clang/Maintainers.rst b/clang/Maintainers.rst index 27255a9c0319b4..ad42a9a2050b63 100644 --- a/clang/Maintainers.rst +++ b/clang/Maintainers.rst @@ -301,6 +301,12 @@ SYCL conformance | alexey.bader\@intel.com (email), bader (Phabricator), bader (GitHub) +HLSL conformance + +| Chris Bieneman +| chris.bieneman\@gmail.com (email), llvm-beanz (GitHub), beanz (Discord), beanz (Discourse) + + Issue Triage | Shafik Yaghmour ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Add Mariya as maintainer for constant expressions & Sema (PR #114974)
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/114974 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Transforms][Utils][PromoteMem2Reg] Propagate nnan flag on par with the nsz flag (PR #114271)
arsenm wrote: > I do think this change still makes sense, especially from a consistency point > of view. If SROA sets one of the value-based FMF flags (nsz) then it stands > to reason that it should also set the other two (nnan and ninf). Unless there > is some reason why nsz would be more problematic than nnan/ninf in this > context (it does have substantially different semantics). nsz is more problematic and difficult to recover than nnan/ninf. Violations of no-nans no-infs can be treated as poison. nsz is fuzzier and just expands the set of permissible values, and is thus attached to specific operations and not recoverable from the inputs. You can't simply add some form of assertion that a value cannot be -0, in the way you could for a nan. It's not problematic to preserve nnan in the same way here, but it's also less important. https://github.com/llvm/llvm-project/pull/114271 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] AMDGPU: Treat uint32_max as the default value for amdgpu-max-num-workgroups (PR #113751)
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/113751 >From 6981d5ad80130130d373b8c879a88b7d727b0115 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Sat, 19 Oct 2024 02:39:06 +0400 Subject: [PATCH 1/4] clang/AMDGPU: Emit grid size builtins with range metadata These cannot be 0. --- clang/lib/CodeGen/CGBuiltin.cpp | 6 ++ clang/test/CodeGenOpenCL/builtins-amdgcn.cl | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 34fedd67114751..3e627667cf4da0 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -18671,6 +18671,12 @@ Value *EmitAMDGPUGridSize(CodeGenFunction &CGF, unsigned Index) { auto *GEP = CGF.Builder.CreateGEP(CGF.Int8Ty, DP, Offset); auto *LD = CGF.Builder.CreateLoad( Address(GEP, CGF.Int32Ty, CharUnits::fromQuantity(4))); + + llvm::MDBuilder MDB(CGF.getLLVMContext()); + + // Known non-zero. + LD->setMetadata(llvm::LLVMContext::MD_range, + MDB.createRange(APInt(32, 1), APInt::getZero(32))); LD->setMetadata(llvm::LLVMContext::MD_invariant_load, llvm::MDNode::get(CGF.getLLVMContext(), {})); return LD; diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl index 9132cc8a717e0f..3bc6107b7fd40d 100644 --- a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl +++ b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl @@ -639,7 +639,7 @@ void test_get_workgroup_size(int d, global int *out) // CHECK-LABEL: @test_get_grid_size( // CHECK: {{.*}}call align 4 dereferenceable(64){{.*}} ptr addrspace(4) @llvm.amdgcn.dispatch.ptr() // CHECK: getelementptr inbounds i8, ptr addrspace(4) %{{.*}}, i64 %{{.+}} -// CHECK: load i32, ptr addrspace(4) %{{.*}}, align 4, !invariant.load +// CHECK: load i32, ptr addrspace(4) %{{.*}}, align 4, !range [[$GRID_RANGE:![0-9]+]], !invariant.load void test_get_grid_size(int d, global int *out) { switch (d) { @@ -896,5 +896,6 @@ void test_set_fpenv(unsigned long env) { __builtin_amdgcn_set_fpenv(env); } +// CHECK-DAG: [[$GRID_RANGE]] = !{i32 1, i32 0} // CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025} // CHECK-DAG: attributes #[[$NOUNWIND_READONLY]] = { convergent mustprogress nocallback nofree nounwind willreturn memory(none) } >From 45b0b32286d47925d37361d154924da22d9afeda Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 25 Oct 2024 18:31:43 -0700 Subject: [PATCH 2/4] AMDGPU: Treat uint32_max as the default value for amdgpu-max-num-workgroups 0 does not make sense as a value for this to be, much less the default. Also stop emitting each individual field if it is the default, rather than if any element was the default. Also fix the name of the test since it didn't exactly match the real attribute name. --- .../AMDGPU/AMDGPUHSAMetadataStreamer.cpp | 15 +++-- llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp| 3 +- .../Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp| 7 ++- llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h | 3 +- ...s.ll => attr-amdgpu-max-num-workgroups.ll} | 58 +++ 5 files changed, 76 insertions(+), 10 deletions(-) rename llvm/test/CodeGen/AMDGPU/{attr-amdgpu-num-workgroups.ll => attr-amdgpu-max-num-workgroups.ll} (58%) diff --git a/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp b/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp index bd418efcb83cb2..440d6f9a503279 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp @@ -504,14 +504,19 @@ MetadataStreamerMsgPackV4::getHSAKernelProps(const MachineFunction &MF, Kern[".max_flat_workgroup_size"] = Kern.getDocument()->getNode(MFI.getMaxFlatWorkGroupSize()); - unsigned NumWGX = MFI.getMaxNumWorkGroupsX(); - unsigned NumWGY = MFI.getMaxNumWorkGroupsY(); - unsigned NumWGZ = MFI.getMaxNumWorkGroupsZ(); - if (NumWGX != 0 && NumWGY != 0 && NumWGZ != 0) { + + uint32_t NumWGX = MFI.getMaxNumWorkGroupsX(); + uint32_t NumWGY = MFI.getMaxNumWorkGroupsY(); + uint32_t NumWGZ = MFI.getMaxNumWorkGroupsZ(); + if (NumWGX != std::numeric_limits::max()) Kern[".max_num_workgroups_x"] = Kern.getDocument()->getNode(NumWGX); + + if (NumWGY != std::numeric_limits::max()) Kern[".max_num_workgroups_y"] = Kern.getDocument()->getNode(NumWGY); + + if (NumWGZ != std::numeric_limits::max()) Kern[".max_num_workgroups_z"] = Kern.getDocument()->getNode(NumWGZ); - } + Kern[".sgpr_spill_count"] = Kern.getDocument()->getNode(MFI.getNumSpilledSGPRs()); Kern[".vgpr_spill_count"] = diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp b/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp index 961a9220b48d6b..54b17ca2cffb15 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp @@ -371,5 +371,6 @@ const AMDGPUSubtarget &AMDGPUSubtarget::get(const TargetMachine &TM,
[clang] clang/AMDGPU: Emit grid size builtins with range metadata (PR #113038)
https://github.com/arsenm edited https://github.com/llvm/llvm-project/pull/113038 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c48fc46 - Add Mariya as maintainer for constant expressions & Sema (#114974)
Author: Aaron Ballman Date: 2024-11-05T11:02:16-05:00 New Revision: c48fc467575e6dfa6578c66ebafa7c29de3fdaf4 URL: https://github.com/llvm/llvm-project/commit/c48fc467575e6dfa6578c66ebafa7c29de3fdaf4 DIFF: https://github.com/llvm/llvm-project/commit/c48fc467575e6dfa6578c66ebafa7c29de3fdaf4.diff LOG: Add Mariya as maintainer for constant expressions & Sema (#114974) Mariya has extensive knowledge of the constant expression evaluator and has done a lot of reviewing in Sema over the past year or so. Added: Modified: clang/Maintainers.rst Removed: diff --git a/clang/Maintainers.rst b/clang/Maintainers.rst index ad42a9a2050b63..8d12eda766d9b4 100644 --- a/clang/Maintainers.rst +++ b/clang/Maintainers.rst @@ -68,6 +68,9 @@ Sema | Sirraide | aeternalmail\@gmail.com (email), Sirraide (GitHub), Ætérnal (Discord), Sirraide (Discourse) +| Mariya Podchishchaeva +| mariya.podchishchaeva\@intel.com (email), Fznamznon (GitHub), fznamznon (Discord), Fznamznon (Discourse) + Recovery AST @@ -150,6 +153,12 @@ Driver parts not covered by someone else | i\@maskray.me (email), MaskRay (Phabricator), MaskRay (GitHub) +Constant Expressions + +| Mariya Podchishchaeva +| mariya.podchishchaeva\@intel.com (email), Fznamznon (GitHub), fznamznon (Discord), Fznamznon (Discourse) + + Tools - These maintainers are responsible for user-facing tools under the Clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1a59087 - [SYCL] The sycl_kernel_entry_point attribute. (#111389)
Author: Tom Honermann Date: 2024-11-05T11:09:32-05:00 New Revision: 1a590870b6b3452934ecc245e01957fdab48909c URL: https://github.com/llvm/llvm-project/commit/1a590870b6b3452934ecc245e01957fdab48909c DIFF: https://github.com/llvm/llvm-project/commit/1a590870b6b3452934ecc245e01957fdab48909c.diff LOG: [SYCL] The sycl_kernel_entry_point attribute. (#111389) The `sycl_kernel_entry_point` attribute is used to declare a function that defines a pattern for an offload kernel to be emitted. The attribute requires a single type argument that specifies the type used as a SYCL kernel name as described in section 5.2, "Naming of kernels", of the SYCL 2020 specification. Properties of the offload kernel are collected when a function declared with the `sycl_kernel_entry_point` attribute is parsed or instantiated. These properties, such as the kernel name type, are stored in the AST context where they are (or will be) used for diagnostic purposes and to facilitate reflection to a SYCL run-time library. These properties are not serialized with the AST but are recreated upon deserialization. The `sycl_kernel_entry_point` attribute is intended to replace the existing `sycl_kernel` attribute which is intended to be deprecated in a future change and removed following an appropriate deprecation period. The new attribute differs in that it is enabled for both SYCL host and device compilation, may be used with non-template functions, explicitly indicates the type used as the kernel name type, and will impact AST generation. This change adds the basic infrastructure for the new attribute. Future changes will add diagnostics and new AST support that will be used to drive generation of the corresponding offload kernel. Added: clang/include/clang/AST/SYCLKernelInfo.h clang/test/ASTSYCL/ast-dump-sycl-kernel-entry-point.cpp clang/test/SemaSYCL/sycl-kernel-entry-point-attr-grammar.cpp clang/test/SemaSYCL/sycl-kernel-entry-point-attr-ignored.cpp Modified: clang/include/clang/AST/ASTContext.h clang/include/clang/Basic/Attr.td clang/include/clang/Basic/AttrDocs.td clang/include/clang/Sema/SemaSYCL.h clang/lib/AST/ASTContext.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/lib/Sema/SemaSYCL.cpp clang/lib/Serialization/ASTReaderDecl.cpp clang/test/Misc/pragma-attribute-supported-attributes-list.test Removed: diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index fb0c051dc19182..1e8101f60b03fb 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -23,6 +23,7 @@ #include "clang/AST/ExternalASTSource.h" #include "clang/AST/PrettyPrinter.h" #include "clang/AST/RawCommentList.h" +#include "clang/AST/SYCLKernelInfo.h" #include "clang/AST/TemplateName.h" #include "clang/Basic/LLVM.h" #include "clang/Basic/PartialDiagnostic.h" @@ -1239,6 +1240,11 @@ class ASTContext : public RefCountedBase { /// in device compilation. llvm::DenseSet CUDAImplicitHostDeviceFunUsedByDevice; + /// Map of SYCL kernels indexed by the unique type used to name the kernel. + /// Entries are not serialized but are recreated on deserialization of a + /// sycl_kernel_entry_point attributed function declaration. + llvm::DenseMap SYCLKernels; + /// For capturing lambdas with an explicit object parameter whose type is /// derived from the lambda type, we need to perform derived-to-base /// conversion so we can access the captures; the cast paths for that @@ -3340,6 +3346,14 @@ class ASTContext : public RefCountedBase { void getFunctionFeatureMap(llvm::StringMap &FeatureMap, GlobalDecl GD) const; + /// Generates and stores SYCL kernel metadata for the provided + /// SYCL kernel entry point function. The provided function must have + /// an attached sycl_kernel_entry_point attribute that specifies a unique + /// type for the name of a SYCL kernel. Callers are required to detect + /// conflicting SYCL kernel names and issue a diagnostic prior to calling + /// this function. + void registerSYCLEntryPointFunction(FunctionDecl *FD); + //======// //Statistics //======// diff --git a/clang/include/clang/AST/SYCLKernelInfo.h b/clang/include/clang/AST/SYCLKernelInfo.h new file mode 100644 index 00..55dba1f8e31fd9 --- /dev/null +++ b/clang/include/clang/AST/SYCLKernelInfo.h @@ -0,0 +1,41 @@ +//===--- SYCLKernelInfo.h --- Information about SYCL kernels --===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===
[clang] Add Chris as the HLSL maintainer (PR #114863)
https://github.com/erichkeane approved this pull request. https://github.com/llvm/llvm-project/pull/114863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SYCL] The sycl_kernel_entry_point attribute. (PR #111389)
https://github.com/tahonermann closed https://github.com/llvm/llvm-project/pull/111389 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Add Chris as the HLSL maintainer (PR #114863)
https://github.com/AaronBallman closed https://github.com/llvm/llvm-project/pull/114863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libc] [Clang] Implement resource directory headers for common GPU intrinsics (PR #110179)
jhuber6 wrote: Ping https://github.com/llvm/llvm-project/pull/110179 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] eliminate shadowing warnings for parameters using deducing this (PR #114813)
@@ -8236,11 +8236,14 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, DeclContext *NewDC = D->getDeclContext(); if (FieldDecl *FD = dyn_cast(ShadowedDecl)) { -// Fields are not shadowed by variables in C++ static methods. -if (CXXMethodDecl *MD = dyn_cast(NewDC)) +if (CXXMethodDecl *MD = dyn_cast(NewDC)) { + // Fields are not shadowed by variables in C++ static methods. if (MD->isStatic()) return; + if (!MD->getParent()->isLambda() && MD->isExplicitObjectMemberFunction()) +return; a-tarasyuk wrote: ``` ``` https://github.com/llvm/llvm-project/pull/114813 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Make source locations space usage diagnostics numbers easier to read (PR #114999)
ilya-biryukov wrote: > Yes, I was considering both options. It might be useful to see the full > number in case you want to diff between logs, and the diff would be > relatively small (people might care about zero diff vs. tiny diff), so I > decided to make this change not lose any information. Makes sense, and given that it's a relatively infrequently surfaced feature, I think it's fine to change our mind on that later. https://github.com/llvm/llvm-project/pull/114999 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] [libcxxabi] [libunwind] [llvm] [libc++] Unify the benchmarks with the test suite (PR #101399)
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/101399 >From 2e50f00dfc6636abbaf0c8350c6e7c92b7b3dba0 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Thu, 25 Jul 2024 10:41:10 -0400 Subject: [PATCH] [libc++] Unify the benchmarks with the test suite Instead of building the benchmarks separately via CMake and running them separately from the test suite, this patch merges the benchmarks into the test suite and handles both uniformly. As a result: - It is now possible to run individual benchmarks like we run tests (e.g. using libcxx-lit), which is a huge quality-of-life improvement. - The benchmarks will be run under exactly the same configuration as the rest of the tests, which is a nice simplification. This does mean that one has to be careful to enable the desired optimization flags when running benchmarks, but that is easy with e.g. `libcxx-lit <...> --param optimization=speed`. - Benchmarks can use the same annotations as the rest of the test suite, such as `// UNSUPPORTED` & friends. When running the tests via `check-cxx`, we only compile the benchmarks because running them would be too time consuming. This introduces a bit of complexity in the testing setup, and instead it would be better to allow passing a --dry-run flag to GoogleBenchmark executables, which is the topic of a GoogleBenchmark issue. I am not really satisfied with the layering violation of adding the %{benchmark_flags} substitution to cmake-bridge, however I believe this can be improved in the future. --- .github/workflows/libcxx-build-and-test.yaml | 3 - libcxx/CMakeLists.txt | 19 +- libcxx/docs/TestingLibcxx.rst | 49 ++--- libcxx/docs/VendorDocumentation.rst | 12 +- libcxx/test/CMakeLists.txt| 13 +- libcxx/test/benchmarks/CMakeLists.txt | 185 +- .../test/benchmarks/algorithms/min.bench.cpp | 2 + .../atomic_wait_vs_mutex_lock.bench.cpp | 4 - .../test/benchmarks/formatter_int.bench.cpp | 2 +- libcxx/test/benchmarks/lit.cfg.py.in | 23 --- libcxx/test/benchmarks/lit.site.cfg.py.in | 10 - .../test/benchmarks/util_smartptr.bench.cpp | 2 + libcxx/test/configs/cmake-bridge.cfg.in | 1 + libcxx/utils/ci/buildkite-pipeline.yml| 3 + libcxx/utils/ci/run-buildbot | 10 - libcxx/utils/libcxx/test/config.py| 2 +- libcxx/utils/libcxx/test/format.py| 31 ++- libcxx/utils/libcxx/test/googlebenchmark.py | 125 libcxx/utils/libcxx/test/params.py| 10 + libcxxabi/test/configs/cmake-bridge.cfg.in| 1 + libunwind/test/configs/cmake-bridge.cfg.in| 1 + 21 files changed, 100 insertions(+), 408 deletions(-) delete mode 100644 libcxx/test/benchmarks/lit.cfg.py.in delete mode 100644 libcxx/test/benchmarks/lit.site.cfg.py.in delete mode 100644 libcxx/utils/libcxx/test/googlebenchmark.py diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml index 657e7f1e7f0f7e..32e9350d7353da 100644 --- a/.github/workflows/libcxx-build-and-test.yaml +++ b/.github/workflows/libcxx-build-and-test.yaml @@ -157,9 +157,6 @@ jobs: 'generic-no-rtti', 'generic-optimized-speed', 'generic-static', - # TODO Find a better place for the benchmark and bootstrapping builds to live. They're either very expensive - # or don't provide much value since the benchmark run results are too noise on the bots. - 'benchmarks', 'bootstrapping-build' ] machine: [ 'libcxx-runners-8-set' ] diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index 95a7d10f055ea7..cb2b9ad57f6a5f 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -150,12 +150,19 @@ message(STATUS "Using libc++ testing configuration: ${LIBCXX_TEST_CONFIG}") set(LIBCXX_TEST_PARAMS "" CACHE STRING "A list of parameters to run the Lit test suite with.") -# Benchmark options --- -option(LIBCXX_INCLUDE_BENCHMARKS "Build the libc++ benchmarks and their dependencies" ON) - -set(LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT --benchmark_min_time=0.01) -set(LIBCXX_BENCHMARK_TEST_ARGS "${LIBCXX_BENCHMARK_TEST_ARGS_DEFAULT}" CACHE STRING -"Arguments to pass when running the benchmarks using check-cxx-benchmarks") +# TODO: Figure out how to build GoogleBenchmark on those platforms, and how to build when exceptions or RTTI is disabled +if (WIN32 OR MINGW OR ANDROID OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX" +OR NOT LIBCXX_ENABLE_LOCALIZATION +OR NOT LIBCXX_ENABLE_THREADS +OR NOT LIBCXX_ENABLE_FILESYSTEM +OR NOT LIBCXX_ENABLE_RANDOM_DEVICE +OR NOT LIBCXX_ENABLE_EXCEPTIONS +OR NOT LIBCXX_ENABLE_RTTI) + set(_include_benchmarks OFF) +else() + set(_include_benchmarks ON) +endif() +option(LIBCXX_INCLUDE_BENCHMARKS "Build
[clang] [clang] Make source locations space usage diagnostics numbers easier to read (PR #114999)
@@ -2227,6 +2227,28 @@ LLVM_DUMP_METHOD void SourceManager::dump() const { } } +static std::string NumberToHumanString(uint64_t Number) { + static constexpr std::array, 4> Units = { + {{1'000'000'000'000UL, 'T'}, + {1'000'000'000UL, 'G'}, + {1'000'000UL, 'M'}, + {1'000UL, 'k'}}}; + + std::string HumanString; + llvm::raw_string_ostream HumanStringStream(HumanString); + for (const auto &[UnitSize, UnitSign] : Units) { +if (Number >= UnitSize) { + HumanStringStream << llvm::format( ilya-biryukov wrote: Suggestion: use `formatv` and it can convert to string directly. ```cpp HumanString += llvm::formatv(...); ``` https://github.com/llvm/llvm-project/pull/114999 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Make source locations space usage diagnostics numbers easier to read (PR #114999)
@@ -2227,6 +2227,28 @@ LLVM_DUMP_METHOD void SourceManager::dump() const { } } +static std::string NumberToHumanString(uint64_t Number) { + static constexpr std::array, 4> Units = { + {{1'000'000'000'000UL, 'T'}, + {1'000'000'000UL, 'G'}, + {1'000'000UL, 'M'}, + {1'000UL, 'k'}}}; + + std::string HumanString; + llvm::raw_string_ostream HumanStringStream(HumanString); + for (const auto &[UnitSize, UnitSign] : Units) { +if (Number >= UnitSize) { + HumanStringStream << llvm::format( + "%.2f%c", Number / static_cast(UnitSize), UnitSign); + break; ilya-biryukov wrote: Suggestion: maybe reduce the amount of the code a little by using `return` instead of `break`? That would also make the extra variable unnecessary. ```cpp for (... : Units) { if (Number >= UnitSize) return llvm::formatv(...); } return std::to_string(Number); ``` https://github.com/llvm/llvm-project/pull/114999 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV][VLS] Support RISCV VLS calling convention (PR #100346)
@@ -317,38 +323,60 @@ ABIArgInfo RISCVABIInfo::coerceAndExpandFPCCEligibleStruct( // Fixed-length RVV vectors are represented as scalable vectors in function // args/return and must be coerced from fixed vectors. -ABIArgInfo RISCVABIInfo::coerceVLSVector(QualType Ty) const { +ABIArgInfo RISCVABIInfo::coerceVLSVector(QualType Ty, + unsigned ArgABIVLen) const { assert(Ty->isVectorType() && "expected vector type!"); const auto *VT = Ty->castAs(); assert(VT->getElementType()->isBuiltinType() && "expected builtin type!"); - auto VScale = - getContext().getTargetInfo().getVScaleRange(getContext().getLangOpts()); - unsigned NumElts = VT->getNumElements(); - llvm::Type *EltType; - if (VT->getVectorKind() == VectorKind::RVVFixedLengthMask) { -NumElts *= 8; -EltType = llvm::Type::getInt1Ty(getVMContext()); + llvm::ScalableVectorType *ResType; + llvm::Type *EltType = CGT.ConvertType(VT->getElementType()); + + if (ArgABIVLen == 0) { +// RVV fixed-length vector +auto VScale = + getContext().getTargetInfo().getVScaleRange(getContext().getLangOpts()); + +if (VT->getVectorKind() == VectorKind::RVVFixedLengthMask) { + NumElts *= 8; + EltType = llvm::Type::getInt1Ty(getVMContext()); +} + +// The MinNumElts is simplified from equation: +// NumElts / VScale = +// (EltSize * NumElts / (VScale * RVVBitsPerBlock)) +//* (RVVBitsPerBlock / EltSize) +ResType = llvm::ScalableVectorType::get(EltType, NumElts / VScale->first); } else { -assert(VT->getVectorKind() == VectorKind::RVVFixedLengthData && - "Unexpected vector kind"); -EltType = CGT.ConvertType(VT->getElementType()); +// If the corresponding extension is not supported, just make it an i32 +// vector. +const TargetInfo &TI = getContext().getTargetInfo(); topperc wrote: Does this work with target_clones/target_version? https://github.com/llvm/llvm-project/pull/100346 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] dc62edf - [clang][Driver][HIP] Add support for mixing AMDGCNSPIRV & concrete `offload-arch`s. (#113509)
Author: Alex Voicu Date: 2024-11-05T10:53:05+02:00 New Revision: dc62edf10543137fbf7f3d4aaa21c17ff073a8fe URL: https://github.com/llvm/llvm-project/commit/dc62edf10543137fbf7f3d4aaa21c17ff073a8fe DIFF: https://github.com/llvm/llvm-project/commit/dc62edf10543137fbf7f3d4aaa21c17ff073a8fe.diff LOG: [clang][Driver][HIP] Add support for mixing AMDGCNSPIRV & concrete `offload-arch`s. (#113509) This removes the temporary ban on mixing AMDGCN flavoured SPIR-V and concrete targets (e.g. `gfx900`) in the same HIPAMD compilation. This is done primarily by tweaking the effective / observable triple when the target is `amdgcnspirv`, which seamlessly composes with the existing infra. The test is stolen from #75357. Added: Modified: clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChain.cpp clang/lib/Driver/ToolChains/HIPAMD.cpp clang/lib/Driver/ToolChains/HIPUtility.cpp clang/test/Driver/hip-toolchain-no-rdc.hip Removed: diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index df802450ad5938..c5be122737051e 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -149,13 +149,9 @@ static std::optional getHIPOffloadTargetTriple(const Driver &D, const ArgList &Args) { if (!Args.hasArg(options::OPT_offload_EQ)) { auto OffloadArchs = Args.getAllArgValues(options::OPT_offload_arch_EQ); -if (llvm::is_contained(OffloadArchs, "amdgcnspirv")) { - if (OffloadArchs.size() == 1) -return llvm::Triple("spirv64-amd-amdhsa"); - // Mixing specific & SPIR-V compilation is not supported for now. - D.Diag(diag::err_drv_only_one_offload_target_supported); - return std::nullopt; -} +if (llvm::is_contained(OffloadArchs, "amdgcnspirv") && +OffloadArchs.size() == 1) + return llvm::Triple("spirv64-amd-amdhsa"); return llvm::Triple("amdgcn-amd-amdhsa"); // Default HIP triple. } auto TT = getOffloadTargetTriple(D, Args); @@ -3477,9 +3473,11 @@ class OffloadingActionBuilder final { llvm::StringMap Features; // getHIPOffloadTargetTriple() is known to return valid value as it has // been called successfully in the CreateOffloadingDeviceToolChains(). - auto ArchStr = parseTargetID( - *getHIPOffloadTargetTriple(C.getDriver(), C.getInputArgs()), IdStr, - &Features); + auto T = + (IdStr == "amdgcnspirv") + ? llvm::Triple("spirv64-amd-amdhsa") + : *getHIPOffloadTargetTriple(C.getDriver(), C.getInputArgs()); + auto ArchStr = parseTargetID(T, IdStr, &Features); if (!ArchStr) { C.getDriver().Diag(clang::diag::err_drv_bad_target_id) << IdStr; C.setContainsError(); @@ -5755,7 +5753,7 @@ InputInfoList Driver::BuildJobsForActionNoCache( // We only have to generate a prefix for the host if this is not a top-level // action. std::string OffloadingPrefix = Action::GetOffloadingFileNamePrefix( -A->getOffloadingDeviceKind(), TC->getTriple().normalize(), +A->getOffloadingDeviceKind(), EffectiveTriple.normalize(), /*CreatePrefixForHost=*/isa(A) || !(A->getOffloadingHostActiveKinds() == Action::OFK_None || AtTopLevel)); diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index bdf3da0c96adca..9774d3fab741cb 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -1099,6 +1099,12 @@ std::string ToolChain::ComputeLLVMTriple(const ArgList &Args, } case llvm::Triple::aarch64_32: return getTripleString(); + case llvm::Triple::amdgcn: { +llvm::Triple Triple = getTriple(); +if (Args.getLastArgValue(options::OPT_mcpu_EQ) == "amdgcnspirv") + Triple.setArch(llvm::Triple::ArchType::spirv64); +return Triple.getTriple(); + } case llvm::Triple::arm: case llvm::Triple::armeb: case llvm::Triple::thumb: diff --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp b/clang/lib/Driver/ToolChains/HIPAMD.cpp index bae05cc0bb7353..4eb8c4f58923fd 100644 --- a/clang/lib/Driver/ToolChains/HIPAMD.cpp +++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp @@ -205,7 +205,7 @@ void AMDGCN::Linker::ConstructJob(Compilation &C, const JobAction &JA, if (JA.getType() == types::TY_LLVM_BC) return constructLlvmLinkCommand(C, JA, Inputs, Output, Args); - if (getToolChain().getTriple().isSPIRV()) + if (getToolChain().getEffectiveTriple().isSPIRV()) return constructLinkAndEmitSpirvCommand(C, JA, Inputs, Output, Args); return constructLldCommand(C, JA, Inputs, Output, Args); @@ -264,12 +264,14 @@ void HIPAMDToolChain::addClangTargetOptions( CC1Args.push_back("-fapply-global-visibility-to-externs"); } - // For SPIR-V we embed the command-line into the generated binary, in order to - // retrieve it at JIT time and be able to do target specific compilation with - // options that mat
[clang] [clang][Driver][HIP] Add support for mixing AMDGCNSPIRV & concrete `offload-arch`s. (PR #113509)
https://github.com/AlexVlx closed https://github.com/llvm/llvm-project/pull/113509 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add maintainer for Recovery expressions. (PR #114859)
https://github.com/hokein updated https://github.com/llvm/llvm-project/pull/114859 >From 04254d2352a385df1ab57c855d6b5de6e668844d Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Mon, 4 Nov 2024 21:01:32 +0100 Subject: [PATCH 1/2] [clang] Add maintainer for Recovery expressions. --- clang/Maintainers.rst | 6 ++ 1 file changed, 6 insertions(+) diff --git a/clang/Maintainers.rst b/clang/Maintainers.rst index 896b463d882d08..8c8ea572a15d6e 100644 --- a/clang/Maintainers.rst +++ b/clang/Maintainers.rst @@ -69,6 +69,12 @@ Sema | aeternalmail\@gmail.com (email), Sirraide (GitHub), Ætérnal (Discord), Sirraide (Discourse) +Recovery AST + +| Haojian Wu +| hokein.wu\@gmail.com (email), hokein (Phabricator), hokein (GitHub) + + Experimental new constant interpreter ~ | Timm Bäder >From 601364a6b11ea029e85e0972cfe7ebd77ef9592e Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 5 Nov 2024 09:01:22 +0100 Subject: [PATCH 2/2] Add discourse handle. --- clang/Maintainers.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/Maintainers.rst b/clang/Maintainers.rst index 8c8ea572a15d6e..299d8e0511953d 100644 --- a/clang/Maintainers.rst +++ b/clang/Maintainers.rst @@ -72,7 +72,7 @@ Sema Recovery AST | Haojian Wu -| hokein.wu\@gmail.com (email), hokein (Phabricator), hokein (GitHub) +| hokein.wu\@gmail.com (email), hokein (Phabricator), hokein (GitHub), hokein (Discourse) Experimental new constant interpreter ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RFC] [clang] [CodeGen] Avoid creating global variable repeatedly when type are not specified (PR #114948)
https://github.com/ChuanqiXu9 created https://github.com/llvm/llvm-project/pull/114948 This comes from an internal crash. I know generally it is better to reproduce it first but I do feel the pattern is pretty risky. So I am wondering if we can discuss it first. So maybe this is more of a discussion instead of a pure PR. Then story is, when we try to get or create a LLVM global for a C/C++'s global, we will try to look up the name first for the existing globals. And if we find one, we will perform some checks. If the checks pass, we will return the found one. If not, we will create a new one and replace the previous one. (Why do we want to do this? My instinct reaction is that we should abort here): https://github.com/llvm/llvm-project/blob/bf43a138f0a6220cd043a376200bd739cacb25e3/clang/lib/CodeGen/CodeGenModule.cpp#L4966-L4982 https://github.com/llvm/llvm-project/blob/bf43a138f0a6220cd043a376200bd739cacb25e3/clang/lib/CodeGen/CodeGenModule.cpp#L5017-L5032 The problem is, if we store the address of a global variable and the global variable got replaced later, the address we stored became a wild pointer! e.g. https://github.com/llvm/llvm-project/blob/283273fa1e3be4a03f06a5efd08a8c818be981fd/clang/lib/CodeGen/CodeGenModule.cpp#L2092-L2097 I feel this is pretty dangerous. And to my knowledge, I think we'd better to not remove things emitted during CodeGen. Then, one of the trigger for the problem is `CodeGenModule::GetAddrOfGlobalVar`: https://github.com/llvm/llvm-project/blob/283273fa1e3be4a03f06a5efd08a8c818be981fd/clang/lib/CodeGen/CodeGenModule.cpp#L5232C17-L5243 The arguments except `D` can be omitted. And if we don't specify `Ty`, the function will try to deduce the type from `D`. And use the type to get or create a LLVM global in the above process. And the `Ty` arguments may not always be omitted, e.g., in https://github.com/llvm/llvm-project/blob/283273fa1e3be4a03f06a5efd08a8c818be981fd/clang/lib/CodeGen/CodeGenModule.cpp#L5484-L5564, we will try to deduce the LLVM type directly. Then problem happens, sometimes we try to get or create the global variable by the AST type, but sometimes we try to get or create the **same** global variable by deduced type, and if the two types differs, we may be in the trouble of wild pointer. (the two types are compatible: e.g., one is `struct { %another.struct}` with `%another.struct = { ptr }` and another type is `{ { ptr } }`). The solution or one workaround I got is, in `CodeGenModule::GetAddrOfGlobalVar`, if we didn't specify the `Ty` and we have the same variable, return the variable directly. I think it makes sense since if the `Ty` is not specified, it implies the caller doesn't care about it too much. WDYT? >From 5b7def2c1deb4315cd043bc090a7364edbaeb84c Mon Sep 17 00:00:00 2001 From: Chuanqi Xu Date: Tue, 5 Nov 2024 15:50:50 +0800 Subject: [PATCH] [RFC] [clang] [CodeGen] Avoid creating global variable repeatedly when type are not specified --- clang/lib/CodeGen/CodeGenModule.cpp | 9 - clang/test/CodeGen/attr-weakref2.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index ba376f9ecfacde..9566cfb8d6e794 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -5233,11 +5233,18 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D, llvm::Type *Ty, ForDefinition_t IsForDefinition) { assert(D->hasGlobalStorage() && "Not a global variable"); + + StringRef MangledName = getMangledName(D); + llvm::GlobalValue *Entry = GetGlobalValue(MangledName); QualType ASTTy = D->getType(); + LangAS AddrSpace = ASTTy.getAddressSpace(); + + if (Entry && !Ty && Entry->getAddressSpace() == getContext().getTargetAddressSpace(AddrSpace)) +return Entry; + if (!Ty) Ty = getTypes().ConvertTypeForMem(ASTTy); - StringRef MangledName = getMangledName(D); return GetOrCreateLLVMGlobal(MangledName, Ty, ASTTy.getAddressSpace(), D, IsForDefinition); } diff --git a/clang/test/CodeGen/attr-weakref2.c b/clang/test/CodeGen/attr-weakref2.c index 114f048a851832..a67f906810faf3 100644 --- a/clang/test/CodeGen/attr-weakref2.c +++ b/clang/test/CodeGen/attr-weakref2.c @@ -33,7 +33,7 @@ int test4_h(void) { } int test4_f; -// CHECK: @test5_f = external global i32 +// CHECK: @test5_f = extern_weak global i32 extern int test5_f; static int test5_g __attribute__((weakref("test5_f"))); int test5_h(void) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Consider outer instantiation scopes for constraint normalization (PR #114749)
zyn0217 wrote: Backport PR https://github.com/llvm/llvm-project/pull/114951 (I have to backport it manually as there are some other changes on the post-19 branch) https://github.com/llvm/llvm-project/pull/114749 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] SemaFunctionEffects: When verifying a function, ignore any trailing 'requires' clause. (PR #114266)
https://github.com/Sirraide closed https://github.com/llvm/llvm-project/pull/114266 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits