[clang] [clang] Generate nuw GEPs for struct member accesses (PR #99538)
@@ -1902,16 +1902,18 @@ class IRBuilderBase { } Value *CreateConstGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1, -const Twine = "") { +const Twine = "", +GEPNoWrapFlags NWFlags = GEPNoWrapFlags::none()) { Value *Idxs[] = { ConstantInt::get(Type::getInt32Ty(Context), Idx0), ConstantInt::get(Type::getInt32Ty(Context), Idx1) }; -if (auto *V = Folder.FoldGEP(Ty, Ptr, Idxs, GEPNoWrapFlags::none())) +if (auto *V = +Folder.FoldGEP(Ty, Ptr, Idxs, /*IsInBounds=*/NWFlags.isInBounds())) nikic wrote: Shouldn't this be? ```suggestion Folder.FoldGEP(Ty, Ptr, Idxs, NWFlags)) ``` https://github.com/llvm/llvm-project/pull/99538 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Generate nuw GEPs for struct member accesses (PR #99538)
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/99538 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Generate nuw GEPs for struct member accesses (PR #99538)
https://github.com/nikic commented: As you already put in the test update work, I'm happy to take it :) https://github.com/llvm/llvm-project/pull/99538 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][LoongArch] Align global symbol by size (PR #101309)
nikic wrote: I think for your use case you want to implement the shouldAlignPointerArgs() hook. It exists to allow raising GV/Alloca alignment for objects used inside memcpy and similar. Check out the ARM backend for an example. https://github.com/llvm/llvm-project/pull/101309 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [LTO] enable `ObjCARCContractPass` only on optimized build (PR #101114)
nikic wrote: The pipeline test changes here still look problematic. Can you make the ObjCARCContract pass preserve the DT? https://github.com/llvm/llvm-project/pull/101114 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Update argument checking tablegen code to use a 'full' name (PR #99993)
nikic wrote: This causes significant compile-time regressions, especially for unoptimized builds: https://llvm-compile-time-tracker.com/compare.php?from=39b6900852e7a1187bd742ba5c1387ca1be58e2c=2acf77f987331c05520c5bfd849326909ffce983=instructions:u You probably need to separately match the syntax and the name without constructing a temporary `std::string`. https://github.com/llvm/llvm-project/pull/3 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Sanitizer] Make sanitizer passes idempotent (PR #99439)
@@ -12,12 +12,33 @@ //===--===// #include "llvm/Transforms/Instrumentation.h" +#include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Module.h" #include "llvm/TargetParser/Triple.h" using namespace llvm; +static cl::opt ClIgnoreRedundantInstrumentation( +"ignore-redundant-instrumentation", +cl::desc("Ignore redundant instrumentation"), cl::Hidden, cl::init(false)); + +/// Check if module has flag attached, if not add the flag. +bool llvm::checkIfAlreadyInstrumented(Module , StringRef flag) { nikic wrote: ```suggestion bool llvm::checkIfAlreadyInstrumented(Module , StringRef Flag) { ``` https://github.com/llvm/llvm-project/pull/99439 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Sanitizer] Make sanitizer passes idempotent (PR #99439)
@@ -19,6 +19,7 @@ #include "llvm/IR/Function.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Instruction.h" +#include "llvm/IR/Module.h" nikic wrote: Should be a forward-declare. https://github.com/llvm/llvm-project/pull/99439 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Sanitizer] Make sanitizer passes idempotent (PR #99439)
@@ -12,12 +12,33 @@ //===--===// #include "llvm/Transforms/Instrumentation.h" +#include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Module.h" #include "llvm/TargetParser/Triple.h" using namespace llvm; +static cl::opt ClIgnoreRedundantInstrumentation( +"ignore-redundant-instrumentation", +cl::desc("Ignore redundant instrumentation"), cl::Hidden, cl::init(false)); + +/// Check if module has flag attached, if not add the flag. +bool llvm::checkIfAlreadyInstrumented(Module , StringRef flag) { + if (M.getModuleFlag(flag)) { +if (ClIgnoreRedundantInstrumentation) + return true; +std::string diagInfo = +"Redundant instrumentation detected, with module flag: " + +std::string(flag); +M.getContext().diagnose( +DiagnosticInfoInlineAsm(diagInfo, DiagnosticSeverity::DS_Warning)); nikic wrote: This doesn't seem related to inline asm? https://github.com/llvm/llvm-project/pull/99439 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Sanitizer] Make sanitizer passes idempotent (PR #99439)
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/99439 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Sanitizer] Make sanitizer passes idempotent (PR #99439)
https://github.com/nikic commented: Some nits, no strong opinion on overall approach. https://github.com/llvm/llvm-project/pull/99439 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][CodeGen] Add metadata for load from reference (PR #98746)
https://github.com/nikic commented: I think this is missing some test coverage for the `!align` values. Right now it just includes test updates, and I don't think the actual value is checked anywhere. https://github.com/llvm/llvm-project/pull/98746 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] Remove the `x86_mmx` IR type. (PR #98505)
nikic wrote: 19.x has already branched, so it's fine to land this now (for LLVM 20). https://github.com/llvm/llvm-project/pull/98505 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Fix some type errors, add type annotations (PR #98745)
nikic wrote: @DeinAlptraum It's a major change to the clang python bindings. In general, please refrain from landing major changes immediately before branching (and certainly do not backport them to the release branch). https://github.com/llvm/llvm-project/pull/98745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libclang/python] Fix some type errors, add type annotations (PR #98745)
nikic wrote: https://github.com/llvm/llvm-project/pull/78114 should absolutely not go onto the release branch -- and with that in mind, please hold off on merging this PR until LLVM 19 has branched as well. https://github.com/llvm/llvm-project/pull/98745 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Add -Wimplicit-fallthrough to -Wextra (PR #97926)
nikic wrote: CTMark is not compiled with `-Wextra`, so we'd not get any useful data out of this patch. What changes does one have to do to enable `-Wimplicit-fallthrough` by default (not just for `-Wextra`)? https://github.com/llvm/llvm-project/pull/97926 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][CodeGen] Add metadata for load from reference (PR #98746)
@@ -2799,9 +2799,37 @@ CodeGenFunction::EmitLoadOfReference(LValue RefLVal, llvm::LoadInst *Load = Builder.CreateLoad(RefLVal.getAddress(), RefLVal.isVolatile()); CGM.DecorateInstructionWithTBAA(Load, RefLVal.getTBAAInfo()); - return makeNaturalAddressForPointer(Load, RefLVal.getType()->getPointeeType(), - CharUnits(), /*ForPointeeType=*/true, - PointeeBaseInfo, PointeeTBAAInfo); + QualType PTy = RefLVal.getType()->getPointeeType(); + if (!PTy->isIncompleteType() && PTy->isConstantSizeType()) { +llvm::LLVMContext = getLLVMContext(); +llvm::MDBuilder MDB(Ctx); +// Emit !dereferenceable metadata +Load->setMetadata( +llvm::LLVMContext::MD_dereferenceable, +llvm::MDNode::get(Ctx, + MDB.createConstant(llvm::ConstantInt::get( + Builder.getInt64Ty(), nikic wrote: I don't think this is safe. It's not spelled out in LangRef, but effectively `!dereferenceable` metadata means "dereferenceable while this SSA value is in scope". References in C++ are allowed to become dangling, as long as they are not used (in the sense of lvalue to rvalue conversion). This problem also exists for function parameters, but I think it's much more likely to cause issues in this context. Note that rustc also does not emit dereferenceable on function returns and loads, only on parameters, for this reason. https://github.com/llvm/llvm-project/pull/98746 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CVP] Infer range return attribute (PR #99620)
https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/99620 >From 23bdf84091020df916441b3ed2d2cc74f4059e37 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 19 Jul 2024 11:02:56 +0200 Subject: [PATCH] [CVP] Infer range return attribute We already infer this in IPSCCP, but as that pass runs very early, it cannot make use of simplifications (in particular post-inline simplifications). This fixes most cases from https://github.com/llvm/llvm-project/issues/98946 (everything apart from f2 where the assume is dropped). --- clang/test/CodeGen/attr-counted-by.c | 8 +- .../Scalar/CorrelatedValuePropagation.cpp | 18 + .../CorrelatedValuePropagation/add.ll | 2 +- .../CorrelatedValuePropagation/ashr.ll| 8 +- .../CorrelatedValuePropagation/basic.ll | 78 +-- .../cond-using-block-value.ll | 2 +- .../CorrelatedValuePropagation/select.ll | 8 +- .../CorrelatedValuePropagation/vectors.ll | 44 +-- 8 files changed, 93 insertions(+), 75 deletions(-) diff --git a/clang/test/CodeGen/attr-counted-by.c b/clang/test/CodeGen/attr-counted-by.c index 32db136076d7d..0fd3d4cc85f83 100644 --- a/clang/test/CodeGen/attr-counted-by.c +++ b/clang/test/CodeGen/attr-counted-by.c @@ -639,7 +639,7 @@ void test6(struct anon_struct *p, int index) { p->array[index] = __builtin_dynamic_object_size(p->array, 1); } -// SANITIZE-WITH-ATTR-LABEL: define dso_local i64 @test6_bdos( +// SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, -3) i64 @test6_bdos( // SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 8 @@ -649,7 +649,7 @@ void test6(struct anon_struct *p, int index) { // SANITIZE-WITH-ATTR-NEXT:[[TMP1:%.*]] = select i1 [[DOTINV]], i64 0, i64 [[TMP0]] // SANITIZE-WITH-ATTR-NEXT:ret i64 [[TMP1]] // -// NO-SANITIZE-WITH-ATTR-LABEL: define dso_local i64 @test6_bdos( +// NO-SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, -3) i64 @test6_bdos( // NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 8 @@ -955,7 +955,7 @@ void test10(struct union_of_fams *p, int index) { p->bytes[index] = (unsigned char)__builtin_dynamic_object_size(p->bytes, 1); } -// SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 -2147483648, 2147483648) i64 @test10_bdos( +// SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, 2147483648) i64 @test10_bdos( // SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 8 @@ -964,7 +964,7 @@ void test10(struct union_of_fams *p, int index) { // SANITIZE-WITH-ATTR-NEXT:[[TMP0:%.*]] = zext nneg i32 [[NARROW]] to i64 // SANITIZE-WITH-ATTR-NEXT:ret i64 [[TMP0]] // -// NO-SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 -2147483648, 2147483648) i64 @test10_bdos( +// NO-SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, 2147483648) i64 @test10_bdos( // NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 8 diff --git a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp index 95de8eceb6be5..df899495b8c0c 100644 --- a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp +++ b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp @@ -1207,6 +1207,11 @@ static bool processAnd(BinaryOperator *BinOp, LazyValueInfo *LVI) { static bool runImpl(Function , LazyValueInfo *LVI, DominatorTree *DT, const SimplifyQuery ) { bool FnChanged = false; + std::optional RetRange; + if (F.getReturnType()->isIntOrIntVectorTy()) +RetRange = +ConstantRange::getEmpty(F.getReturnType()->getScalarSizeInBits()); + // Visiting in a pre-order depth-first traversal causes us to simplify early // blocks before querying later blocks (which require us to analyze early // blocks). Eagerly simplifying shallow blocks means there is strictly less @@ -1277,6 +1282,11 @@ static bool runImpl(Function , LazyValueInfo *LVI, DominatorTree *DT, // constant folding the return values of callees. auto *RetVal = RI->getReturnValue(); if (!RetVal) break; // handle "ret void" + if (RetRange && !RetRange->isFullSet()) +RetRange = +
[clang] [llvm] [CVP] Infer range return attribute (PR #99620)
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/99620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CVP] Infer range return attribute (PR #99620)
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/99620 We already infer this in IPSCCP, but as that pass runs very early, it cannot make use of simplifications (in particular post-inline simplifications). This fixes most cases from https://github.com/llvm/llvm-project/issues/98946 (everything apart from f2 where the assume is dropped). (Draft because there is a significant compile-time regression in lencod ThinLTO that I should take a look at first: http://llvm-compile-time-tracker.com/compare.php?from=a1d77caaabbb5279b734c061dab36b2138ec476d=66f84aa164ca7c42e02c4b1c3ba1b4fb71d6220e=instructions%3Au) >From 9756800f3f5cbba0f84e2e7b551c2a45b3e70fc9 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 19 Jul 2024 11:02:56 +0200 Subject: [PATCH] [CVP] Infer range return attribute We already infer this in IPSCCP, but as that pass runs very early, it cannot make use of simplifications (in particular post-inline simplifications). This fixes most cases from https://github.com/llvm/llvm-project/issues/98946 (everything apart from f2 where the assume is dropped). --- clang/test/CodeGen/attr-counted-by.c | 8 ++--- .../Scalar/CorrelatedValuePropagation.cpp | 12 +++ .../CorrelatedValuePropagation/add.ll | 2 +- .../CorrelatedValuePropagation/basic.ll | 10 +++--- .../cond-using-block-value.ll | 2 +- .../CorrelatedValuePropagation/select.ll | 6 ++-- .../CorrelatedValuePropagation/vectors.ll | 34 +-- 7 files changed, 43 insertions(+), 31 deletions(-) diff --git a/clang/test/CodeGen/attr-counted-by.c b/clang/test/CodeGen/attr-counted-by.c index 32db136076d7d..0fd3d4cc85f83 100644 --- a/clang/test/CodeGen/attr-counted-by.c +++ b/clang/test/CodeGen/attr-counted-by.c @@ -639,7 +639,7 @@ void test6(struct anon_struct *p, int index) { p->array[index] = __builtin_dynamic_object_size(p->array, 1); } -// SANITIZE-WITH-ATTR-LABEL: define dso_local i64 @test6_bdos( +// SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, -3) i64 @test6_bdos( // SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 8 @@ -649,7 +649,7 @@ void test6(struct anon_struct *p, int index) { // SANITIZE-WITH-ATTR-NEXT:[[TMP1:%.*]] = select i1 [[DOTINV]], i64 0, i64 [[TMP0]] // SANITIZE-WITH-ATTR-NEXT:ret i64 [[TMP1]] // -// NO-SANITIZE-WITH-ATTR-LABEL: define dso_local i64 @test6_bdos( +// NO-SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, -3) i64 @test6_bdos( // NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 8 @@ -955,7 +955,7 @@ void test10(struct union_of_fams *p, int index) { p->bytes[index] = (unsigned char)__builtin_dynamic_object_size(p->bytes, 1); } -// SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 -2147483648, 2147483648) i64 @test10_bdos( +// SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, 2147483648) i64 @test10_bdos( // SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // SANITIZE-WITH-ATTR-NEXT: entry: // SANITIZE-WITH-ATTR-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 8 @@ -964,7 +964,7 @@ void test10(struct union_of_fams *p, int index) { // SANITIZE-WITH-ATTR-NEXT:[[TMP0:%.*]] = zext nneg i32 [[NARROW]] to i64 // SANITIZE-WITH-ATTR-NEXT:ret i64 [[TMP0]] // -// NO-SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 -2147483648, 2147483648) i64 @test10_bdos( +// NO-SANITIZE-WITH-ATTR-LABEL: define dso_local range(i64 0, 2147483648) i64 @test10_bdos( // NO-SANITIZE-WITH-ATTR-SAME: ptr nocapture noundef readonly [[P:%.*]]) local_unnamed_addr #[[ATTR2]] { // NO-SANITIZE-WITH-ATTR-NEXT: entry: // NO-SANITIZE-WITH-ATTR-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 8 diff --git a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp index 95de8eceb6be5..c34fb0746931e 100644 --- a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp +++ b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp @@ -1283,6 +1283,18 @@ static bool runImpl(Function , LazyValueInfo *LVI, DominatorTree *DT, RI->replaceUsesOfWith(RetVal, C); BBChanged = true; } + // Infer range attribute on return value. + if (RetVal->getType()->isIntOrIntVectorTy()) { +ConstantRange CR = LVI->getConstantRange(RetVal, RI, + /*UndefAllowed=*/false); +if (!CR.isFullSet()) { + Attribute RangeAttr =
[clang] Performance optimizations for function effects (nonblocking attribute etc.) (PR #96844)
nikic wrote: Thanks for following up on this! For the record, this was the final result: https://llvm-compile-time-tracker.com/compare.php?from=18cdfa72e046a40d4372ee98602fd1a65a94=0bb68b55715487447ffceaa1ab59f7a0bc8c7979=instructions:u https://github.com/llvm/llvm-project/pull/96844 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)
nikic wrote: I can see the argument for dereferenceable_or_null, but I don't see any way in which range will be useful. https://github.com/llvm/llvm-project/pull/91101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Undefined behaviour pointer arithmetic with null pointer (PR #98648)
@@ -230,8 +230,13 @@ void DwarfFDECache::iterateCacheEntries(void (*func)( } #endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) - -#define arrayoffsetof(type, index, field) ((size_t)(&((type *)0)[index].field)) +template +__attribute__((no_sanitize("undefined"))) static inline size_t +_arrayoffsetof(int index, FIELD TYPE::*field) { + return ((size_t)(&(((TYPE *)0)[index].*field))); +} +#define arrayoffsetof(type, index, field) \ + _arrayoffsetof(index, ::field) nikic wrote: You can replace this with something like `sizeof(type) * index + offsetof(type, field)`, which is safe. https://github.com/llvm/llvm-project/pull/98648 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][NFC] Fix a warning (PR #98611)
https://github.com/nikic approved this pull request. https://github.com/llvm/llvm-project/pull/98611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)
nikic wrote: > Okay, so x86_64 describes it in byte terms and says they're little-endian, > which is consistent with the overall target. Interestingly, it does not > guarantee the content of the excess bits. The code-generation in this patch > is consistent with that: the extension we do is unnecessary but allowed, and > then we truncate it away after load. If we ever add some way to tell the > backend that a truncation is known to be reversing a sign/zero-extension, > we'll need to not set it on this target. FYI this already exists in the form of `trunc nuw` / `trunc nsw`. (Though it's not fully optimized yet.) https://github.com/llvm/llvm-project/pull/91364 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NFC][Clang] Move set functions out BranchProtectionInfo. (PR #98451)
@@ -413,6 +414,12 @@ class TargetCodeGenInfo { return nullptr; } + void setFnAttributes(const TargetInfo::BranchProtectionInfo , nikic wrote: ```suggestion void setBranchProtectionFnAttributes(const TargetInfo::BranchProtectionInfo , ``` Or so? The current name seems a bit too generic. https://github.com/llvm/llvm-project/pull/98451 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NFC][Clang] Move set functions out BranchProtectionInfo. (PR #98451)
@@ -133,7 +133,7 @@ class AArch64TargetCodeGenInfo : public TargetCodeGenInfo { } } auto *Fn = cast(GV); -BPI.setFnAttributes(*Fn); +CGM.getTargetCodeGenInfo().setFnAttributes(BPI, *Fn); nikic wrote: ```suggestion setFnAttributes(BPI, *Fn); ``` We're inside AArch64TargetCodeGenInfo here, so I think this is just a member function? https://github.com/llvm/llvm-project/pull/98451 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NFC][Clang] Move functions of BranchProtectionInfo out of line (PR #98329)
nikic wrote: > in some build config `TargetInfo.cpp` is built without dependency to > `LLVM-Core`. Okay, that means that putting this code inside Basic/ is a layering violation. You need to move it into CodeGen/. Probably best to revert the whole change in the meantime. https://github.com/llvm/llvm-project/pull/98329 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [NFC][Clang] Move functions of BranchProtectionInfo out of line (PR #98329)
https://github.com/nikic approved this pull request. LGTM, thanks! https://github.com/llvm/llvm-project/pull/98329 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][ARM][AArch64] Alway emit protection attributes for functions. (PR #82819)
@@ -32,7 +32,9 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSet.h" #include "llvm/Frontend/OpenMP/OMPGridValues.h" +#include "llvm/IR/Attributes.h" #include "llvm/IR/DerivedTypes.h" +#include "llvm/IR/Function.h" nikic wrote: Could you please move the implementation out of line, so that these headers don't get included here? This has a significant impact on clang build times. (Or possibly this shouldn't be in Basic/TargetInfo at all? I'm not familiar with clang layering, but this sounds more like CodeGen/TargetInfo than Basic/TargetInfo to me.) https://github.com/llvm/llvm-project/pull/82819 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [llvm][TargetParser] Return StringMap from getHostCPUFeatures (PR #97824)
@@ -20,16 +20,15 @@ using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + const < StringMap features = sys::getHostCPUFeatures(features); nikic wrote: I think something went wrong here... https://github.com/llvm/llvm-project/pull/97824 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SCCP] Add support for vectors (PR #98026)
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/98026 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SCCP] Add support for vectors (PR #98026)
https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/98026 >From e5c0cba0f065a8efab6c8a91d436f1309478 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 8 Jul 2024 15:02:31 +0200 Subject: [PATCH 1/2] [SCCP] Add support for vectors Add preliminary support for vectors of integers by using the `ValueLatticeElement::asConstantRange()` helper instead of a custom implementation, and relxing various integer type checks. This enables just the part that works automatically, e.g. icmps with a constant vector operand aren't supported yet. The change in ssa.copy handling is because asConstantRange() returns an unknown LV for empty range, while SCCP's getConstantRange() returned a full range. I've made the change to preserve the existing behavior. --- llvm/lib/Transforms/Utils/SCCPSolver.cpp | 46 +-- .../test/Transforms/SCCP/add-nuw-nsw-flags.ll | 6 +-- llvm/test/Transforms/SCCP/overdefined-ext.ll | 18 +++- .../Transforms/SCCP/trunc-nuw-nsw-flags.ll| 2 +- 4 files changed, 31 insertions(+), 41 deletions(-) diff --git a/llvm/lib/Transforms/Utils/SCCPSolver.cpp b/llvm/lib/Transforms/Utils/SCCPSolver.cpp index db0d40b317d17..7bfff4dfa67ad 100644 --- a/llvm/lib/Transforms/Utils/SCCPSolver.cpp +++ b/llvm/lib/Transforms/Utils/SCCPSolver.cpp @@ -42,14 +42,6 @@ static ValueLatticeElement::MergeOptions getMaxWidenStepsOpts() { MaxNumRangeExtensions); } -static ConstantRange getConstantRange(const ValueLatticeElement , Type *Ty, - bool UndefAllowed) { - assert(Ty->isIntOrIntVectorTy() && "Should be int or int vector"); - if (LV.isConstantRange(UndefAllowed)) -return LV.getConstantRange(); - return ConstantRange::getFull(Ty->getScalarSizeInBits()); -} - namespace llvm { bool SCCPSolver::isConstant(const ValueLatticeElement ) { @@ -109,14 +101,14 @@ static bool refineInstruction(SCCPSolver , Instruction ) { bool Changed = false; auto GetRange = [, ](Value *Op) { -if (auto *Const = dyn_cast(Op)) - return ConstantRange(Const->getValue()); -if (isa(Op) || InsertedValues.contains(Op)) { +if (auto *Const = dyn_cast(Op)) + return Const->toConstantRange(); +if (InsertedValues.contains(Op)) { unsigned Bitwidth = Op->getType()->getScalarSizeInBits(); return ConstantRange::getFull(Bitwidth); } -return getConstantRange(Solver.getLatticeValueFor(Op), Op->getType(), -/*UndefAllowed=*/false); +return Solver.getLatticeValueFor(Op).asConstantRange( +Op->getType(), /*UndefAllowed=*/false); }; if (isa(Inst)) { @@ -819,7 +811,7 @@ class SCCPInstVisitor : public InstVisitor { } void trackValueOfArgument(Argument *A) { -if (A->getType()->isIntegerTy()) { +if (A->getType()->isIntOrIntVectorTy()) { if (std::optional Range = A->getRange()) { markConstantRange(ValueState[A], A, *Range); return; @@ -1296,11 +1288,12 @@ void SCCPInstVisitor::visitCastInst(CastInst ) { } // Ignore bitcasts, as they may change the number of vector elements. - if (I.getDestTy()->isIntegerTy() && I.getSrcTy()->isIntOrIntVectorTy() && + if (I.getDestTy()->isIntOrIntVectorTy() && + I.getSrcTy()->isIntOrIntVectorTy() && I.getOpcode() != Instruction::BitCast) { auto = getValueState(); ConstantRange OpRange = -getConstantRange(OpSt, I.getSrcTy(), /*UndefAllowed=*/false); +OpSt.asConstantRange(I.getSrcTy(), /*UndefAllowed=*/false); Type *DestTy = I.getDestTy(); ConstantRange Res = @@ -1322,8 +1315,8 @@ void SCCPInstVisitor::handleExtractOfWithOverflow(ExtractValueInst , return; // Wait to resolve. Type *Ty = LHS->getType(); - ConstantRange LR = getConstantRange(L, Ty, /*UndefAllowed=*/false); - ConstantRange RR = getConstantRange(R, Ty, /*UndefAllowed=*/false); + ConstantRange LR = L.asConstantRange(Ty, /*UndefAllowed=*/false); + ConstantRange RR = R.asConstantRange(Ty, /*UndefAllowed=*/false); if (Idx == 0) { ConstantRange Res = LR.binaryOp(WO->getBinaryOp(), RR); mergeInValue(, ValueLatticeElement::getRange(Res)); @@ -1523,14 +1516,14 @@ void SCCPInstVisitor::visitBinaryOperator(Instruction ) { } // Only use ranges for binary operators on integers. - if (!I.getType()->isIntegerTy()) + if (!I.getType()->isIntOrIntVectorTy()) return markOverdefined(); // Try to simplify to a constant range. ConstantRange A = - getConstantRange(V1State, I.getType(), /*UndefAllowed=*/false); + V1State.asConstantRange(I.getType(), /*UndefAllowed=*/false); ConstantRange B = - getConstantRange(V2State, I.getType(), /*UndefAllowed=*/false); + V2State.asConstantRange(I.getType(), /*UndefAllowed=*/false); auto *BO = cast(); ConstantRange R = ConstantRange::getEmpty(I.getType()->getScalarSizeInBits()); @@ -1626,7 +1619,7 @@ void
[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)
nikic wrote: High level question: Are all of these really useful? For parameter attributes, there are really two types, ones that are used to reason about calls, and ones used to reason about function definitions. I think the split here is something like: * readonly/readnone: Mostly used for calls. Since recently used for definitions in conjunction with noalias. * writeonly: Used for calls. * range, dereferenceable_or_null: Used for definitions. * align: Mostly used for definitions, but also used for intrinsic calls. * nonnull, dereferenceable: Mostly used for definitions. Used for calls in conjunction with noundef for "dominating conditions" in isKnownNonZero. Based on that breakdown, I can see some usefulness for propagating the readonly family, align and nonnull/dereferenceable. Is there anything that propagating range and dereferenceof_or_null is good for? I haven't checked how the latter is used in detail, but I'm pretty confident that we don't use call-site parameter range information for anything. https://github.com/llvm/llvm-project/pull/91101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)
nikic wrote: @htyu LLVM does not support this. Support for doing that was officially removed about ten years ago when data layout became mandatory, but even prior to that IR was already target-specific, e.g. due to target-specific ABI. I think some parts of MLIR may support this, but certainly nothing does on the LLVM IR level. https://github.com/llvm/llvm-project/pull/68882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)
@@ -1352,18 +1352,42 @@ static void AddParamAndFnBasicAttributes(const CallBase , auto = CalledFunction->getContext(); // Collect valid attributes for all params. - SmallVector ValidParamAttrs; + SmallVector ValidObjParamAttrs, ValidExactParamAttrs; bool HasAttrToPropagate = false; for (unsigned I = 0, E = CB.arg_size(); I < E; ++I) { -ValidParamAttrs.emplace_back(AttrBuilder{CB.getContext()}); +ValidObjParamAttrs.emplace_back(AttrBuilder{CB.getContext()}); +ValidExactParamAttrs.emplace_back(AttrBuilder{CB.getContext()}); // Access attributes can be propagated to any param with the same underlying // object as the argument. if (CB.paramHasAttr(I, Attribute::ReadNone)) - ValidParamAttrs.back().addAttribute(Attribute::ReadNone); + ValidObjParamAttrs.back().addAttribute(Attribute::ReadNone); if (CB.paramHasAttr(I, Attribute::ReadOnly)) - ValidParamAttrs.back().addAttribute(Attribute::ReadOnly); -HasAttrToPropagate |= ValidParamAttrs.back().hasAttributes(); + ValidObjParamAttrs.back().addAttribute(Attribute::ReadOnly); +HasAttrToPropagate |= ValidObjParamAttrs.back().hasAttributes(); + +// Attributes we can only propagate if the exact parameter is forwarded. + +// We can propagate both poison generating and UB generating attributes +// without any extra checks. The only attribute that is tricky to propagate +// is `noundef` (skipped for now) as that can create new UB where previous +// behavior was just using a poison value. +if (auto DerefBytes = CB.getParamDereferenceableBytes(I)) + ValidExactParamAttrs.back().addDereferenceableAttr(DerefBytes); +if (auto DerefOrNullBytes = CB.getParamDereferenceableOrNullBytes(I)) + ValidExactParamAttrs.back().addDereferenceableOrNullAttr( + DerefOrNullBytes); +if (CB.paramHasAttr(I, Attribute::NoFree)) + ValidExactParamAttrs.back().addAttribute(Attribute::NoFree); +if (CB.paramHasAttr(I, Attribute::NonNull)) + ValidExactParamAttrs.back().addAttribute(Attribute::NonNull); +if (auto Align = CB.getParamAlign(I)) + ValidExactParamAttrs.back().addAlignmentAttr(Align); +if (auto Range = CB.getParamRange(I)) + ValidExactParamAttrs.back().addRangeAttr(*Range); nikic wrote: Please do something like `for(AttrKind AK : ...) { Attribute Attr = CB.getParamAttr(I, AK); if (Attr.isValid()) ValidExactParamAttrs.back().addAttribute(Attr); }`. We can reuse the original Attributes, no need to reconstruct them. https://github.com/llvm/llvm-project/pull/91101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)
@@ -1381,21 +1405,58 @@ static void AddParamAndFnBasicAttributes(const CallBase , AttributeList AL = NewInnerCB->getAttributes(); for (unsigned I = 0, E = InnerCB->arg_size(); I < E; ++I) { // Check if the underlying value for the parameter is an argument. -const Value *UnderlyingV = -getUnderlyingObject(InnerCB->getArgOperand(I)); -const Argument *Arg = dyn_cast(UnderlyingV); -if (!Arg) - continue; +const Argument *Arg = dyn_cast(InnerCB->getArgOperand(I)); +unsigned ArgNo; +if (Arg) { + ArgNo = Arg->getArgNo(); + // For dereferenceable, dereferenceable_or_null, align, etc... + // we don't want to propagate if the existing param has the same + // attribute with "better" constraints. So, only remove from the + // existing AL if the region of the existing param is smaller than + // what we can propagate. AttributeList's merge API honours the + // already existing attribute value so we choose the "better" + // attribute by removing if the existing one is worse. nikic wrote: I think you got this the wrong way around? If you use addAttribute() you will always overwrite the new attribute, not keep the existing one. Looking at your tests, you do indeed decrease alignment in some cases, e.g. prop_param_deref_align_no_update. https://github.com/llvm/llvm-project/pull/91101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)
@@ -1381,21 +1405,58 @@ static void AddParamAndFnBasicAttributes(const CallBase , AttributeList AL = NewInnerCB->getAttributes(); for (unsigned I = 0, E = InnerCB->arg_size(); I < E; ++I) { // Check if the underlying value for the parameter is an argument. -const Value *UnderlyingV = -getUnderlyingObject(InnerCB->getArgOperand(I)); -const Argument *Arg = dyn_cast(UnderlyingV); -if (!Arg) - continue; +const Argument *Arg = dyn_cast(InnerCB->getArgOperand(I)); +unsigned ArgNo; +if (Arg) { + ArgNo = Arg->getArgNo(); + // For dereferenceable, dereferenceable_or_null, align, etc... + // we don't want to propagate if the existing param has the same + // attribute with "better" constraints. So, only remove from the + // existing AL if the region of the existing param is smaller than + // what we can propagate. AttributeList's merge API honours the + // already existing attribute value so we choose the "better" + // attribute by removing if the existing one is worse. + if (AL.getParamDereferenceableBytes(I) < + ValidExactParamAttrs[ArgNo].getDereferenceableBytes()) +AL = +AL.removeParamAttribute(Context, I, Attribute::Dereferenceable); + if (AL.getParamDereferenceableOrNullBytes(I) < + ValidExactParamAttrs[ArgNo].getDereferenceableOrNullBytes()) +AL = +AL.removeParamAttribute(Context, I, Attribute::Dereferenceable); + if (AL.getParamAlignment(I).valueOrOne() < + ValidExactParamAttrs[ArgNo].getAlignment().valueOrOne()) +AL = AL.removeParamAttribute(Context, I, Attribute::Alignment); + + auto ExistingRange = AL.getParamRange(I); + AL = AL.addParamAttributes(Context, I, ValidExactParamAttrs[ArgNo]); + + // For range we use the intersection. + if (ExistingRange.has_value()) { +if (auto NewRange = ValidExactParamAttrs[ArgNo].getRange()) { + auto CombinedRange = ExistingRange->intersectWith(*NewRange); nikic wrote: auto -> ConstantRange https://github.com/llvm/llvm-project/pull/91101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)
@@ -1352,18 +1352,42 @@ static void AddParamAndFnBasicAttributes(const CallBase , auto = CalledFunction->getContext(); // Collect valid attributes for all params. - SmallVector ValidParamAttrs; + SmallVector ValidObjParamAttrs, ValidExactParamAttrs; bool HasAttrToPropagate = false; for (unsigned I = 0, E = CB.arg_size(); I < E; ++I) { -ValidParamAttrs.emplace_back(AttrBuilder{CB.getContext()}); +ValidObjParamAttrs.emplace_back(AttrBuilder{CB.getContext()}); +ValidExactParamAttrs.emplace_back(AttrBuilder{CB.getContext()}); // Access attributes can be propagated to any param with the same underlying // object as the argument. if (CB.paramHasAttr(I, Attribute::ReadNone)) - ValidParamAttrs.back().addAttribute(Attribute::ReadNone); + ValidObjParamAttrs.back().addAttribute(Attribute::ReadNone); if (CB.paramHasAttr(I, Attribute::ReadOnly)) - ValidParamAttrs.back().addAttribute(Attribute::ReadOnly); -HasAttrToPropagate |= ValidParamAttrs.back().hasAttributes(); + ValidObjParamAttrs.back().addAttribute(Attribute::ReadOnly); +HasAttrToPropagate |= ValidObjParamAttrs.back().hasAttributes(); + +// Attributes we can only propagate if the exact parameter is forwarded. + +// We can propagate both poison generating and UB generating attributes +// without any extra checks. The only attribute that is tricky to propagate +// is `noundef` (skipped for now) as that can create new UB where previous +// behavior was just using a poison value. +if (auto DerefBytes = CB.getParamDereferenceableBytes(I)) + ValidExactParamAttrs.back().addDereferenceableAttr(DerefBytes); +if (auto DerefOrNullBytes = CB.getParamDereferenceableOrNullBytes(I)) + ValidExactParamAttrs.back().addDereferenceableOrNullAttr( + DerefOrNullBytes); +if (CB.paramHasAttr(I, Attribute::NoFree)) + ValidExactParamAttrs.back().addAttribute(Attribute::NoFree); nikic wrote: Please drop nofree propagation. It's an essentially unused attribute with undecided semantics. https://github.com/llvm/llvm-project/pull/91101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)
@@ -1381,21 +1405,58 @@ static void AddParamAndFnBasicAttributes(const CallBase , AttributeList AL = NewInnerCB->getAttributes(); for (unsigned I = 0, E = InnerCB->arg_size(); I < E; ++I) { // Check if the underlying value for the parameter is an argument. -const Value *UnderlyingV = -getUnderlyingObject(InnerCB->getArgOperand(I)); -const Argument *Arg = dyn_cast(UnderlyingV); -if (!Arg) - continue; +const Argument *Arg = dyn_cast(InnerCB->getArgOperand(I)); +unsigned ArgNo; +if (Arg) { + ArgNo = Arg->getArgNo(); + // For dereferenceable, dereferenceable_or_null, align, etc... + // we don't want to propagate if the existing param has the same + // attribute with "better" constraints. So, only remove from the + // existing AL if the region of the existing param is smaller than + // what we can propagate. AttributeList's merge API honours the + // already existing attribute value so we choose the "better" + // attribute by removing if the existing one is worse. + if (AL.getParamDereferenceableBytes(I) < + ValidExactParamAttrs[ArgNo].getDereferenceableBytes()) +AL = +AL.removeParamAttribute(Context, I, Attribute::Dereferenceable); + if (AL.getParamDereferenceableOrNullBytes(I) < + ValidExactParamAttrs[ArgNo].getDereferenceableOrNullBytes()) +AL = +AL.removeParamAttribute(Context, I, Attribute::Dereferenceable); + if (AL.getParamAlignment(I).valueOrOne() < + ValidExactParamAttrs[ArgNo].getAlignment().valueOrOne()) +AL = AL.removeParamAttribute(Context, I, Attribute::Alignment); + + auto ExistingRange = AL.getParamRange(I); + AL = AL.addParamAttributes(Context, I, ValidExactParamAttrs[ArgNo]); + + // For range we use the intersection. + if (ExistingRange.has_value()) { +if (auto NewRange = ValidExactParamAttrs[ArgNo].getRange()) { + auto CombinedRange = ExistingRange->intersectWith(*NewRange); + AL = AL.removeParamAttribute(Context, I, Attribute::Range); + AL = AL.addRangeParamAttr(Context, I, CombinedRange); +} + } +} else { + // Check if the underlying value for the parameter is an argument. + const Value *UnderlyingV = + getUnderlyingObject(InnerCB->getArgOperand(I)); + Arg = dyn_cast(UnderlyingV); + if (!Arg) +continue; + ArgNo = Arg->getArgNo(); +} if (AL.hasParamAttr(I, Attribute::ByVal)) // It's unsound to propagate memory attributes to byval arguments. // Even if CalledFunction doesn't e.g. write to the argument, // the call to NewInnerCB may write to its by-value copy. continue; nikic wrote: Please apply this to all attributes, not just the underlying object ones. E.g. if you have a big dereferenceable and pass it to small byval, applying the big dereferenceable to the result would be incorrect. Alignment on byval also has very special semantics. Let's please not go there. At all. https://github.com/llvm/llvm-project/pull/91101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)
nikic wrote: Did you check whether this has any compile-time impact? https://github.com/llvm/llvm-project/pull/91101 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] fix the unexpected controlflow in `ParseTentative.cpp` (PR #95917)
nikic wrote: The TryParseProtocolQualifiers code path can be reached using something like this: ``` struct X { }; void foo() { X; } ``` But I don't know how to make that valid code without it taking some different code path... https://github.com/llvm/llvm-project/pull/95917 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [InstCombine] Canonicalize constant GEPs to i8 source element type (PR #68882)
nikic wrote: @karthik-man LLVM *always* requires a correct data layout. Yes, that includes InstCombine. https://github.com/llvm/llvm-project/pull/68882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Hashing] Use a non-deterministic seed if LLVM_ENABLE_ABI_BREAKING_CHECKS (PR #96282)
@@ -322,24 +306,20 @@ struct hash_state { } }; - -/// A global, fixed seed-override variable. -/// -/// This variable can be set using the \see llvm::set_fixed_execution_seed -/// function. See that function for details. Do not, under any circumstances, -/// set or read this variable. -extern uint64_t fixed_seed_override; - +/// In LLVM_ENABLE_ABI_BREAKING_CHECKS builds, the seed is non-deterministic +/// (address of a variable) to prevent having users depend on the particular +/// hash values. On platforms without ASLR, this is still likely +/// non-deterministic per build. inline uint64_t get_execution_seed() { - // FIXME: This needs to be a per-execution seed. This is just a placeholder - // implementation. Switching to a per-execution seed is likely to flush out - // instability bugs and so will happen as its own commit. - // - // However, if there is a fixed seed override set the first time this is - // called, return that instead of the per-execution seed. - const uint64_t seed_prime = 0xff51afd7ed558ccdULL; - static uint64_t seed = fixed_seed_override ? fixed_seed_override : seed_prime; - return seed; + // Work around x86-64 negative offset folding for old Clang -fno-pic + // https://reviews.llvm.org/D93931 +#if LLVM_ENABLE_ABI_BREAKING_CHECKS && \ +(!defined(__clang__) || __clang_major__ > 11) nikic wrote: Maybe it would make sense to move the function to the source file for the LLVM_ENABLE_ABI_BREAKING_CHECKS case? It will add cost, but it's okay for assertion-enabled builds. https://github.com/llvm/llvm-project/pull/96282 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 05670b4 - [InstCombine] Remove root special case in demanded bits simplification
Author: Nikita Popov Date: 2024-07-02T11:14:36+02:00 New Revision: 05670b42f5b45710bfdba48dcb7e8c30c8c7478f URL: https://github.com/llvm/llvm-project/commit/05670b42f5b45710bfdba48dcb7e8c30c8c7478f DIFF: https://github.com/llvm/llvm-project/commit/05670b42f5b45710bfdba48dcb7e8c30c8c7478f.diff LOG: [InstCombine] Remove root special case in demanded bits simplification When calling SimplifyDemandedBits (as opposed to SimplifyDemandedInstructionBits), and there are multiple uses, always use SimplifyMultipleUseDemandedBits and drop the special case for root values. This fixes the ephemeral value detection, as seen by the restored assumes in tests. It may result in more or less simplification, depending on whether we get more out of having demanded bits or the ability to perform non-multi-use transforms. The change in the phi-known-bits.ll test is because the icmp operand now gets simplified based on demanded bits, which then prevents a different known bits simplification later. This also makes the code safe against future changes like https://github.com/llvm/llvm-project/pull/97289, which add more context that would have to be discarded for the multi-use case. Added: Modified: clang/test/CodeGen/inline-asm-x86-flag-output.c llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp llvm/test/Analysis/ValueTracking/phi-known-bits.ll llvm/test/Transforms/InstCombine/assume-inseltpoison.ll llvm/test/Transforms/InstCombine/assume.ll Removed: diff --git a/clang/test/CodeGen/inline-asm-x86-flag-output.c b/clang/test/CodeGen/inline-asm-x86-flag-output.c index 7ca6dc7a39f50..243dc3716ca13 100644 --- a/clang/test/CodeGen/inline-asm-x86-flag-output.c +++ b/clang/test/CodeGen/inline-asm-x86-flag-output.c @@ -380,8 +380,10 @@ int test_assume_boolean_flag(long nr, volatile long *addr) { //CHECK: %0 = tail call { i32, i32 } asm "cmp $2,$1", "={@cca},={@ccae},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) //CHECK: [[RES1:%.*]] = extractvalue { i32, i32 } %0, 0 //CHECK: [[RES2:%.*]] = extractvalue { i32, i32 } %0, 1 - //CHECK: %1 = icmp ult i32 [[RES2]], 2 + //CHECK: %1 = icmp ult i32 [[RES1]], 2 //CHECK: tail call void @llvm.assume(i1 %1) + //CHECK: %2 = icmp ult i32 [[RES2]], 2 + //CHECK: tail call void @llvm.assume(i1 %2) int x,y; asm("cmp %2,%1" : "=@cca"(x), "=@ccae"(y), "=m"(*(volatile long *)(addr)) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index b1d03786f3218..98f085a2c756a 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -117,20 +117,11 @@ bool InstCombinerImpl::SimplifyDemandedBits(Instruction *I, unsigned OpNo, if (VInst->hasOneUse()) { // If the instruction has one use, we can directly simplify it. NewVal = SimplifyDemandedUseBits(VInst, DemandedMask, Known, Depth, Q); - } else if (Depth != 0) { -// If there are multiple uses of this instruction and we aren't at the root, -// then we can simplify VInst to some other value, but not modify the -// instruction. -NewVal = -SimplifyMultipleUseDemandedBits(VInst, DemandedMask, Known, Depth, Q); } else { -// If this is the root being simplified, allow it to have multiple uses, -// just set the DemandedMask to all bits and reset the context instruction. -// This allows visitTruncInst (for example) to simplify the operand of a -// trunc without duplicating all the SimplifyDemandedUseBits() logic. +// If there are multiple uses of this instruction, then we can simplify +// VInst to some other value, but not modify the instruction. NewVal = -SimplifyDemandedUseBits(VInst, APInt::getAllOnes(Known.getBitWidth()), -Known, Depth, Q.getWithInstruction(VInst)); +SimplifyMultipleUseDemandedBits(VInst, DemandedMask, Known, Depth, Q); } if (!NewVal) return false; if (Instruction* OpInst = dyn_cast(U)) diff --git a/llvm/test/Analysis/ValueTracking/phi-known-bits.ll b/llvm/test/Analysis/ValueTracking/phi-known-bits.ll index 7b5e143fecfd9..3728e4177dd99 100644 --- a/llvm/test/Analysis/ValueTracking/phi-known-bits.ll +++ b/llvm/test/Analysis/ValueTracking/phi-known-bits.ll @@ -375,10 +375,13 @@ F: define i8 @phi_ugt_high_bits_and_known(i8 %xx) { ; CHECK-LABEL: @phi_ugt_high_bits_and_known( ; CHECK-NEXT: entry: -; CHECK-NEXT:[[CMP:%.*]] = icmp ugt i8 [[XX:%.*]], -65 +; CHECK-NEXT:[[X:%.*]] = or i8 [[XX:%.*]], 1 +; CHECK-NEXT:[[CMP:%.*]] = icmp ugt i8 [[XX]], -65 ; CHECK-NEXT:br i1 [[CMP]], label [[T:%.*]], label [[F:%.*]] ; CHECK: T: -; CHECK-NEXT:ret i8 65 +; CHECK-NEXT:[[V:%.*]] = phi i8 [ [[X]], [[ENTRY:%.*]] ], [ -1, [[F]] ]
[clang] 86b3794 - Reapply [InstCombine] Fix context for multi-use demanded bits simplification
Author: Nikita Popov Date: 2024-07-02T11:02:55+02:00 New Revision: 86b37944a70229b07626e63bdb9a46b4bc3d1460 URL: https://github.com/llvm/llvm-project/commit/86b37944a70229b07626e63bdb9a46b4bc3d1460 DIFF: https://github.com/llvm/llvm-project/commit/86b37944a70229b07626e63bdb9a46b4bc3d1460.diff LOG: Reapply [InstCombine] Fix context for multi-use demanded bits simplification Repplied with a clang test fix. - When simplifying a multi-use root value, the demanded bits were reset to full, but we also need to reset the context instruction. To make this convenient (without requiring by-value passing of SimplifyQuery), move the logic that handles constants and dispatches to SimplifyDemandedUseBits/SimplifyMultipleUseDemandedBits into SimplifyDemandedBits. The SimplifyDemandedInstructionBits caller starts with full demanded bits and an appropriate context anyway. The different context instruction does mean that the ephemeral value protection no longer triggers in some cases, as the changes to assume tests show. An alternative, which I will explore in a followup, is to always use SimplifyMultipleUseDemandedBits() -- the previous root special case is only really intended for SimplifyDemandedInstructionBits(), which now no longer shares this code path. Fixes https://github.com/llvm/llvm-project/issues/97330. Added: Modified: clang/test/CodeGen/inline-asm-x86-flag-output.c llvm/lib/Transforms/InstCombine/InstCombineInternal.h llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp llvm/test/Transforms/InstCombine/assume-inseltpoison.ll llvm/test/Transforms/InstCombine/assume.ll llvm/test/Transforms/InstCombine/known-bits.ll Removed: diff --git a/clang/test/CodeGen/inline-asm-x86-flag-output.c b/clang/test/CodeGen/inline-asm-x86-flag-output.c index 243dc3716ca13..7ca6dc7a39f50 100644 --- a/clang/test/CodeGen/inline-asm-x86-flag-output.c +++ b/clang/test/CodeGen/inline-asm-x86-flag-output.c @@ -380,10 +380,8 @@ int test_assume_boolean_flag(long nr, volatile long *addr) { //CHECK: %0 = tail call { i32, i32 } asm "cmp $2,$1", "={@cca},={@ccae},=*m,r,~{cc},~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i64) %addr, i64 %nr) //CHECK: [[RES1:%.*]] = extractvalue { i32, i32 } %0, 0 //CHECK: [[RES2:%.*]] = extractvalue { i32, i32 } %0, 1 - //CHECK: %1 = icmp ult i32 [[RES1]], 2 + //CHECK: %1 = icmp ult i32 [[RES2]], 2 //CHECK: tail call void @llvm.assume(i1 %1) - //CHECK: %2 = icmp ult i32 [[RES2]], 2 - //CHECK: tail call void @llvm.assume(i1 %2) int x,y; asm("cmp %2,%1" : "=@cca"(x), "=@ccae"(y), "=m"(*(volatile long *)(addr)) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h index 318c455fd7ef1..64fbcc80e0edf 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h +++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h @@ -545,10 +545,11 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final ConstantInt *, ConstantInt *, ConstantInt *); - /// Attempts to replace V with a simpler value based on the demanded + /// Attempts to replace I with a simpler value based on the demanded /// bits. - Value *SimplifyDemandedUseBits(Value *V, APInt DemandedMask, KnownBits , - unsigned Depth, const SimplifyQuery ); + Value *SimplifyDemandedUseBits(Instruction *I, const APInt , + KnownBits , unsigned Depth, + const SimplifyQuery ); using InstCombiner::SimplifyDemandedBits; bool SimplifyDemandedBits(Instruction *I, unsigned Op, const APInt , KnownBits , diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index 6cf2e71363ab5..b1d03786f3218 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -91,8 +91,47 @@ bool InstCombinerImpl::SimplifyDemandedBits(Instruction *I, unsigned OpNo, KnownBits , unsigned Depth, const SimplifyQuery ) { Use = I->getOperandUse(OpNo); - Value *NewVal = SimplifyDemandedUseBits(U.get(), DemandedMask, Known, - Depth, Q); + Value *V = U.get(); + if (isa(V)) { +llvm::computeKnownBits(V, Known, Depth, Q); +return false; + } + + Known.resetAll(); + if (DemandedMask.isZero()) { +// Not demanding any bits from V. +replaceUse(U, UndefValue::get(V->getType())); +return true; + } + + if (Depth == MaxAnalysisRecursionDepth) +return false; + + Instruction *VInst = dyn_cast(V); + if (!VInst) { +
[clang] 5cc1287 - [CGBuilder] Use getDataLayout() helpers (NFC)
Author: Nikita Popov Date: 2024-06-29T11:50:28+02:00 New Revision: 5cc1287bdbb2de9ad91e4ba8dc9eeb9508c734a5 URL: https://github.com/llvm/llvm-project/commit/5cc1287bdbb2de9ad91e4ba8dc9eeb9508c734a5 DIFF: https://github.com/llvm/llvm-project/commit/5cc1287bdbb2de9ad91e4ba8dc9eeb9508c734a5.diff LOG: [CGBuilder] Use getDataLayout() helpers (NFC) Added: Modified: clang/lib/CodeGen/CGBuilder.h Removed: diff --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h index ed07476f4047f..0bc4fda62979c 100644 --- a/clang/lib/CodeGen/CGBuilder.h +++ b/clang/lib/CodeGen/CGBuilder.h @@ -62,7 +62,7 @@ class CGBuilderTy : public CGBuilderBaseTy { template Address createConstGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1, const llvm::Twine ) { -const llvm::DataLayout = BB->getParent()->getParent()->getDataLayout(); +const llvm::DataLayout = BB->getDataLayout(); llvm::GetElementPtrInst *GEP; if (IsInBounds) GEP = cast(CreateConstInBoundsGEP2_32( @@ -218,7 +218,7 @@ class CGBuilderTy : public CGBuilderBaseTy { Address CreateStructGEP(Address Addr, unsigned Index, const llvm::Twine = "") { llvm::StructType *ElTy = cast(Addr.getElementType()); -const llvm::DataLayout = BB->getParent()->getParent()->getDataLayout(); +const llvm::DataLayout = BB->getDataLayout(); const llvm::StructLayout *Layout = DL.getStructLayout(ElTy); auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index)); @@ -240,7 +240,7 @@ class CGBuilderTy : public CGBuilderBaseTy { Address CreateConstArrayGEP(Address Addr, uint64_t Index, const llvm::Twine = "") { llvm::ArrayType *ElTy = cast(Addr.getElementType()); -const llvm::DataLayout = BB->getParent()->getParent()->getDataLayout(); +const llvm::DataLayout = BB->getDataLayout(); CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy->getElementType())); @@ -260,7 +260,7 @@ class CGBuilderTy : public CGBuilderBaseTy { Address CreateConstInBoundsGEP(Address Addr, uint64_t Index, const llvm::Twine = "") { llvm::Type *ElTy = Addr.getElementType(); -const llvm::DataLayout = BB->getParent()->getParent()->getDataLayout(); +const llvm::DataLayout = BB->getDataLayout(); CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy)); return Address( @@ -277,7 +277,7 @@ class CGBuilderTy : public CGBuilderBaseTy { Address CreateConstGEP(Address Addr, uint64_t Index, const llvm::Twine = "") { llvm::Type *ElTy = Addr.getElementType(); -const llvm::DataLayout = BB->getParent()->getParent()->getDataLayout(); +const llvm::DataLayout = BB->getDataLayout(); CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy)); return Address(CreateGEP(ElTy, Addr.getBasePointer(), getSize(Index), Name), @@ -290,7 +290,7 @@ class CGBuilderTy : public CGBuilderBaseTy { using CGBuilderBaseTy::CreateGEP; Address CreateGEP(CodeGenFunction , Address Addr, llvm::Value *Index, const llvm::Twine = "") { -const llvm::DataLayout = BB->getParent()->getParent()->getDataLayout(); +const llvm::DataLayout = BB->getDataLayout(); CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(Addr.getElementType())); @@ -412,7 +412,7 @@ class CGBuilderTy : public CGBuilderBaseTy { unsigned FieldIndex, llvm::MDNode *DbgInfo) { llvm::StructType *ElTy = cast(Addr.getElementType()); -const llvm::DataLayout = BB->getParent()->getParent()->getDataLayout(); +const llvm::DataLayout = BB->getDataLayout(); const llvm::StructLayout *Layout = DL.getStructLayout(ElTy); auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [polly] Revert "[IR] Don't include Module.h in Analysis.h (NFC) (#97023)" (PR #97129)
https://github.com/nikic requested changes to this pull request. This is probably caused by some downstream patches in google3? https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp does not contain any mentions of `M->getFunction` or `M->getContext`. You need to add the missing include to your downstream patches. https://github.com/llvm/llvm-project/pull/97129 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [polly] [IR] Don't include Module.h in Analysis.h (NFC) (PR #97023)
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/97023 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [polly] [IR] Don't include Module.h in Analysis.h (NFC) (PR #97023)
https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/97023 >From f21bee2d46446e9238992fde4e190ce8010ede7a Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 27 Jun 2024 17:05:54 +0200 Subject: [PATCH 1/2] [IR] Don't include Module.h in Analysis.h (NFC) Replace it with a forward declaration instead. Analysis.h is pulled in by all passes, but not all passes need to access the module. --- clang/lib/Interpreter/DeviceOffload.cpp| 1 + llvm/include/llvm/Analysis/TargetTransformInfo.h | 1 + llvm/include/llvm/Analysis/VectorUtils.h | 1 + llvm/include/llvm/IR/Analysis.h| 4 +++- llvm/include/llvm/Transforms/IPO/Attributor.h | 1 + llvm/include/llvm/Transforms/Utils/Debugify.h | 3 ++- llvm/lib/Analysis/CallPrinter.cpp | 1 + llvm/lib/Analysis/InlineAdvisor.cpp| 1 + llvm/lib/Analysis/LazyValueInfo.cpp| 1 + llvm/lib/Analysis/LoopInfo.cpp | 1 + llvm/lib/Analysis/LoopPass.cpp | 1 + llvm/lib/Analysis/MLInlineAdvisor.cpp | 1 + llvm/lib/Analysis/StructuralHash.cpp | 1 + llvm/lib/Analysis/TargetLibraryInfo.cpp| 1 + llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp | 1 + llvm/lib/CodeGen/AsmPrinter/AIXException.cpp | 1 + llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp | 1 + llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp | 1 + llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp| 1 + llvm/lib/CodeGen/CFGuardLongjmp.cpp| 1 + llvm/lib/CodeGen/EHContGuardCatchret.cpp | 1 + llvm/lib/CodeGen/GCMetadata.cpp| 1 + llvm/lib/CodeGen/KCFI.cpp | 1 + llvm/lib/CodeGen/MachineCheckDebugify.cpp | 1 + llvm/lib/CodeGen/MachineFunctionPass.cpp | 1 + llvm/lib/CodeGen/MachineModuleSlotTracker.cpp | 1 + llvm/lib/CodeGen/RegAllocBase.cpp | 1 + llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp | 1 + llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 1 + llvm/lib/CodeGen/WinEHPrepare.cpp | 1 + llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp | 1 + llvm/lib/IR/PassManager.cpp| 1 + llvm/lib/LTO/UpdateCompilerUsed.cpp| 3 ++- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 1 + llvm/lib/Target/AArch64/AArch64FastISel.cpp| 1 + llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 1 + llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp| 1 + llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.h | 1 + llvm/lib/Target/AMDGPU/AMDGPUMachineModuleInfo.cpp | 1 + llvm/lib/Target/AMDGPU/R600OpenCLImageTypeLoweringPass.cpp | 1 + llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp | 1 + llvm/lib/Target/ARM/ARMInstrInfo.cpp | 1 + llvm/lib/Target/ARM/ARMMachineFunctionInfo.cpp | 1 + llvm/lib/Target/ARM/Thumb1InstrInfo.cpp| 1 + llvm/lib/Target/ARM/Thumb2InstrInfo.cpp| 1 + llvm/lib/Target/AVR/AVRAsmPrinter.cpp | 1 + llvm/lib/Target/BPF/BPFAsmPrinter.cpp | 1 + llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp | 1 + llvm/lib/Target/BPF/BTFDebug.cpp | 1 + llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp | 1 + llvm/lib/Target/Mips/MipsAsmPrinter.cpp| 1 + llvm/lib/Target/Mips/MipsISelLowering.cpp | 1 + llvm/lib/Target/PowerPC/PPCMCInstLower.cpp | 1 + llvm/lib/Target/PowerPC/PPCSubtarget.cpp | 2 ++ llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp | 1 + llvm/lib/Target/RISCV/RISCVInstrInfo.cpp | 1 + llvm/lib/Target/RISCV/RISCVTargetObjectFile.cpp| 1 + llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp | 1 + llvm/lib/Target/SystemZ/SystemZISelLowering.cpp| 1 + llvm/lib/Target/Target.cpp | 1 + llvm/lib/Target/TargetMachine.cpp | 1 + llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp | 1 + llvm/lib/Target/WebAssembly/WebAssemblyMCLowerPrePass.cpp | 1 + llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp | 1 + llvm/lib/Target/X86/X86FrameLowering.cpp | 1 + llvm/lib/Target/X86/X86ISelDAGToDAG.cpp| 1 + llvm/lib/Target/X86/X86IndirectBranchTracking.cpp | 1 + llvm/lib/Target/X86/X86InsertPrefetch.cpp | 1 + llvm/lib/Target/X86/X86InstrInfo.cpp | 1 +
[clang] [llvm] [polly] [IR] Don't include Module.h in Analysis.h (NFC) (PR #97023)
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/97023 Replace it with a forward declaration instead. Analysis.h is pulled in by all passes, but not all passes need to access the module. >From f21bee2d46446e9238992fde4e190ce8010ede7a Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 27 Jun 2024 17:05:54 +0200 Subject: [PATCH] [IR] Don't include Module.h in Analysis.h (NFC) Replace it with a forward declaration instead. Analysis.h is pulled in by all passes, but not all passes need to access the module. --- clang/lib/Interpreter/DeviceOffload.cpp| 1 + llvm/include/llvm/Analysis/TargetTransformInfo.h | 1 + llvm/include/llvm/Analysis/VectorUtils.h | 1 + llvm/include/llvm/IR/Analysis.h| 4 +++- llvm/include/llvm/Transforms/IPO/Attributor.h | 1 + llvm/include/llvm/Transforms/Utils/Debugify.h | 3 ++- llvm/lib/Analysis/CallPrinter.cpp | 1 + llvm/lib/Analysis/InlineAdvisor.cpp| 1 + llvm/lib/Analysis/LazyValueInfo.cpp| 1 + llvm/lib/Analysis/LoopInfo.cpp | 1 + llvm/lib/Analysis/LoopPass.cpp | 1 + llvm/lib/Analysis/MLInlineAdvisor.cpp | 1 + llvm/lib/Analysis/StructuralHash.cpp | 1 + llvm/lib/Analysis/TargetLibraryInfo.cpp| 1 + llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp | 1 + llvm/lib/CodeGen/AsmPrinter/AIXException.cpp | 1 + llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp | 1 + llvm/lib/CodeGen/AsmPrinter/WinCFGuard.cpp | 1 + llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp| 1 + llvm/lib/CodeGen/CFGuardLongjmp.cpp| 1 + llvm/lib/CodeGen/EHContGuardCatchret.cpp | 1 + llvm/lib/CodeGen/GCMetadata.cpp| 1 + llvm/lib/CodeGen/KCFI.cpp | 1 + llvm/lib/CodeGen/MachineCheckDebugify.cpp | 1 + llvm/lib/CodeGen/MachineFunctionPass.cpp | 1 + llvm/lib/CodeGen/MachineModuleSlotTracker.cpp | 1 + llvm/lib/CodeGen/RegAllocBase.cpp | 1 + llvm/lib/CodeGen/RegAllocEvictionAdvisor.cpp | 1 + llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 1 + llvm/lib/CodeGen/WinEHPrepare.cpp | 1 + llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp | 1 + llvm/lib/IR/PassManager.cpp| 1 + llvm/lib/LTO/UpdateCompilerUsed.cpp| 3 ++- llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp | 1 + llvm/lib/Target/AArch64/AArch64FastISel.cpp| 1 + llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 1 + llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp| 1 + llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.h | 1 + llvm/lib/Target/AMDGPU/AMDGPUMachineModuleInfo.cpp | 1 + llvm/lib/Target/AMDGPU/R600OpenCLImageTypeLoweringPass.cpp | 1 + llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp | 1 + llvm/lib/Target/ARM/ARMInstrInfo.cpp | 1 + llvm/lib/Target/ARM/ARMMachineFunctionInfo.cpp | 1 + llvm/lib/Target/ARM/Thumb1InstrInfo.cpp| 1 + llvm/lib/Target/ARM/Thumb2InstrInfo.cpp| 1 + llvm/lib/Target/AVR/AVRAsmPrinter.cpp | 1 + llvm/lib/Target/BPF/BPFAsmPrinter.cpp | 1 + llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp | 1 + llvm/lib/Target/BPF/BTFDebug.cpp | 1 + llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp | 1 + llvm/lib/Target/Mips/MipsAsmPrinter.cpp| 1 + llvm/lib/Target/Mips/MipsISelLowering.cpp | 1 + llvm/lib/Target/PowerPC/PPCMCInstLower.cpp | 1 + llvm/lib/Target/PowerPC/PPCSubtarget.cpp | 2 ++ llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp | 1 + llvm/lib/Target/RISCV/RISCVInstrInfo.cpp | 1 + llvm/lib/Target/RISCV/RISCVTargetObjectFile.cpp| 1 + llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp | 1 + llvm/lib/Target/SystemZ/SystemZISelLowering.cpp| 1 + llvm/lib/Target/Target.cpp | 1 + llvm/lib/Target/TargetMachine.cpp | 1 + llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp | 1 + llvm/lib/Target/WebAssembly/WebAssemblyMCLowerPrePass.cpp | 1 + llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp | 1 + llvm/lib/Target/X86/X86FrameLowering.cpp | 1 + llvm/lib/Target/X86/X86ISelDAGToDAG.cpp| 1 + llvm/lib/Target/X86/X86IndirectBranchTracking.cpp | 1 +
[clang] [llvm] [Pipelines] Move IPSCCP after inliner pipeline (PR #96620)
nikic wrote: Yes, this causes a massive compile-time regression: http://llvm-compile-time-tracker.com/compare.php?from=253a294b54a6096a0b66f840931dd0e345d70c4f=20869e8ed55c58696ce4e9dc3d18cd6af01ed49c=instructions:u https://github.com/llvm/llvm-project/pull/96620 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)
nikic wrote: > > Looks like using InsertPosition in IRBuilder has some overhead: > > Hm, we're adding an extra pointer chase when we give up passing a basicblock > - I think then it makes sense to keep the option to pass BB+It, and do so > when the caller already knows the BB (while removing the need to pass the BB > around for functions that only have an instruction). My guess here would have been that the issue is the cases where an Instruction* or BasicBlock* is passed rather than BB+Iterator, because those two cases go through an out-of-line constructor. https://github.com/llvm/llvm-project/pull/96497 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Update Clang extension criteria (PR #96532)
https://github.com/nikic approved this pull request. https://github.com/llvm/llvm-project/pull/96532 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)
nikic wrote: Looks like using InsertPosition in IRBuilder has some overhead: https://llvm-compile-time-tracker.com/compare.php?from=317277e4f961edf13132914a58a26408db4ab0aa=6481dc57612671ebe77fe9c34214fba94e1b3b27=instructions:u So it might make sense to keep some explicit overloads for IRBuilder (not sure which ones are hot though). https://github.com/llvm/llvm-project/pull/96497 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)
@@ -637,8 +637,7 @@ void ARMParallelDSP::InsertParallelMACs(Reduction ) { Intrinsic::getDeclaration(M, Intrinsic::arm_smlad) : Intrinsic::getDeclaration(M, Intrinsic::arm_smlald); -IRBuilder Builder(InsertAfter->getParent(), -BasicBlock::iterator(InsertAfter)); +IRBuilder Builder((BasicBlock::iterator(InsertAfter))); nikic wrote: ```suggestion IRBuilder Builder(BasicBlock::iterator(InsertAfter)); ``` https://github.com/llvm/llvm-project/pull/96497 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)
https://github.com/nikic approved this pull request. LGTM if CI is happy. https://github.com/llvm/llvm-project/pull/96497 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)
@@ -3136,7 +3136,7 @@ static void LLVMPositionBuilderImpl(IRBuilder<> *Builder, BasicBlock *Block, Instruction *Instr, bool BeforeDbgRecords) { BasicBlock::iterator I = Instr ? Instr->getIterator() : Block->end(); I.setHeadBit(BeforeDbgRecords); - Builder->SetInsertPoint(Block, I); + Builder->SetInsertPoint(I); nikic wrote: Maybe assert that BB and Instr are consistent here? https://github.com/llvm/llvm-project/pull/96497 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)
@@ -44,15 +44,19 @@ template <> struct ilist_alloc_traits { iterator_range::iterator> getDbgRecordRange(DbgMarker *); +/// Class used to generate an insert position (ultimately always a +/// BasicBlock::iterator, which it will implicitly convert to) from either: +/// - An Instruction, inserting immediately prior. nikic wrote: Indicate that this is deprecated? https://github.com/llvm/llvm-project/pull/96497 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [mlir] [polly] [IR][NFC] Update IRBuilder to use InsertPosition (PR #96497)
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/96497 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 30299b8 - [CommandLine] Avoid ManagedStatic.h include (NFC)
Author: Nikita Popov Date: 2024-06-21T15:45:17+02:00 New Revision: 30299b87171cbad2dacb8b1ec0e75801785f16d9 URL: https://github.com/llvm/llvm-project/commit/30299b87171cbad2dacb8b1ec0e75801785f16d9 DIFF: https://github.com/llvm/llvm-project/commit/30299b87171cbad2dacb8b1ec0e75801785f16d9.diff LOG: [CommandLine] Avoid ManagedStatic.h include (NFC) The two variables using ManagedStatic that are exported by this header are not actually used anywhere -- they are used through SubCommand::getTopLevel() and SubCommand::getAll() instead. Drop the extern declarations and the include. Added: Modified: clang/lib/Frontend/PrecompiledPreamble.cpp lldb/utils/TableGen/LLDBTableGen.cpp llvm/include/llvm/Support/CommandLine.h llvm/lib/Support/CommandLine.cpp llvm/lib/Support/RandomNumberGenerator.cpp llvm/lib/Support/TypeSize.cpp Removed: diff --git a/clang/lib/Frontend/PrecompiledPreamble.cpp b/clang/lib/Frontend/PrecompiledPreamble.cpp index fdf05c3613c95..cab5838fceb24 100644 --- a/clang/lib/Frontend/PrecompiledPreamble.cpp +++ b/clang/lib/Frontend/PrecompiledPreamble.cpp @@ -28,6 +28,7 @@ #include "llvm/Config/llvm-config.h" #include "llvm/Support/CrashRecoveryContext.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" #include "llvm/Support/VirtualFileSystem.h" diff --git a/lldb/utils/TableGen/LLDBTableGen.cpp b/lldb/utils/TableGen/LLDBTableGen.cpp index c63ca76c0d48f..bbd3f3d6c66c4 100644 --- a/lldb/utils/TableGen/LLDBTableGen.cpp +++ b/lldb/utils/TableGen/LLDBTableGen.cpp @@ -12,6 +12,7 @@ #include "LLDBTableGenBackends.h" // Declares all backends. #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" #include "llvm/TableGen/Error.h" diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h index b035209406b68..5d60bb64bbb20 100644 --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/include/llvm/Support/CommandLine.h @@ -28,7 +28,6 @@ #include "llvm/ADT/Twine.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/StringSaver.h" #include "llvm/Support/raw_ostream.h" #include @@ -237,12 +236,6 @@ class SubCommand { Option *ConsumeAfterOpt = nullptr; // The ConsumeAfter option if it exists. }; -// A special subcommand representing no subcommand -extern ManagedStatic TopLevelSubCommand; - -// A special subcommand that can be used to put an option into all subcommands. -extern ManagedStatic AllSubCommands; - class SubCommandGroup { SmallVector Subs; diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 8a00d4798f33d..6dc0c86cea894 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -455,10 +455,10 @@ void OptionCategory::registerCategory() { // initialization because it is referenced from cl::opt constructors, which run // dynamically in an arbitrary order. LLVM_REQUIRE_CONSTANT_INITIALIZATION -ManagedStatic llvm::cl::TopLevelSubCommand; +static ManagedStatic TopLevelSubCommand; // A special subcommand that can be used to put an option into all subcommands. -ManagedStatic llvm::cl::AllSubCommands; +static ManagedStatic AllSubCommands; SubCommand ::getTopLevel() { return *TopLevelSubCommand; } diff --git a/llvm/lib/Support/RandomNumberGenerator.cpp b/llvm/lib/Support/RandomNumberGenerator.cpp index 12fe109dbc2b5..2959fc2bfed17 100644 --- a/llvm/lib/Support/RandomNumberGenerator.cpp +++ b/llvm/lib/Support/RandomNumberGenerator.cpp @@ -19,6 +19,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Error.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/raw_ostream.h" #ifdef _WIN32 #include "llvm/Support/Windows/WindowsSupport.h" diff --git a/llvm/lib/Support/TypeSize.cpp b/llvm/lib/Support/TypeSize.cpp index 8bed9b29cba55..43346b81cd676 100644 --- a/llvm/lib/Support/TypeSize.cpp +++ b/llvm/lib/Support/TypeSize.cpp @@ -8,6 +8,7 @@ #include "llvm/Support/TypeSize.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/WithColor.h" #include "DebugOptions.h" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 48ef912 - [VFS] Avoid include (NFC)
Author: Nikita Popov Date: 2024-06-21T15:17:41+02:00 New Revision: 48ef912e2b32798b704af242e551a7090102c750 URL: https://github.com/llvm/llvm-project/commit/48ef912e2b32798b704af242e551a7090102c750 DIFF: https://github.com/llvm/llvm-project/commit/48ef912e2b32798b704af242e551a7090102c750.diff LOG: [VFS] Avoid include (NFC) Directly use a vector instead of wrapping it in a stack, like we do in most places. Added: Modified: clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp clang-tools-extra/clangd/GlobalCompilationDatabase.cpp clang-tools-extra/clangd/Selection.h clang/lib/Sema/SemaAPINotes.cpp clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp clang/unittests/Support/TimeProfilerTest.cpp lldb/include/lldb/Target/StackFrameRecognizer.h llvm/include/llvm/Support/VirtualFileSystem.h llvm/lib/ProfileData/Coverage/CoverageMapping.cpp llvm/lib/Support/VirtualFileSystem.cpp llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp b/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp index fafb029e7de1b..04ca006143503 100644 --- a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp @@ -9,6 +9,7 @@ #include "RedundantStrcatCallsCheck.h" #include "clang/AST/ASTContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" +#include using namespace clang::ast_matchers; diff --git a/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp index a64c9b2905ca1..01276af6c7d8f 100644 --- a/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/MacroRepeatedSideEffectsCheck.cpp @@ -12,6 +12,7 @@ #include "clang/Lex/MacroArgs.h" #include "clang/Lex/PPCallbacks.h" #include "clang/Lex/Preprocessor.h" +#include namespace clang::tidy::bugprone { diff --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp index 5bec7966a9c3a..85c80eb482efb 100644 --- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp +++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include diff --git a/clang-tools-extra/clangd/Selection.h b/clang-tools-extra/clangd/Selection.h index f80ee83c4b94c..cb40c6d403487 100644 --- a/clang-tools-extra/clangd/Selection.h +++ b/clang-tools-extra/clangd/Selection.h @@ -45,6 +45,7 @@ #include "clang/AST/PrettyPrinter.h" #include "clang/Tooling/Syntax/Tokens.h" #include "llvm/ADT/SmallVector.h" +#include namespace clang { namespace clangd { diff --git a/clang/lib/Sema/SemaAPINotes.cpp b/clang/lib/Sema/SemaAPINotes.cpp index bc1628f5b7163..d535cb35cfbc8 100644 --- a/clang/lib/Sema/SemaAPINotes.cpp +++ b/clang/lib/Sema/SemaAPINotes.cpp @@ -18,6 +18,7 @@ #include "clang/Sema/SemaInternal.h" #include "clang/Sema/SemaObjC.h" #include "clang/Sema/SemaSwift.h" +#include using namespace clang; diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index 487a3bd16b674..4ff4f7de425ca 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -59,6 +59,7 @@ #include #include #include +#include #include #include diff --git a/clang/unittests/Support/TimeProfilerTest.cpp b/clang/unittests/Support/TimeProfilerTest.cpp index 97fdbb7232b13..5f3950ff033f1 100644 --- a/clang/unittests/Support/TimeProfilerTest.cpp +++ b/clang/unittests/Support/TimeProfilerTest.cpp @@ -12,6 +12,7 @@ #include "llvm/Support/JSON.h" #include "llvm/Support/TimeProfiler.h" +#include #include "gtest/gtest.h" diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h b/lldb/include/lldb/Target/StackFrameRecognizer.h index 5e8e12b2a4e96..e9ac2750192ef 100644 --- a/lldb/include/lldb/Target/StackFrameRecognizer.h +++ b/lldb/include/lldb/Target/StackFrameRecognizer.h @@ -17,6 +17,7 @@ #include "lldb/lldb-private-forward.h" #include "lldb/lldb-public.h" +#include #include #include diff --git a/llvm/include/llvm/Support/VirtualFileSystem.h b/llvm/include/llvm/Support/VirtualFileSystem.h index a1e38de74dfcc..f7cfcd4058e72 100644 --- a/llvm/include/llvm/Support/VirtualFileSystem.h +++ b/llvm/include/llvm/Support/VirtualFileSystem.h @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -219,7 +218,7 @@ namespace detail { /// Keeps state for the
[clang] [llvm] Intrinsic: introduce minimumnum and maximumnum (PR #93841)
nikic wrote: It looks like this PR was merged without being approved, and I also couldn't find the corresponding RFC for this addition on discourse. I've reverted it for now. https://github.com/llvm/llvm-project/pull/93841 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [PassManager] Remove some unnecessary includes (NFC) (PR #96175)
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/96175 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lld] [llvm] [PassManager] Remove some unnecessary includes (NFC) (PR #96175)
https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/96175 >From 8a5e15bffd2bbb1fbb35968f38a0ad2ba067 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 20 Jun 2024 13:25:28 +0200 Subject: [PATCH 1/2] [PassManger] Remove some unnecessary includes (NFC) SmallPtrSet.h and TimeProfiler.h are unused. CommandLine.h is only needed for the UseNewDbgInfoFormat declare, which can be moved to the places that need it. --- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp | 1 + llvm/include/llvm/IR/PassManager.h | 5 - llvm/include/llvm/IR/PassManagerImpl.h | 3 +++ llvm/lib/Analysis/PHITransAddr.cpp | 1 + llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 1 + llvm/lib/LTO/LTO.cpp| 2 ++ llvm/lib/Transforms/Coroutines/CoroFrame.cpp| 2 ++ llvm/lib/Transforms/IPO/ConstantMerge.cpp | 1 + llvm/tools/llvm-as/llvm-as.cpp | 1 + llvm/tools/opt/optdriver.cpp| 1 + 10 files changed, 13 insertions(+), 5 deletions(-) diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 623e888a3bf86..cdfe8cfbd9379 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -50,6 +50,7 @@ #include "llvm/Support/SourceMgr.h" #include "llvm/Support/StringSaver.h" #include "llvm/Support/TargetSelect.h" +#include "llvm/Support/TimeProfiler.h" #include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h index cdeed83bbf702..5661a1d58c8ec 100644 --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -39,7 +39,6 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/TinyPtrVector.h" #include "llvm/IR/Analysis.h" @@ -47,8 +46,6 @@ #include "llvm/IR/Module.h" #include "llvm/IR/PassInstrumentation.h" #include "llvm/IR/PassManagerInternal.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/TimeProfiler.h" #include "llvm/Support/TypeName.h" #include #include @@ -60,8 +57,6 @@ #include #include -extern llvm::cl::opt UseNewDbgInfoFormat; - namespace llvm { // Forward declare the analysis manager template. diff --git a/llvm/include/llvm/IR/PassManagerImpl.h b/llvm/include/llvm/IR/PassManagerImpl.h index dc85ebc3644b9..e4a85b0f33b26 100644 --- a/llvm/include/llvm/IR/PassManagerImpl.h +++ b/llvm/include/llvm/IR/PassManagerImpl.h @@ -15,8 +15,11 @@ #ifndef LLVM_IR_PASSMANAGERIMPL_H #define LLVM_IR_PASSMANAGERIMPL_H +#include "llvm/Support/CommandLine.h" #include "llvm/IR/PassManager.h" +extern llvm::cl::opt UseNewDbgInfoFormat; + namespace llvm { template diff --git a/llvm/lib/Analysis/PHITransAddr.cpp b/llvm/lib/Analysis/PHITransAddr.cpp index 1a02497f25c33..5ec1964c4cb60 100644 --- a/llvm/lib/Analysis/PHITransAddr.cpp +++ b/llvm/lib/Analysis/PHITransAddr.cpp @@ -17,6 +17,7 @@ #include "llvm/IR/Constants.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Instructions.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index af5d6891805a6..06d99366a8c3e 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -109,6 +109,7 @@ cl::opt LoadBitcodeIntoNewDbgInfoFormat( "load-bitcode-into-experimental-debuginfo-iterators", cl::Hidden, cl::desc("Load bitcode directly into the new debug info format (regardless " "of input format)")); +extern cl::opt UseNewDbgInfoFormat; extern cl::opt PreserveInputDbgFormat; extern bool WriteNewDbgInfoFormatToBitcode; extern cl::opt WriteNewDbgInfoFormat; diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 5c603ac6ab472..2ba7f587c3f2b 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -65,6 +65,8 @@ using namespace object; #define DEBUG_TYPE "lto" +extern cl::opt UseNewDbgInfoFormat; + static cl::opt DumpThinCGSCCs("dump-thin-cg-sccs", cl::init(false), cl::Hidden, cl::desc("Dump the SCCs in the ThinLTO index's callgraph")); diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp index 8e829a53aeca2..30ef7689801dd 100644 --- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp @@ -44,6 +44,8 @@ using namespace llvm; +extern cl::opt UseNewDbgInfoFormat; + // The "coro-suspend-crossing" flag is very noisy. There is
[clang] [llvm] [PassManager] Remove some unnecessary includes (NFC) (PR #96175)
https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/96175 >From 4da2e8622b296b644755c924f317d0be95ce4d42 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 20 Jun 2024 13:25:28 +0200 Subject: [PATCH] [PassManger] Remove some unnecessary includes (NFC) SmallPtrSet.h and TimeProfiler.h are unused. CommandLine.h is only needed for the UseNewDbgInfoFormat declare, which can be moved to the places that need it. --- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp | 1 + llvm/include/llvm/IR/PassManager.h | 5 - llvm/include/llvm/IR/PassManagerImpl.h | 3 +++ llvm/lib/Analysis/PHITransAddr.cpp | 1 + llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 1 + llvm/lib/LTO/LTO.cpp| 2 ++ llvm/lib/Transforms/Coroutines/CoroFrame.cpp| 2 ++ llvm/lib/Transforms/IPO/ConstantMerge.cpp | 1 + llvm/tools/llvm-as/llvm-as.cpp | 1 + llvm/tools/opt/optdriver.cpp| 1 + 10 files changed, 13 insertions(+), 5 deletions(-) diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 623e888a3bf86..cdfe8cfbd9379 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -50,6 +50,7 @@ #include "llvm/Support/SourceMgr.h" #include "llvm/Support/StringSaver.h" #include "llvm/Support/TargetSelect.h" +#include "llvm/Support/TimeProfiler.h" #include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h index cdeed83bbf702..5661a1d58c8ec 100644 --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -39,7 +39,6 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/TinyPtrVector.h" #include "llvm/IR/Analysis.h" @@ -47,8 +46,6 @@ #include "llvm/IR/Module.h" #include "llvm/IR/PassInstrumentation.h" #include "llvm/IR/PassManagerInternal.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/TimeProfiler.h" #include "llvm/Support/TypeName.h" #include #include @@ -60,8 +57,6 @@ #include #include -extern llvm::cl::opt UseNewDbgInfoFormat; - namespace llvm { // Forward declare the analysis manager template. diff --git a/llvm/include/llvm/IR/PassManagerImpl.h b/llvm/include/llvm/IR/PassManagerImpl.h index dc85ebc3644b9..e4a85b0f33b26 100644 --- a/llvm/include/llvm/IR/PassManagerImpl.h +++ b/llvm/include/llvm/IR/PassManagerImpl.h @@ -15,8 +15,11 @@ #ifndef LLVM_IR_PASSMANAGERIMPL_H #define LLVM_IR_PASSMANAGERIMPL_H +#include "llvm/Support/CommandLine.h" #include "llvm/IR/PassManager.h" +extern llvm::cl::opt UseNewDbgInfoFormat; + namespace llvm { template diff --git a/llvm/lib/Analysis/PHITransAddr.cpp b/llvm/lib/Analysis/PHITransAddr.cpp index 1a02497f25c33..5ec1964c4cb60 100644 --- a/llvm/lib/Analysis/PHITransAddr.cpp +++ b/llvm/lib/Analysis/PHITransAddr.cpp @@ -17,6 +17,7 @@ #include "llvm/IR/Constants.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Instructions.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index af5d6891805a6..06d99366a8c3e 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -109,6 +109,7 @@ cl::opt LoadBitcodeIntoNewDbgInfoFormat( "load-bitcode-into-experimental-debuginfo-iterators", cl::Hidden, cl::desc("Load bitcode directly into the new debug info format (regardless " "of input format)")); +extern cl::opt UseNewDbgInfoFormat; extern cl::opt PreserveInputDbgFormat; extern bool WriteNewDbgInfoFormatToBitcode; extern cl::opt WriteNewDbgInfoFormat; diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 5c603ac6ab472..2ba7f587c3f2b 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -65,6 +65,8 @@ using namespace object; #define DEBUG_TYPE "lto" +extern cl::opt UseNewDbgInfoFormat; + static cl::opt DumpThinCGSCCs("dump-thin-cg-sccs", cl::init(false), cl::Hidden, cl::desc("Dump the SCCs in the ThinLTO index's callgraph")); diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp index 8e829a53aeca2..30ef7689801dd 100644 --- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp @@ -44,6 +44,8 @@ using namespace llvm; +extern cl::opt UseNewDbgInfoFormat; + // The "coro-suspend-crossing" flag is very noisy. There is another
[clang] [llvm] [PassManager] Remove some unnecessary includes (NFC) (PR #96175)
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/96175 SmallPtrSet.h and TimeProfiler.h are unused. CommandLine.h is only needed for the UseNewDbgInfoFormat declare, which can be moved to the places that need it. >From 09446aad3123c3051267fd3311ffc9ad2fb99486 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 20 Jun 2024 13:25:28 +0200 Subject: [PATCH] [PassManger] Remove some unnecessary includes (NFC) SmallPtrSet.h and TimeProfiler.h are unused. CommandLine.h is only needed for the UseNewDbgInfoFormat declare, which can be moved to the places that need it. --- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp | 1 + llvm/include/llvm/IR/PassManager.h | 5 - llvm/include/llvm/IR/PassManagerImpl.h | 3 +++ llvm/lib/Analysis/PHITransAddr.cpp | 1 + llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 1 + llvm/lib/LTO/LTO.cpp| 2 ++ llvm/lib/Transforms/Coroutines/CoroFrame.cpp| 2 ++ llvm/lib/Transforms/IPO/ConstantMerge.cpp | 1 + llvm/tools/llvm-as/llvm-as.cpp | 1 + llvm/tools/opt/optdriver.cpp| 1 + 10 files changed, 13 insertions(+), 5 deletions(-) diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 623e888a3bf86..cdfe8cfbd9379 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -50,6 +50,7 @@ #include "llvm/Support/SourceMgr.h" #include "llvm/Support/StringSaver.h" #include "llvm/Support/TargetSelect.h" +#include "llvm/Support/TimeProfiler.h" #include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetMachine.h" diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h index cdeed83bbf702..5661a1d58c8ec 100644 --- a/llvm/include/llvm/IR/PassManager.h +++ b/llvm/include/llvm/IR/PassManager.h @@ -39,7 +39,6 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/TinyPtrVector.h" #include "llvm/IR/Analysis.h" @@ -47,8 +46,6 @@ #include "llvm/IR/Module.h" #include "llvm/IR/PassInstrumentation.h" #include "llvm/IR/PassManagerInternal.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/TimeProfiler.h" #include "llvm/Support/TypeName.h" #include #include @@ -60,8 +57,6 @@ #include #include -extern llvm::cl::opt UseNewDbgInfoFormat; - namespace llvm { // Forward declare the analysis manager template. diff --git a/llvm/include/llvm/IR/PassManagerImpl.h b/llvm/include/llvm/IR/PassManagerImpl.h index dc85ebc3644b9..e4a85b0f33b26 100644 --- a/llvm/include/llvm/IR/PassManagerImpl.h +++ b/llvm/include/llvm/IR/PassManagerImpl.h @@ -15,8 +15,11 @@ #ifndef LLVM_IR_PASSMANAGERIMPL_H #define LLVM_IR_PASSMANAGERIMPL_H +#include "llvm/Support/CommandLine.h" #include "llvm/IR/PassManager.h" +extern llvm::cl::opt UseNewDbgInfoFormat; + namespace llvm { template diff --git a/llvm/lib/Analysis/PHITransAddr.cpp b/llvm/lib/Analysis/PHITransAddr.cpp index 1a02497f25c33..5ec1964c4cb60 100644 --- a/llvm/lib/Analysis/PHITransAddr.cpp +++ b/llvm/lib/Analysis/PHITransAddr.cpp @@ -17,6 +17,7 @@ #include "llvm/IR/Constants.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Instructions.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index af5d6891805a6..06d99366a8c3e 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -109,6 +109,7 @@ cl::opt LoadBitcodeIntoNewDbgInfoFormat( "load-bitcode-into-experimental-debuginfo-iterators", cl::Hidden, cl::desc("Load bitcode directly into the new debug info format (regardless " "of input format)")); +extern cl::opt UseNewDbgInfoFormat; extern cl::opt PreserveInputDbgFormat; extern bool WriteNewDbgInfoFormatToBitcode; extern cl::opt WriteNewDbgInfoFormat; diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 5c603ac6ab472..2ba7f587c3f2b 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -65,6 +65,8 @@ using namespace object; #define DEBUG_TYPE "lto" +extern cl::opt UseNewDbgInfoFormat; + static cl::opt DumpThinCGSCCs("dump-thin-cg-sccs", cl::init(false), cl::Hidden, cl::desc("Dump the SCCs in the ThinLTO index's callgraph")); diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp index 8e829a53aeca2..30ef7689801dd 100644 --- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp +++
[clang] [llvm] [polly] [LLVM] Add InsertPosition union-type to remove overloads of Instruction-creation (PR #94226)
https://github.com/nikic approved this pull request. https://github.com/llvm/llvm-project/pull/94226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM] Add InsertPosition union-type to remove overloads of Instruction-creation (PR #94226)
@@ -1567,68 +1242,33 @@ void LoadInst::AssertOK() { "Ptr must have pointer type."); } -static Align computeLoadStoreDefaultAlign(Type *Ty, BasicBlock *BB) { - assert(BB && "Insertion BB cannot be null when alignment not provided!"); +static Align computeLoadStoreDefaultAlign(Type *Ty, InsertPosition Pos) { + assert(Pos.isValid() && + "Insertion position cannot be null when alignment not provided!"); + BasicBlock *BB = ((BasicBlock::iterator)Pos).getNodeParent(); nikic wrote: ```suggestion BasicBlock *BB = Pos.getBasicBlock(); ``` https://github.com/llvm/llvm-project/pull/94226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM] Add InsertPosition union-type to remove overloads of Instruction-creation (PR #94226)
nikic wrote: It looks like polly needs an update as well. https://github.com/llvm/llvm-project/pull/94226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM] Add InsertPosition union-type to remove overloads of Instruction-creation (PR #94226)
@@ -63,10 +63,10 @@ class IRBuilderDefaultInserter { virtual ~IRBuilderDefaultInserter(); virtual void InsertHelper(Instruction *I, const Twine , -BasicBlock *BB, BasicBlock::iterator InsertPt) const { -if (BB) - I->insertInto(BB, InsertPt); +if (InsertPt.isValid()) { nikic wrote: Drop braces. https://github.com/llvm/llvm-project/pull/94226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM] Add InsertPosition union-type to remove overloads of Instruction-creation (PR #94226)
@@ -44,6 +44,23 @@ template <> struct ilist_alloc_traits { iterator_range::iterator> getDbgRecordRange(DbgMarker *); +class InsertPosition { + using InstListType = SymbolTableList, + ilist_parent>; + InstListType::iterator InsertAt; + +public: + InsertPosition(std::nullopt_t) : InsertAt() {} + InsertPosition(std::nullptr_t) : InsertAt() {} + // LLVM_DEPRECATED("Use BasicBlock::iterators for insertion instead", + // "BasicBlock::iterator") + InsertPosition(Instruction *InsertBefore); + InsertPosition(BasicBlock *InsertAtEnd); + InsertPosition(InstListType::iterator InsertAt) : InsertAt(InsertAt) {} + operator InstListType::iterator() const { return InsertAt; } + bool IsValid() const { return InsertAt.getNodePtr(); } nikic wrote: I think you added an isValid() method to the iterator itself? https://github.com/llvm/llvm-project/pull/94226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM] Add InsertPosition union-type to remove overloads of Instruction-creation (PR #94226)
@@ -120,7 +120,8 @@ llvm::AllocaInst *CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, Alloca = Builder.CreateAlloca(Ty, ArraySize, Name); else Alloca = new llvm::AllocaInst(Ty, CGM.getDataLayout().getAllocaAddrSpace(), - ArraySize, Name, AllocaInsertPt); + ArraySize, Name, + (llvm::Instruction *)AllocaInsertPt); nikic wrote: ```suggestion &*AllocaInsertPt); ``` Does something like this work instead? https://github.com/llvm/llvm-project/pull/94226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM] Add InsertPosition union-type to remove overloads of Instruction-creation (PR #94226)
@@ -1460,56 +1184,29 @@ static Value *getAISize(LLVMContext , Value *Amt) { return Amt; } -static Align computeAllocaDefaultAlign(Type *Ty, BasicBlock *BB) { - assert(BB && "Insertion BB cannot be null when alignment not provided!"); +static Align computeAllocaDefaultAlign(Type *Ty, InsertPosition Pos) { + assert(Pos.IsValid() && + "Insertion position cannot be null when alignment not provided!"); + BasicBlock *BB = ((BasicBlock::iterator)Pos).getNodeParent(); nikic wrote: Maybe add a getParent() method on InsertPosition? https://github.com/llvm/llvm-project/pull/94226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM] Add InsertPosition union-type to remove overloads of Instruction-creation (PR #94226)
@@ -63,10 +63,10 @@ class IRBuilderDefaultInserter { virtual ~IRBuilderDefaultInserter(); virtual void InsertHelper(Instruction *I, const Twine , -BasicBlock *BB, BasicBlock::iterator InsertPt) const { -if (BB) - I->insertInto(BB, InsertPt); +if (InsertPt.isValid()) { + I->insertInto(InsertPt.getNodeParent(), InsertPt); nikic wrote: We should drop the BasicBlock argument from this API now, but that can be a followup... https://github.com/llvm/llvm-project/pull/94226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM] Add InsertPosition union-type to remove overloads of Instruction-creation (PR #94226)
https://github.com/nikic approved this pull request. Thanks for doing this, LGTM! https://github.com/llvm/llvm-project/pull/94226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM] Add InsertPosition union-type to remove overloads of Instruction-creation (PR #94226)
https://github.com/nikic edited https://github.com/llvm/llvm-project/pull/94226 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)
@@ -118,6 +124,37 @@ llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T, bool ForBitField) { return R; } +bool CodeGenTypes::LLVMTypeLayoutMatchesAST(QualType ASTTy, +llvm::Type *LLVMTy) { + CharUnits ASTSize = Context.getTypeSizeInChars(ASTTy); + CharUnits LLVMSize = + CharUnits::fromQuantity(getDataLayout().getTypeAllocSize(LLVMTy)); + return ASTSize == LLVMSize; +} + +llvm::Type *CodeGenTypes::convertTypeForLoadStore(QualType T, + llvm::Type *LLVMTy) { + if (!LLVMTy) +LLVMTy = ConvertType(T); + + if (!T->isBitIntType() && LLVMTy->isIntegerTy(1)) +return llvm::IntegerType::get(getLLVMContext(), + (unsigned)Context.getTypeSize(T)); + + if (T->isBitIntType()) { +llvm::Type *R = ConvertType(T); +if (!LLVMTypeLayoutMatchesAST(T, R)) + return llvm::Type::getIntNTy( + getLLVMContext(), Context.getTypeSizeInChars(T).getQuantity() * 8); nikic wrote: FWIW, using `[N x i8]` for all types is exactly what Rust does nowadays. https://github.com/llvm/llvm-project/pull/91364 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [llvm] [llvm] Remove the Legacy PM Hello example (PR #95708)
https://github.com/nikic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/95708 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] cc2dc09 - Reapply [ConstantFold] Drop gep of gep fold entirely (#95126)
Author: Nikita Popov Date: 2024-06-13T17:03:35+02:00 New Revision: cc2dc0916ad6a00ebc9373a58854d77cf73af122 URL: https://github.com/llvm/llvm-project/commit/cc2dc0916ad6a00ebc9373a58854d77cf73af122 DIFF: https://github.com/llvm/llvm-project/commit/cc2dc0916ad6a00ebc9373a58854d77cf73af122.diff LOG: Reapply [ConstantFold] Drop gep of gep fold entirely (#95126) Reapplying without changes. The flang+openmp buildbot failure should be addressed by https://github.com/llvm/llvm-project/pull/94541. - This is a followup to https://github.com/llvm/llvm-project/pull/93823 and drops the DataLayout-unaware GEP of GEP fold entirely. All cases are now left to the DataLayout-aware constant folder, which will fold everything to a single i8 GEP. We didn't have any test coverage for this fold in LLVM, but some Clang tests change. Added: Modified: clang/test/CodeGenCUDA/managed-var.cu clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp clang/test/CodeGenCXX/ms-inline-asm-fields.cpp clang/test/OpenMP/threadprivate_codegen.cpp llvm/include/llvm/IR/ConstantFold.h llvm/lib/Analysis/InstructionSimplify.cpp llvm/lib/IR/ConstantFold.cpp llvm/lib/IR/Constants.cpp Removed: diff --git a/clang/test/CodeGenCUDA/managed-var.cu b/clang/test/CodeGenCUDA/managed-var.cu index 5206acc62fe00..07e1a1e692c75 100644 --- a/clang/test/CodeGenCUDA/managed-var.cu +++ b/clang/test/CodeGenCUDA/managed-var.cu @@ -127,9 +127,10 @@ __device__ __host__ float load2() { // HOST-LABEL: define {{.*}}@_Z5load3v() // HOST: %ld.managed = load ptr, ptr @v2, align 16 -// HOST: %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, i64 0, i64 1, i32 1 -// HOST: %1 = load float, ptr %0, align 4 -// HOST: ret float %1 +// HOST: %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, i64 0, i64 1 +// HOST: %1 = getelementptr inbounds %struct.vec, ptr %0, i32 0, i32 1 +// HOST: %2 = load float, ptr %1, align 4 +// HOST: ret float %2 float load3() { return v2[1].y; } @@ -139,10 +140,11 @@ float load3() { // HOST: %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, i64 0, i64 1 // HOST: %1 = ptrtoint ptr %0 to i64 // HOST: %ld.managed1 = load ptr, ptr @v2, align 16 -// HOST: %2 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed1, i64 0, i64 1, i32 1 -// HOST: %3 = ptrtoint ptr %2 to i64 -// HOST: %4 = sub i64 %3, %1 -// HOST: %sub.ptr.div = sdiv exact i64 %4, 4 +// HOST: %2 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed1, i64 0, i64 1 +// HOST: %3 = getelementptr inbounds %struct.vec, ptr %2, i32 0, i32 1 +// HOST: %4 = ptrtoint ptr %3 to i64 +// HOST: %5 = sub i64 %4, %1 +// HOST: %sub.ptr.div = sdiv exact i64 %5, 4 // HOST: %conv = sitofp i64 %sub.ptr.div to float // HOST: ret float %conv float addr_taken2() { diff --git a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp index 4033adc8f0390..14557829268ef 100644 --- a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp +++ b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp @@ -21,6 +21,6 @@ struct S { // CHECK: store i32 0, ptr @arr // CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr @arr, i32 0, i32 1), ptr noundef @.str) // CHECK: store i32 1, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1) -// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr @arr, i64 1, i32 1), ptr noundef @.str.1) +// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1), i32 0, i32 1), ptr noundef @.str.1) // CHECK: store i32 2, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 2) -// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr @arr, i64 2, i32 1), ptr noundef @.str.2) +// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 2), i32 0, i32 1), ptr noundef @.str.2) diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp index 6fbe4c7fd17a7..caa92f47a93c2 100644 --- a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp +++ b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp @@ -79,12 +79,12 @@ std::initializer_list> nested = { // CHECK-DYNAMIC-BL: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr @_ZGR6nested1_, i64 1) // CHECK-DYNAMIC-BL: store ptr @_ZGR6nested1_, // CHECK-DYNAMIC-BL: ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), align 8 -//
[clang] [llvm] Reapply "[llvm][IR] Extend BranchWeightMetadata to track provenance o… (PR #95281)
https://github.com/nikic approved this pull request. Looks good now, no text size of compile-time changes. https://github.com/llvm/llvm-project/pull/95281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [ConstantFold] Drop gep of gep fold entirely (PR #95126)
nikic wrote: @agozillon Thanks for looking into this! This change isn't urgent, so I'm happy to wait for your PR to go in first. https://github.com/llvm/llvm-project/pull/95126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [ConstantFold] Drop gep of gep fold entirely (PR #95126)
nikic wrote: > I believe this broke our flang+openmp+offload bot: > https://lab.llvm.org/staging/#/builders/140/builds/10168 Happy to help > looking into it. That's for the heads-up, I've reverted this patch in https://github.com/llvm/llvm-project/commit/cece0a105b29dcbb9d88d0aa264c4745c07a8456. I would appreciate some help with debugging this, I don't think I can run this test locally. Probably just having the pre-optimization LLVM IR/bitcode would be enough. (Though with offload, there is probably more than one module involved?) https://github.com/llvm/llvm-project/pull/95126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] cece0a1 - Revert "[ConstantFold] Drop gep of gep fold entirely (#95126)"
Author: Nikita Popov Date: 2024-06-12T11:52:12+02:00 New Revision: cece0a105b29dcbb9d88d0aa264c4745c07a8456 URL: https://github.com/llvm/llvm-project/commit/cece0a105b29dcbb9d88d0aa264c4745c07a8456 DIFF: https://github.com/llvm/llvm-project/commit/cece0a105b29dcbb9d88d0aa264c4745c07a8456.diff LOG: Revert "[ConstantFold] Drop gep of gep fold entirely (#95126)" This reverts commit 3b3b839c66dc49674fd6646650525a2173030690. This broke the flang+openmp+offload buildbot, as reported in https://github.com/llvm/llvm-project/pull/95126#issuecomment-2162424019. Added: Modified: clang/test/CodeGenCUDA/managed-var.cu clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp clang/test/CodeGenCXX/ms-inline-asm-fields.cpp clang/test/OpenMP/threadprivate_codegen.cpp llvm/include/llvm/IR/ConstantFold.h llvm/lib/Analysis/InstructionSimplify.cpp llvm/lib/IR/ConstantFold.cpp llvm/lib/IR/Constants.cpp Removed: diff --git a/clang/test/CodeGenCUDA/managed-var.cu b/clang/test/CodeGenCUDA/managed-var.cu index 07e1a1e692c75..5206acc62fe00 100644 --- a/clang/test/CodeGenCUDA/managed-var.cu +++ b/clang/test/CodeGenCUDA/managed-var.cu @@ -127,10 +127,9 @@ __device__ __host__ float load2() { // HOST-LABEL: define {{.*}}@_Z5load3v() // HOST: %ld.managed = load ptr, ptr @v2, align 16 -// HOST: %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, i64 0, i64 1 -// HOST: %1 = getelementptr inbounds %struct.vec, ptr %0, i32 0, i32 1 -// HOST: %2 = load float, ptr %1, align 4 -// HOST: ret float %2 +// HOST: %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, i64 0, i64 1, i32 1 +// HOST: %1 = load float, ptr %0, align 4 +// HOST: ret float %1 float load3() { return v2[1].y; } @@ -140,11 +139,10 @@ float load3() { // HOST: %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, i64 0, i64 1 // HOST: %1 = ptrtoint ptr %0 to i64 // HOST: %ld.managed1 = load ptr, ptr @v2, align 16 -// HOST: %2 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed1, i64 0, i64 1 -// HOST: %3 = getelementptr inbounds %struct.vec, ptr %2, i32 0, i32 1 -// HOST: %4 = ptrtoint ptr %3 to i64 -// HOST: %5 = sub i64 %4, %1 -// HOST: %sub.ptr.div = sdiv exact i64 %5, 4 +// HOST: %2 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed1, i64 0, i64 1, i32 1 +// HOST: %3 = ptrtoint ptr %2 to i64 +// HOST: %4 = sub i64 %3, %1 +// HOST: %sub.ptr.div = sdiv exact i64 %4, 4 // HOST: %conv = sitofp i64 %sub.ptr.div to float // HOST: ret float %conv float addr_taken2() { diff --git a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp index 14557829268ef..4033adc8f0390 100644 --- a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp +++ b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp @@ -21,6 +21,6 @@ struct S { // CHECK: store i32 0, ptr @arr // CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr @arr, i32 0, i32 1), ptr noundef @.str) // CHECK: store i32 1, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1) -// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1), i32 0, i32 1), ptr noundef @.str.1) +// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr @arr, i64 1, i32 1), ptr noundef @.str.1) // CHECK: store i32 2, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 2) -// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 2), i32 0, i32 1), ptr noundef @.str.2) +// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr @arr, i64 2, i32 1), ptr noundef @.str.2) diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp index caa92f47a93c2..6fbe4c7fd17a7 100644 --- a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp +++ b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp @@ -79,12 +79,12 @@ std::initializer_list> nested = { // CHECK-DYNAMIC-BL: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr @_ZGR6nested1_, i64 1) // CHECK-DYNAMIC-BL: store ptr @_ZGR6nested1_, // CHECK-DYNAMIC-BL: ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), align 8 -// CHECK-DYNAMIC-BL: store i64 2, ptr getelementptr inbounds ({{.*}}, ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), i32 0, i32 1), align 8 +// CHECK-DYNAMIC-BL: store i64 2, ptr getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1, i32 1), align 8 //
[clang] [llvm] [ConstantFold] Drop gep of gep fold entirely (PR #95126)
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/95126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Swap range metadata to attribute for intrinsics. (PR #94851)
https://github.com/nikic approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/94851 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [ConstantFold] Drop gep of gep fold entirely (PR #95126)
nikic wrote: > See > [51e459a](https://github.com/llvm/llvm-project/commit/51e459a561519c8d51e2b4cadddc0d1f99c8b7ef): > > > This causes some non-trivial text size increases in unoptimized builds for > > Bullet. Revert while I investigate. > > Can you double check this? This was mitigated by https://github.com/llvm/llvm-project/pull/93956. I did check that this patch does not cause code size regression for O0. https://github.com/llvm/llvm-project/pull/95126 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [ConstantFold] Drop gep of gep fold entirely (PR #95126)
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/95126 This is a followup to https://github.com/llvm/llvm-project/pull/93823 and drops the DataLayout-unaware GEP of GEP fold entirely. All cases are now left to the DataLayout-aware constant folder, which will fold everything to a single i8 GEP. We didn't have any test coverage for this fold in LLVM, but some Clang tests change. >From 450f26d9950f6b335eb883f31fc94581a39d32ac Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 30 May 2024 16:20:35 +0200 Subject: [PATCH] [ConstantFold] Drop gep of gep fold entirely This is a followup to https://github.com/llvm/llvm-project/pull/93823 and drop the DataLayout-unaware GEP of GEP fold entirely. All cases are now left to the DataLayout-aware constant folder, which will fold everything to a single i8 GEP. We didn't have any test coverage for this fold in LLVM, but some Clang tests change. --- clang/test/CodeGenCUDA/managed-var.cu | 16 + .../CodeGenCXX/2011-12-19-init-list-ctor.cpp | 4 +-- ...initializer-stdinitializerlist-pr12086.cpp | 8 ++--- .../cxx0x-initializer-stdinitializerlist.cpp | 4 +-- .../test/CodeGenCXX/ms-inline-asm-fields.cpp | 2 +- clang/test/OpenMP/threadprivate_codegen.cpp | 16 - llvm/include/llvm/IR/ConstantFold.h | 2 +- llvm/lib/Analysis/InstructionSimplify.cpp | 5 ++- llvm/lib/IR/ConstantFold.cpp | 33 --- llvm/lib/IR/Constants.cpp | 3 +- 10 files changed, 30 insertions(+), 63 deletions(-) diff --git a/clang/test/CodeGenCUDA/managed-var.cu b/clang/test/CodeGenCUDA/managed-var.cu index 5206acc62fe00..07e1a1e692c75 100644 --- a/clang/test/CodeGenCUDA/managed-var.cu +++ b/clang/test/CodeGenCUDA/managed-var.cu @@ -127,9 +127,10 @@ __device__ __host__ float load2() { // HOST-LABEL: define {{.*}}@_Z5load3v() // HOST: %ld.managed = load ptr, ptr @v2, align 16 -// HOST: %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, i64 0, i64 1, i32 1 -// HOST: %1 = load float, ptr %0, align 4 -// HOST: ret float %1 +// HOST: %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, i64 0, i64 1 +// HOST: %1 = getelementptr inbounds %struct.vec, ptr %0, i32 0, i32 1 +// HOST: %2 = load float, ptr %1, align 4 +// HOST: ret float %2 float load3() { return v2[1].y; } @@ -139,10 +140,11 @@ float load3() { // HOST: %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, i64 0, i64 1 // HOST: %1 = ptrtoint ptr %0 to i64 // HOST: %ld.managed1 = load ptr, ptr @v2, align 16 -// HOST: %2 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed1, i64 0, i64 1, i32 1 -// HOST: %3 = ptrtoint ptr %2 to i64 -// HOST: %4 = sub i64 %3, %1 -// HOST: %sub.ptr.div = sdiv exact i64 %4, 4 +// HOST: %2 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed1, i64 0, i64 1 +// HOST: %3 = getelementptr inbounds %struct.vec, ptr %2, i32 0, i32 1 +// HOST: %4 = ptrtoint ptr %3 to i64 +// HOST: %5 = sub i64 %4, %1 +// HOST: %sub.ptr.div = sdiv exact i64 %5, 4 // HOST: %conv = sitofp i64 %sub.ptr.div to float // HOST: ret float %conv float addr_taken2() { diff --git a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp index 4033adc8f0390..14557829268ef 100644 --- a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp +++ b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp @@ -21,6 +21,6 @@ struct S { // CHECK: store i32 0, ptr @arr // CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr @arr, i32 0, i32 1), ptr noundef @.str) // CHECK: store i32 1, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1) -// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr @arr, i64 1, i32 1), ptr noundef @.str.1) +// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1), i32 0, i32 1), ptr noundef @.str.1) // CHECK: store i32 2, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 2) -// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr @arr, i64 2, i32 1), ptr noundef @.str.2) +// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds (%struct.S, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 2), i32 0, i32 1), ptr noundef @.str.2) diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp index 6fbe4c7fd17a7..caa92f47a93c2 100644 --- a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp +++ b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp @@ -79,12 +79,12 @@ std::initializer_list> nested = { // CHECK-DYNAMIC-BL: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr @_ZGR6nested1_, i64 1) // CHECK-DYNAMIC-BL: store ptr
[clang-tools-extra] [clangd] Use clang_target_link_libraries() for clang libs (PR #94937)
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/94937 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Revert "[llvm][IR] Extend BranchWeightMetadata to track provenance of weights" (PR #95060)
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/95060 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Revert "[llvm][IR] Extend BranchWeightMetadata to track provenance of weights" (PR #95060)
https://github.com/nikic approved this pull request. https://github.com/llvm/llvm-project/pull/95060 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clangd] Use clang_target_link_libraries() for clang libs (PR #94937)
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/94937 Use clang_target_link_libraries() instead of LINK_LIBS when linking clang libraries. This ensures that in CLANG_LINK_CLANG_DYLIB mode we link against libclang-cpp.so (instead of linking against both it and the static libraries). Most places were already doing this correctly, there were just a handful of leftovers. >From 09c5b73a981c4092d2479c9c50da9299ad43cccb Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 10 Jun 2024 10:07:04 +0200 Subject: [PATCH] [clangd] Use clang_target_link_libraries() for clang libs Use clang_target_link_libraries() instead of LINK_LIBS when linking clang libraries. This ensures that in CLANG_LINK_CLANG_DYLIB mode we link against libclang-cpp.so (instead of linking against both it and the static libraries). Most places were already doing this correctly, there were just a handful of leftovers. --- clang-tools-extra/clangd/index/remote/CMakeLists.txt | 6 +- clang-tools-extra/pseudo/lib/CMakeLists.txt | 8 ++-- clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt | 6 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/clangd/index/remote/CMakeLists.txt b/clang-tools-extra/clangd/index/remote/CMakeLists.txt index ed6269d2ccaa9..106bbeff84ccf 100644 --- a/clang-tools-extra/clangd/index/remote/CMakeLists.txt +++ b/clang-tools-extra/clangd/index/remote/CMakeLists.txt @@ -26,7 +26,6 @@ if (CLANGD_ENABLE_REMOTE) clangdRemoteIndexProto clangdRemoteIndexServiceProto clangdRemoteMarshalling -clangBasic clangDaemon clangdSupport @@ -35,6 +34,11 @@ if (CLANGD_ENABLE_REMOTE) clangdRemoteIndexServiceProto ) + clang_target_link_libraries(clangdRemoteIndex +PRIVATE +clangBasic +) + add_subdirectory(marshalling) add_subdirectory(server) add_subdirectory(monitor) diff --git a/clang-tools-extra/pseudo/lib/CMakeLists.txt b/clang-tools-extra/pseudo/lib/CMakeLists.txt index f92f79be12150..a13b5d20cf7c3 100644 --- a/clang-tools-extra/pseudo/lib/CMakeLists.txt +++ b/clang-tools-extra/pseudo/lib/CMakeLists.txt @@ -14,8 +14,6 @@ add_clang_library(clangPseudo Token.cpp LINK_LIBS - clangBasic - clangLex clangPseudoGrammar DEPENDS @@ -25,3 +23,9 @@ add_clang_library(clangPseudo target_include_directories(clangPseudo INTERFACE $ ) + +clang_target_link_libraries(clangPseudo + PRIVATE + clangBasic + clangLex + ) diff --git a/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt b/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt index d56d16c893c3d..2fecdce6a10f9 100644 --- a/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt +++ b/clang-tools-extra/pseudo/lib/cxx/CMakeLists.txt @@ -9,7 +9,11 @@ add_clang_library(clangPseudoCXX cxx_gen LINK_LIBS - clangBasic clangPseudo clangPseudoGrammar ) + +clang_target_link_libraries(clangPseudoCXX + PRIVATE + clangBasic + ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Simplify codegen for array initialization (PR #93956)
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/93956 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [mlir] [Flang]Fix for changed code at the end of AllocaIP. (PR #92430)
https://github.com/nikic dismissed https://github.com/llvm/llvm-project/pull/92430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [CodeGen] Simplify codegen for array initialization (PR #93956)
nikic wrote: ping https://github.com/llvm/llvm-project/pull/93956 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [mlir] [Flang]Fix for changed code at the end of AllocaIP. (PR #92430)
nikic wrote: > > Allocas should be placed at the start of the entry block. > > Would it be acceptable to make this change such that the alloca's are at the > very start of the block? I have tried that, and it seems to work. It will > still mean changes to the tests, and I can't guarantee ALL alloca's for all > Fortran (via MLIR) generated code will be at the start of the entry block. Yes, that should be fine. You could also use something like getFirstNonPHIOrDbgOrAlloca to compute the insert point after the current allocas. (Calling this many times could have quadratic runtime though -- I don't have enough context here to say whether that's a problem or not.) https://github.com/llvm/llvm-project/pull/92430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Remove redundant LINK_LIBS (PR #94588)
https://github.com/nikic closed https://github.com/llvm/llvm-project/pull/94588 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [cmake] Respect CLANG_LINK_CLANG_DYLIB for objlibs (PR #93454)
nikic wrote: I suspect I may have misdiagnosed the issue, and the actual problem may be just https://github.com/llvm/llvm-project/pull/94588. I'll double check whether this change is necessary before landing. https://github.com/llvm/llvm-project/pull/93454 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [cmake] Respect CLANG_LINK_CLANG_DYLIB for objlibs (PR #93454)
https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/93454 >From b0bcd36b62a93e7d8bd0f7f01e857ce9aa7544c2 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 27 May 2024 11:56:41 +0200 Subject: [PATCH 1/2] [cmake] Respect CLANG_LINK_CLANG_DYLIB for objlibs add_clang_library() will create a library clangFoo that depends on objlib obj.clangFoo. Then clang_target_link_libraries() will add a clang-cpp dependency to clangFoo, but obj.clangFoo will instead get dependencies on the individual clangXYZ libraries, instead of the shared object. The final outcome is that we will link both the static libraries and the shared object, leading to an increase in binary size and link times (when using LTO). Make sure we use the same logic for the obj and non-obj libs. --- clang/cmake/modules/AddClang.cmake | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake index a5ef639187d9..534c7b84ecfb 100644 --- a/clang/cmake/modules/AddClang.cmake +++ b/clang/cmake/modules/AddClang.cmake @@ -194,10 +194,6 @@ macro(add_clang_symlink name dest) endmacro() function(clang_target_link_libraries target type) - if (TARGET obj.${target}) -target_link_libraries(obj.${target} ${ARGN}) - endif() - get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS) if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${target} IN_LIST LLVM_DRIVER_TOOLS) set(target llvm-driver) @@ -205,7 +201,13 @@ function(clang_target_link_libraries target type) if (CLANG_LINK_CLANG_DYLIB) target_link_libraries(${target} ${type} clang-cpp) +if (TARGET obj.${target}) + target_link_libraries(obj.${target} clang-cpp) +endif() else() target_link_libraries(${target} ${type} ${ARGN}) +if (TARGET obj.${target}) + target_link_libraries(obj.${target} ${ARGN}) +endif() endif() endfunction() >From 1cc7f9a4dc8d406886188797858e314f2d7634c6 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 6 Jun 2024 10:05:35 +0200 Subject: [PATCH 2/2] Use INTERFACE dep --- clang/cmake/modules/AddClang.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake index 534c7b84ecfb..2528c16a09e5 100644 --- a/clang/cmake/modules/AddClang.cmake +++ b/clang/cmake/modules/AddClang.cmake @@ -202,12 +202,12 @@ function(clang_target_link_libraries target type) if (CLANG_LINK_CLANG_DYLIB) target_link_libraries(${target} ${type} clang-cpp) if (TARGET obj.${target}) - target_link_libraries(obj.${target} clang-cpp) + target_link_libraries(obj.${target} INTERFACE clang-cpp) endif() else() target_link_libraries(${target} ${type} ${ARGN}) if (TARGET obj.${target}) - target_link_libraries(obj.${target} ${ARGN}) + target_link_libraries(obj.${target} INTERFACE ${ARGN}) endif() endif() endfunction() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [clang-tidy] Remove redundant LINK_LIBS (PR #94588)
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/94588 clangAnalysis is already being pulled in via clang_target_link_libraries(). Also listing it in LINK_LIBS means that we'll link both against the static libraries and the shared libclang-cpp.so library if CLANG_LINK_CLANG_DYLIB is enabled, and waste time on unnecessary LTO. >From b4dda7214c4c6431c9f978296f68b494c4fc7b68 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 6 Jun 2024 10:25:25 +0200 Subject: [PATCH] [clang-tidy] Remove redundant LINK_LIBS clangAnalysis is already being pulled in via clang_target_link_libraries(). Also listing it in LINK_LIBS means that we'll link both against the static libraries and the shared libclang-cpp.so library if CLANG_LINK_CLANG_DYLIB is enabled, and waste time on unnecessary LTO. --- clang-tools-extra/clang-tidy/misc/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt index 35e29b9a7d13..36fcd8fc1b27 100644 --- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt @@ -43,7 +43,6 @@ add_clang_library(clangTidyMiscModule UseAnonymousNamespaceCheck.cpp LINK_LIBS - clangAnalysis clangTidy clangTidyUtils ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits