r312870 - clang fix for LLVM API change: isKnownNonNull -> isKnownNonZero
Author: nlopes Date: Sat Sep 9 11:25:36 2017 New Revision: 312870 URL: http://llvm.org/viewvc/llvm-project?rev=312870&view=rev Log: clang fix for LLVM API change: isKnownNonNull -> isKnownNonZero Differential Revision: https://reviews.llvm.org/D37628 Modified: cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp Modified: cfe/trunk/lib/CodeGen/CGCall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=312870&r1=312869&r2=312870&view=diff == --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCall.cpp Sat Sep 9 11:25:36 2017 @@ -3055,7 +3055,8 @@ static void emitWriteback(CodeGenFunctio // If the argument wasn't provably non-null, we need to null check // before doing the store. - bool provablyNonNull = llvm::isKnownNonNull(srcAddr.getPointer()); + bool provablyNonNull = llvm::isKnownNonZero(srcAddr.getPointer(), + CGF.CGM.getDataLayout()); if (!provablyNonNull) { llvm::BasicBlock *writebackBB = CGF.createBasicBlock("icr.writeback"); contBB = CGF.createBasicBlock("icr.done"); @@ -3195,7 +3196,8 @@ static void emitWritebackArg(CodeGenFunc // If the address is *not* known to be non-null, we need to switch. llvm::Value *finalArgument; - bool provablyNonNull = llvm::isKnownNonNull(srcAddr.getPointer()); + bool provablyNonNull = llvm::isKnownNonZero(srcAddr.getPointer(), + CGF.CGM.getDataLayout()); if (provablyNonNull) { finalArgument = temp.getPointer(); } else { Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp?rev=312870&r1=312869&r2=312870&view=diff == --- cfe/trunk/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp (original) +++ cfe/trunk/test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp Sat Sep 9 11:25:36 2017 @@ -78,7 +78,7 @@ T* test6(B* x) { return dynamic_cast // CHECK-NEXT: [[VBOFFS:%.*]] = load i32, i32* [[VBOFFP]], align 4 // CHECK-NEXT: [[DELTA:%.*]] = add nsw i32 [[VBOFFS]], 4 // CHECK-NEXT: [[ADJ:%.*]] = getelementptr inbounds i8, i8* [[CAST]], i32 [[DELTA]] -// CHECK-NEXT: [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* [[ADJ]], i32 [[DELTA]], i8* {{.*}}bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUB@@@8" to i8*), i8* {{.*}}bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUT@@@8" to i8*), i32 0) +// CHECK-NEXT: [[CALL:%.*]] = tail call i8* @__RTDynamicCast(i8* nonnull [[ADJ]], i32 [[DELTA]], i8* {{.*}}bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUB@@@8" to i8*), i8* {{.*}}bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUT@@@8" to i8*), i32 0) // CHECK-NEXT: [[RES:%.*]] = bitcast i8* [[CALL]] to %struct.T* // CHECK-NEXT: br label // CHECK:[[RET:%.*]] = phi %struct.T* @@ -117,7 +117,7 @@ void* test9(B* x) { return dynamic_cast< // CHECK-NEXT: [[VBOFFS:%.*]] = load i32, i32* [[VBOFFP]], align 4 // CHECK-NEXT: [[DELTA:%.*]] = add nsw i32 [[VBOFFS]], 4 // CHECK-NEXT: [[ADJ:%.*]] = getelementptr inbounds i8, i8* [[CAST]], i32 [[DELTA]] -// CHECK-NEXT: [[CALL:%.*]] = tail call i8* @__RTCastToVoid(i8* [[ADJ]]) +// CHECK-NEXT: [[CALL:%.*]] = tail call i8* @__RTCastToVoid(i8* nonnull [[ADJ]]) // CHECK-NEXT: br label // CHECK:[[RET:%.*]] = phi i8* // CHECK-NEXT: ret i8* [[RET]] ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [InstCombine] Infer disjoint flag on Or instructions. (PR #72912)
nunoplopes wrote: We don't have a `isGuaranteedNotToBeUndef` only function, so that's the only way. I would leave a fixme, since this call can be removed if we ever manage to kill undef. Thanks for your help! 🙂 https://github.com/llvm/llvm-project/pull/72912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [InstCombine] Infer disjoint flag on Or instructions. (PR #72912)
nunoplopes wrote: FWIW, Alive2 is complaining about this commit. These patches are not safe w.r.t. undef. https://github.com/llvm/llvm-project/pull/72912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [InstCombine] Infer disjoint flag on Or instructions. (PR #72912)
nunoplopes wrote: Here's a simple-ish example: ```llvm ; Transforms/InstCombine/add.ll define i5 @zext_sext_not(i4 %x) { %zx = zext i4 %x to i5 %notx = xor i4 %x, 15 %snotx = sext i4 %notx to i5 %r = add i5 %zx, %snotx ret i5 %r } => define i5 @zext_sext_not(i4 %x) { %zx = zext i4 %x to i5 %notx = xor i4 %x, 15 %snotx = sext i4 %notx to i5 %r = or disjoint i5 %zx, %snotx ret i5 %r } Transformation doesn't verify! (unsound) ERROR: Target is more poisonous than source Example: i4 %x = undef Source: i5 %zx = #x00 (0) [based on undef value] i4 %notx = #xf (15, -1) [based on undef value] i5 %snotx = #x1f (31, -1) i5 %r = #x1f (31, -1) Target: i5 %zx = #x0f (15) i4 %notx = #xf (15, -1) i5 %snotx = #x1f (31, -1) i5 %r = poison Source value: #x1f (31, -1) Target value: poison ``` Essentially the code doesn't take into consideration that a same register may have different values when it is undef. https://github.com/llvm/llvm-project/pull/72912 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [IR] Fix GEP offset computations for vector GEPs (PR #75448)
nunoplopes wrote: Alive2 is complaining about one of the tests: ```llvm @Global = global 10 bytes, align 1 define void @test_overaligned_vec(i8 %B) { %A = gep ptr @Global, 4 x i64 0, 4 x i64 1 store i8 %B, ptr %A, align 1 ret void } => @Global = global 10 bytes, align 1 define void @test_overaligned_vec(i8 %B) { %__constexpr_0 = gep inbounds ptr @Global, 10 x i64 0, 1 x i64 2 store i8 %B, ptr %__constexpr_0, align 1 ret void } Transformation doesn't verify! (unsound) ERROR: Mismatch in memory Example: i8 %B = #x11 (17) Source: ptr %A = pointer(non-local, block_id=0, offset=4) ``` GEP of 4 vs 2 bytes. https://github.com/llvm/llvm-project/pull/75448 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 6a1ccf6 - Revert "[NFC] Add some additional features to MultiLevelTemplateArgumentList"
Author: Nuno Lopes Date: 2022-07-22T21:33:22+01:00 New Revision: 6a1ccf61cdf80c793f9c699ada33af5d85263b30 URL: https://github.com/llvm/llvm-project/commit/6a1ccf61cdf80c793f9c699ada33af5d85263b30 DIFF: https://github.com/llvm/llvm-project/commit/6a1ccf61cdf80c793f9c699ada33af5d85263b30.diff LOG: Revert "[NFC] Add some additional features to MultiLevelTemplateArgumentList" This reverts commit 0b36a62d5f3505e21692ae0abf25ef00836329e3. It breaks the assertion build Added: Modified: clang/include/clang/Sema/Template.h Removed: diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h index 49bcb5798..5dcde77b5dd37 100644 --- a/clang/include/clang/Sema/Template.h +++ b/clang/include/clang/Sema/Template.h @@ -75,8 +75,6 @@ enum class TemplateSubstitutionKind : char { class MultiLevelTemplateArgumentList { /// The template argument list at a certain template depth using ArgList = ArrayRef; -using ArgListsIterator = SmallVector::iterator; -using ConstArgListsIterator = SmallVector::const_iterator; /// The template argument lists, stored from the innermost template /// argument list (first) to the outermost template argument list (last). @@ -123,12 +121,6 @@ enum class TemplateSubstitutionKind : char { return TemplateArgumentLists.size(); } -// Determine the number of substituted args at 'Depth'. -unsigned getNumSubsitutedArgs(unsigned Depth) const { - assert(NumretainedOuterLevels <= Depth && Depth < getNumLevels()); - return TemplateArgumentLists[getNumLevels() - Depth - 1].size(); -} - unsigned getNumRetainedOuterLevels() const { return NumRetainedOuterLevels; } @@ -166,14 +158,6 @@ enum class TemplateSubstitutionKind : char { return !(*this)(Depth, Index).isNull(); } -bool isAnyArgInstantiationDependent() const { - for (ArgList List : TemplateArgumentLists) -for (const TemplateArgument &TA : List) - if (TA.isInstantiationDependent()) -return true; - return false; -} - /// Clear out a specific template argument. void setArgument(unsigned Depth, unsigned Index, TemplateArgument Arg) { @@ -199,14 +183,6 @@ enum class TemplateSubstitutionKind : char { TemplateArgumentLists.push_back(Args); } -/// Replaces the current 'innermost' level with the provided argument list. -/// This is useful for type deduction cases where we need to get the entire -/// list from the AST, but then add the deduced innermost list. -void replaceInnermostTemplateArguments(ArgList Args) { - assert(TemplateArgumentLists.size() > 0 && "Replacing in an empty list?"); - TemplateArgumentLists[0] = Args; -} - /// Add an outermost level that we are not substituting. We have no /// arguments at this level, and do not remove it from the depth of inner /// template parameters that we instantiate. @@ -221,16 +197,6 @@ enum class TemplateSubstitutionKind : char { const ArgList &getInnermost() const { return TemplateArgumentLists.front(); } -/// Retrieve the outermost template argument list. -const ArgList &getOutermost() const { - return TemplateArgumentLists.back(); -} -ArgListsIterator begin() { return TemplateArgumentLists.begin(); } -ConstArgListsIterator begin() const { - return TemplateArgumentLists.begin(); -} -ArgListsIterator end() { return TemplateArgumentLists.end(); } -ConstArgListsIterator end() const { return TemplateArgumentLists.end(); } }; /// The context in which partial ordering of function templates occurs. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5fc9449 - [DeadArgElim] Use poison instead of undef as placeholder for dead arguments
Author: Nuno Lopes Date: 2022-05-19T18:00:24+01:00 New Revision: 5fc9449c962a0703a658aa8e29162e00dc2fecf1 URL: https://github.com/llvm/llvm-project/commit/5fc9449c962a0703a658aa8e29162e00dc2fecf1 DIFF: https://github.com/llvm/llvm-project/commit/5fc9449c962a0703a658aa8e29162e00dc2fecf1.diff LOG: [DeadArgElim] Use poison instead of undef as placeholder for dead arguments It doesn't matter which value we use for dead args, so let's switch to poison, so we can eventually kill undef. Reviewed By: aeubanks, fhahn Differential Revision: https://reviews.llvm.org/D125983 Added: Modified: clang/test/CodeGen/debug-info-block-vars.c clang/test/CodeGen/mips-unsigned-ext-var.c llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp llvm/test/DebugInfo/X86/dbgloc-insert-extract-val-instrs.ll llvm/test/Transforms/DeadArgElim/NoundefAttrs.ll llvm/test/Transforms/DeadArgElim/aggregates.ll llvm/test/Transforms/DeadArgElim/byref.ll llvm/test/Transforms/DeadArgElim/dbginfo-update-dbgval-local.ll llvm/test/Transforms/DeadArgElim/dbginfo-update-dbgval.ll llvm/test/Transforms/DeadArgElim/deadexternal.ll llvm/test/Transforms/DeadArgElim/fct_ptr.ll llvm/test/Transforms/DeadArgElim/opaque-ptr.ll llvm/test/Transforms/DeadArgElim/variadic_safety.ll Removed: diff --git a/clang/test/CodeGen/debug-info-block-vars.c b/clang/test/CodeGen/debug-info-block-vars.c index 11c899fa3c811..e22e8ac0f84ba 100644 --- a/clang/test/CodeGen/debug-info-block-vars.c +++ b/clang/test/CodeGen/debug-info-block-vars.c @@ -13,8 +13,8 @@ // CHECK-OPT-NOT: alloca // Since the block address is not used anywhere in this function, // the optimizer (DeadArgElim) has replaced all the false uses -// (i.e., metadata users) with undef. -// CHECK-OPT: call void @llvm.dbg.value(metadata i8* undef, +// (i.e., metadata users) with poison. +// CHECK-OPT: call void @llvm.dbg.value(metadata i8* poison, // CHECK-OPT-SAME: metadata !DIExpression()) void f(void) { a(^{ diff --git a/clang/test/CodeGen/mips-unsigned-ext-var.c b/clang/test/CodeGen/mips-unsigned-ext-var.c index 596b2b2fb1d32..e3f1ea6b88e5f 100644 --- a/clang/test/CodeGen/mips-unsigned-ext-var.c +++ b/clang/test/CodeGen/mips-unsigned-ext-var.c @@ -17,6 +17,6 @@ void foo1(void) { foo(1,f); } -//N64: call signext i32 (i32, ...) @foo(i32 signext undef, i32 noundef signext -32) -//N32: call signext i32 (i32, ...) @foo(i32 signext undef, i32 noundef signext -32) -//O32: call i32 (i32, ...) @foo(i32 signext undef, i32 noundef signext -32) +//N64: call signext i32 (i32, ...) @foo(i32 signext poison, i32 noundef signext -32) +//N32: call signext i32 (i32, ...) @foo(i32 signext poison, i32 noundef signext -32) +//O32: call i32 (i32, ...) @foo(i32 signext poison, i32 noundef signext -32) diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp index a879a0fb30b36..a9cabb30324aa 100644 --- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -54,8 +54,8 @@ using namespace llvm; STATISTIC(NumArgumentsEliminated, "Number of unread args removed"); STATISTIC(NumRetValsEliminated , "Number of unused return values removed"); -STATISTIC(NumArgumentsReplacedWithUndef, - "Number of unread args replaced with undef"); +STATISTIC(NumArgumentsReplacedWithPoison, + "Number of unread args replaced with poison"); namespace { @@ -251,14 +251,14 @@ bool DeadArgumentEliminationPass::DeleteDeadVarargs(Function &Fn) { } /// RemoveDeadArgumentsFromCallers - Checks if the given function has any -/// arguments that are unused, and changes the caller parameters to be undefined +/// arguments that are unused, and changes the caller parameters to be poison /// instead. bool DeadArgumentEliminationPass::RemoveDeadArgumentsFromCallers(Function &Fn) { // We cannot change the arguments if this TU does not define the function or // if the linker may choose a function body from another TU, even if the // nominal linkage indicates that other copies of the function have the same // semantics. In the below example, the dead load from %p may not have been - // eliminated from the linker-chosen copy of f, so replacing %p with undef + // eliminated from the linker-chosen copy of f, so replacing %p with poison // in callers may introduce undefined behavior. // // define linkonce_odr void @f(i32* %p) { @@ -294,7 +294,7 @@ bool DeadArgumentEliminationPass::RemoveDeadArgumentsFromCallers(Function &Fn) { if (!Arg.hasSwiftErrorAttr() && Arg.use_empty() && !Arg.hasPassPointeeByValueCopyAttr()) { if (Arg.isUsedByMetadata()) { -Arg.replaceAllUsesWith(UndefValue::get(Arg.getType())); +Arg.replaceAllUsesWith(PoisonValue::get(Arg.getType())); Changed =
[clang] 9231045 - Make LLVM build in C++20 mode
Author: Barry Revzin Date: 2020-12-17T10:44:10Z New Revision: 92310454bf0f1f9686f38afd11756c7d046495c9 URL: https://github.com/llvm/llvm-project/commit/92310454bf0f1f9686f38afd11756c7d046495c9 DIFF: https://github.com/llvm/llvm-project/commit/92310454bf0f1f9686f38afd11756c7d046495c9.diff LOG: Make LLVM build in C++20 mode Part of the <=> changes in C++20 make certain patterns of writing equality operators ambiguous with themselves (sorry!). This patch goes through and adjusts all the comparison operators such that they should work in both C++17 and C++20 modes. It also makes two other small C++20-specific changes (adding a constructor to a type that cases to be an aggregate, and adding casts from u8 literals which no longer have type const char*). There were four categories of errors that this review fixes. Here are canonical examples of them, ordered from most to least common: // 1) Missing const namespace missing_const { struct A { #ifndef FIXED bool operator==(A const&); #else bool operator==(A const&) const; #endif }; bool a = A{} == A{}; // error } // 2) Type mismatch on CRTP namespace crtp_mismatch { template struct Base { #ifndef FIXED bool operator==(Derived const&) const; #else // in one case changed to taking Base const& friend bool operator==(Derived const&, Derived const&); #endif }; struct D : Base { }; bool b = D{} == D{}; // error } // 3) iterator/const_iterator with only mixed comparison namespace iter_const_iter { template struct iterator { using const_iterator = iterator; iterator(); template = 0> iterator(iterator const&); #ifndef FIXED bool operator==(const_iterator const&) const; #else friend bool operator==(iterator const&, iterator const&); #endif }; bool c = iterator{} == iterator{} // error || iterator{} == iterator{} || iterator{} == iterator{} || iterator{} == iterator{}; } // 4) Same-type comparison but only have mixed-type operator namespace ambiguous_choice { enum Color { Red }; struct C { C(); C(Color); operator Color() const; bool operator==(Color) const; friend bool operator==(C, C); }; bool c = C{} == C{}; // error bool d = C{} == Red; } Differential revision: https://reviews.llvm.org/D78938 Added: Modified: clang/include/clang/AST/StmtIterator.h clang/lib/Parse/ParseOpenMP.cpp clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp llvm/include/llvm/ADT/AllocatorList.h llvm/include/llvm/ADT/DenseMap.h llvm/include/llvm/ADT/DenseSet.h llvm/include/llvm/ADT/DirectedGraph.h llvm/include/llvm/ADT/STLExtras.h llvm/include/llvm/ADT/StringMap.h llvm/include/llvm/ADT/iterator.h llvm/include/llvm/CodeGen/DIE.h llvm/include/llvm/CodeGen/LiveInterval.h llvm/include/llvm/DebugInfo/DWARF/DWARFDie.h llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h llvm/include/llvm/IR/Attributes.h llvm/include/llvm/IR/BasicBlock.h llvm/include/llvm/Object/StackMapParser.h llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h llvm/include/llvm/ProfileData/InstrProfReader.h llvm/include/llvm/Support/BinaryStreamRef.h llvm/include/llvm/Support/SuffixTree.h llvm/lib/CodeGen/PeepholeOptimizer.cpp llvm/lib/IR/Attributes.cpp llvm/lib/ObjectYAML/DWARFEmitter.cpp llvm/lib/Transforms/Scalar/GVNHoist.cpp llvm/tools/llvm-objdump/llvm-objdump.cpp llvm/unittests/ADT/STLExtrasTest.cpp Removed: diff --git a/clang/include/clang/AST/StmtIterator.h b/clang/include/clang/AST/StmtIterator.h index 911205347aad..bcdb0df829fb 100644 --- a/clang/include/clang/AST/StmtIterator.h +++ b/clang/include/clang/AST/StmtIterator.h @@ -104,12 +104,13 @@ class StmtIteratorImpl : public StmtIteratorBase, return tmp; } - bool operator==(const DERIVED& RHS) const { -return stmt == RHS.stmt && DGI == RHS.DGI && RawVAPtr == RHS.RawVAPtr; + friend bool operator==(const DERIVED &LHS, const DERIVED &RHS) { +return LHS.stmt == RHS.stmt && LHS.DGI == RHS.DGI && + LHS.RawVAPtr == RHS.RawVAPtr; } - bool operator!=(const DERIVED& RHS) const { -return stmt != RHS.stmt || DGI != RHS.DGI || RawVAPtr != RHS.RawVAPtr; + friend bool operator!=(const DERIVED &LHS, const DERIVED &RHS) { +return !(LHS == RHS); } REFERENCE operator*() const { diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp index c4aa361b8262..db7e967b15ae 100644 --- a/clang/lib/Parse/ParseOpenMP.cpp +++ b/clang/lib/Parse/ParseOpenMP.cpp @@ -61,6 +61,12 @@ enum OpenMPDirectiveKindEx { struct OpenMPDirectiveKindExWrapper { OpenMPDirectiveKindExWrapper(unsigned Value) : Value(Value) {} OpenMPDirectiveKindE
[clang] 57ba07c - [clang] fix typo in unit test
Author: Susana Monteiro Date: 2022-10-18T16:32:13+01:00 New Revision: 57ba07c06f8b68d401f47ab115259fa2dd3d7136 URL: https://github.com/llvm/llvm-project/commit/57ba07c06f8b68d401f47ab115259fa2dd3d7136 DIFF: https://github.com/llvm/llvm-project/commit/57ba07c06f8b68d401f47ab115259fa2dd3d7136.diff LOG: [clang] fix typo in unit test Added: Modified: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp Removed: diff --git a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp index bf06953394692..96f87a8ed555d 100644 --- a/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp @@ -462,7 +462,7 @@ TEST_F(JoinFlowConditionsTest, JoinDistinctButProvablyEquivalentValues) { EXPECT_FALSE(Env1.flowConditionImplies(*GetFooValue(Env1))); EXPECT_TRUE(Env2.flowConditionImplies(*GetFooValue(Env2))); EXPECT_TRUE(Env3.flowConditionImplies(*GetFooValue(Env3))); -EXPECT_TRUE(Env4.flowConditionImplies(*GetFooValue(Env3))); +EXPECT_TRUE(Env4.flowConditionImplies(*GetFooValue(Env4))); }); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 14e2592 - [clang][CodeGen] Use poison instead of undef as placeholder in ARM builtins [NFC]
Author: Manuel Brito Date: 2022-10-07T12:50:59+01:00 New Revision: 14e2592ff6112d1869ba1533d058822200162bf1 URL: https://github.com/llvm/llvm-project/commit/14e2592ff6112d1869ba1533d058822200162bf1 DIFF: https://github.com/llvm/llvm-project/commit/14e2592ff6112d1869ba1533d058822200162bf1.diff LOG: [clang][CodeGen] Use poison instead of undef as placeholder in ARM builtins [NFC] Differential Revision: https://reviews.llvm.org/D135392 Added: Modified: clang/lib/CodeGen/CGBuiltin.cpp clang/test/CodeGen/PowerPC/builtins-ppc-int128.c clang/test/CodeGen/aarch64-bf16-ldst-intrinsics.c clang/test/CodeGen/aarch64-neon-intrinsics.c clang/test/CodeGen/aarch64-neon-ldst-one.c clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq-bfloat.c clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c clang/test/CodeGen/arm-mve-intrinsics/vld24.c clang/test/CodeGen/arm_neon_intrinsics.c Removed: diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 786ed8c5935f9..81fa7b27541c5 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -6861,7 +6861,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr( } case NEON::BI__builtin_neon_vld1_dup_v: case NEON::BI__builtin_neon_vld1q_dup_v: { -Value *V = UndefValue::get(Ty); +Value *V = PoisonValue::get(Ty); PtrOp0 = Builder.CreateElementBitCast(PtrOp0, VTy->getElementType()); LoadInst *Ld = Builder.CreateLoad(PtrOp0); llvm::Constant *CI = ConstantInt::get(SizeTy, 0); @@ -8303,7 +8303,7 @@ Value *CodeGenFunction::EmitARMMVEBuiltinExpr(unsigned BuiltinID, Function *F = CGM.getIntrinsic(IRIntr, makeArrayRef(Tys)); Value *LoadResult = Builder.CreateCall(F, Ops); -Value *MvecOut = UndefValue::get(MvecLType); +Value *MvecOut = PoisonValue::get(MvecLType); for (unsigned i = 0; i < NumVectors; ++i) { Value *Vec = Builder.CreateExtractValue(LoadResult, i); MvecOut = Builder.CreateInsertValue(MvecOut, Vec, {0, i}); @@ -8518,7 +8518,7 @@ static Value *EmitAArch64TblBuiltinExpr(CodeGenFunction &CGF, unsigned BuiltinID Value *CodeGenFunction::vectorWrapScalar16(Value *Op) { auto *VTy = llvm::FixedVectorType::get(Int16Ty, 4); Op = Builder.CreateBitCast(Op, Int16Ty); - Value *V = UndefValue::get(VTy); + Value *V = PoisonValue::get(VTy); llvm::Constant *CI = ConstantInt::get(SizeTy, 0); Op = Builder.CreateInsertElement(V, Op, CI); return Op; @@ -11692,7 +11692,7 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, } case NEON::BI__builtin_neon_vld1_dup_v: case NEON::BI__builtin_neon_vld1q_dup_v: { -Value *V = UndefValue::get(Ty); +Value *V = PoisonValue::get(Ty); Ty = llvm::PointerType::getUnqual(VTy->getElementType()); Ops[0] = Builder.CreateBitCast(Ops[0], Ty); Ops[0] = Builder.CreateAlignedLoad(VTy->getElementType(), Ops[0], @@ -12090,7 +12090,7 @@ BuildVector(ArrayRef Ops) { } // Otherwise, insertelement the values to build the vector. - Value *Result = llvm::UndefValue::get( + Value *Result = llvm::PoisonValue::get( llvm::FixedVectorType::get(Ops[0]->getType(), Ops.size())); for (unsigned i = 0, e = Ops.size(); i != e; ++i) @@ -16143,10 +16143,10 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID, Value *Op0 = EmitScalarExpr(E->getArg(0)); Value *Op1 = EmitScalarExpr(E->getArg(1)); bool isLittleEndian = getTarget().isLittleEndian(); -Value *UndefValue = -llvm::UndefValue::get(llvm::FixedVectorType::get(Op0->getType(), 2)); +Value *PoisonValue = +llvm::PoisonValue::get(llvm::FixedVectorType::get(Op0->getType(), 2)); Value *Res = Builder.CreateInsertElement( -UndefValue, Op0, (uint64_t)(isLittleEndian ? 1 : 0)); +PoisonValue, Op0, (uint64_t)(isLittleEndian ? 1 : 0)); Res = Builder.CreateInsertElement(Res, Op1, (uint64_t)(isLittleEndian ? 0 : 1)); return Builder.CreateBitCast(Res, ConvertType(E->getType())); diff --git a/clang/test/CodeGen/PowerPC/builtins-ppc-int128.c b/clang/test/CodeGen/PowerPC/builtins-ppc-int128.c index 52d705589a893..2b8221c725e66 100644 --- a/clang/test/CodeGen/PowerPC/builtins-ppc-int128.c +++ b/clang/test/CodeGen/PowerPC/builtins-ppc-int128.c @@ -15,11 +15,11 @@ void testVectorInt128Pack(){ // CHECK-LABEL: testVectorInt128Pack // CHECK-LABEL-LE: testVectorInt128Pack res_vslll = __builtin_pack_vector_int128(aull[0], aull[1]); -// CHECK: %[[V1:[0-9]+]] = insertelement <2 x i64> undef, i64 %{{[0-9]+}}, i64 0 +// CHECK: %[[V1:[0-9]+]] = insertelement <2 x i64> poison, i64 %{{[0-9]+}}, i64 0 // CHECK-NEXT: %[[V2:[0-9]+]] = insertelement <2 x i64> %[[V1]], i64 %{{[0-9]+}}, i64 1 // CHECK-NEXT: bitcast <2 x i64> %[[V2]] to
[clang] 4dd1bff - [clang][CodeGen] Switch a few placeholders from UndefValue to PoisonValue
Author: Nuno Lopes Date: 2022-06-12T19:07:59+01:00 New Revision: 4dd1bffc9dac02b34bd1de78808edd9a5955c987 URL: https://github.com/llvm/llvm-project/commit/4dd1bffc9dac02b34bd1de78808edd9a5955c987 DIFF: https://github.com/llvm/llvm-project/commit/4dd1bffc9dac02b34bd1de78808edd9a5955c987.diff LOG: [clang][CodeGen] Switch a few placeholders from UndefValue to PoisonValue This change is cosmetic, as these are dummy values that are not observable, but it gets us closer to removing undef. NFC Added: Modified: clang/lib/CodeGen/CGCall.cpp clang/lib/CodeGen/ConstantInitBuilder.cpp clang/test/CodeGen/arm-swiftcall.c clang/test/CodeGen/cmse-clear-arg.c clang/test/CodeGen/windows-swiftcall.c clang/test/CodeGenCXX/arm-swiftcall.cpp Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 0d838b9aeb529..57eb8b2d93d26 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -3466,7 +3466,7 @@ llvm::Value *CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src, int CharsPerElt = ATy->getArrayElementType()->getScalarSizeInBits() / CharWidth; int MaskIndex = 0; - llvm::Value *R = llvm::UndefValue::get(ATy); + llvm::Value *R = llvm::PoisonValue::get(ATy); for (int I = 0, N = ATy->getArrayNumElements(); I != N; ++I) { uint64_t Mask = buildMultiCharMask(Bits, MaskIndex, CharsPerElt, CharWidth, DataLayout.isBigEndian()); @@ -3640,7 +3640,7 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI, // Construct a return type that lacks padding elements. llvm::Type *returnType = RetAI.getUnpaddedCoerceAndExpandType(); - RV = llvm::UndefValue::get(returnType); + RV = llvm::PoisonValue::get(returnType); for (unsigned i = 0, e = results.size(); i != e; ++i) { RV = Builder.CreateInsertValue(RV, results[i], i); } @@ -3747,7 +3747,7 @@ static AggValueSlot createPlaceholderSlot(CodeGenFunction &CGF, // placeholders. llvm::Type *IRTy = CGF.ConvertTypeForMem(Ty); llvm::Type *IRPtrTy = IRTy->getPointerTo(); - llvm::Value *Placeholder = llvm::UndefValue::get(IRPtrTy->getPointerTo()); + llvm::Value *Placeholder = llvm::PoisonValue::get(IRPtrTy->getPointerTo()); // FIXME: When we generate this IR in one pass, we shouldn't need // this win32-specific alignment hack. diff --git a/clang/lib/CodeGen/ConstantInitBuilder.cpp b/clang/lib/CodeGen/ConstantInitBuilder.cpp index 24e3ca19709cb..06d3e44f01b1a 100644 --- a/clang/lib/CodeGen/ConstantInitBuilder.cpp +++ b/clang/lib/CodeGen/ConstantInitBuilder.cpp @@ -114,7 +114,7 @@ void ConstantInitBuilderBase::abandon(size_t newEnd) { if (newEnd == 0) { for (auto &entry : SelfReferences) { auto dummy = entry.Dummy; - dummy->replaceAllUsesWith(llvm::UndefValue::get(dummy->getType())); + dummy->replaceAllUsesWith(llvm::PoisonValue::get(dummy->getType())); dummy->eraseFromParent(); } SelfReferences.clear(); diff --git a/clang/test/CodeGen/arm-swiftcall.c b/clang/test/CodeGen/arm-swiftcall.c index bd85e7a9aed04..000602819ee01 100644 --- a/clang/test/CodeGen/arm-swiftcall.c +++ b/clang/test/CodeGen/arm-swiftcall.c @@ -121,7 +121,7 @@ TEST(struct_1); // CHECK: [[THIRD:%.*]] = load float, float* [[T0]], align // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 4 // CHECK: [[FOURTH:%.*]] = load float, float* [[T0]], align -// CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ i32, i16, float, float }]] undef, i32 [[FIRST]], 0 +// CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ i32, i16, float, float }]] poison, i32 [[FIRST]], 0 // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i16 [[SECOND]], 1 // CHECK: [[T2:%.*]] = insertvalue [[UAGG]] [[T1]], float [[THIRD]], 2 // CHECK: [[T3:%.*]] = insertvalue [[UAGG]] [[T2]], float [[FOURTH]], 3 @@ -186,7 +186,7 @@ TEST(struct_2); // CHECK: [[THIRD:%.*]] = load float, float* [[T0]], align // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 3 // CHECK: [[FOURTH:%.*]] = load float, float* [[T0]], align -// CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ i32, i32, float, float }]] undef, i32 [[FIRST]], 0 +// CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ i32, i32, float, float }]] poison, i32 [[FIRST]], 0 // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1 // CHECK: [[T2:%.*]] = insertvalue [[UAGG]] [[T1]], float [[THIRD]], 2 // CHECK: [[T3:%.*]] = insertvalue [[UAGG]] [[T2]], float [[FOURTH]], 3 @@ -250,7 +250,7 @@ TEST(struct_misaligned_1) // CHECK: [[FIRST:%.*]] = load i32, i32* [[T0]], align // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1 // CHECK: [[SECOND:%.*]] = load i8, i8* [[T0]], align -// CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ i3
[clang] 571ae1a - fix test expected output (fixes arm buildbot failure) [NFC]
Author: Nuno Lopes Date: 2022-06-12T19:29:00+01:00 New Revision: 571ae1abebb6b102cc2e95e3abf8e81757fba35a URL: https://github.com/llvm/llvm-project/commit/571ae1abebb6b102cc2e95e3abf8e81757fba35a DIFF: https://github.com/llvm/llvm-project/commit/571ae1abebb6b102cc2e95e3abf8e81757fba35a.diff LOG: fix test expected output (fixes arm buildbot failure) [NFC] Added: Modified: clang/test/CodeGen/64bit-swiftcall.c Removed: diff --git a/clang/test/CodeGen/64bit-swiftcall.c b/clang/test/CodeGen/64bit-swiftcall.c index a027129a4bbb..f1fb8e10dc0a 100644 --- a/clang/test/CodeGen/64bit-swiftcall.c +++ b/clang/test/CodeGen/64bit-swiftcall.c @@ -125,7 +125,7 @@ TEST(struct_1); // CHECK: [[T0:%.*]] = load i64, i64* [[GEP0]], align 4 // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 1 // CHECK: [[T1:%.*]] = load i64, i64* [[GEP1]], align 4 -// CHECK: [[R0:%.*]] = insertvalue { i64, i64 } undef, i64 [[T0]], 0 +// CHECK: [[R0:%.*]] = insertvalue { i64, i64 } poison, i64 [[T0]], 0 // CHECK: [[R1:%.*]] = insertvalue { i64, i64 } [[R0]], i64 [[T1]], 1 // CHECK: ret { i64, i64 } [[R1]] // CHECK: } @@ -174,7 +174,7 @@ TEST(struct_2); // CHECK: [[T0:%.*]] = load i64, i64* [[GEP0]], align 4 // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 1 // CHECK: [[T1:%.*]] = load i64, i64* [[GEP1]], align 4 -// CHECK: [[R0:%.*]] = insertvalue { i64, i64 } undef, i64 [[T0]], 0 +// CHECK: [[R0:%.*]] = insertvalue { i64, i64 } poison, i64 [[T0]], 0 // CHECK: [[R1:%.*]] = insertvalue { i64, i64 } [[R0]], i64 [[T1]], 1 // CHECK: ret { i64, i64 } [[R1]] // CHECK: } @@ -395,7 +395,7 @@ TEST(int8) // CHECK: [[FIRST:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1 // CHECK: [[SECOND:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align -// CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, <4 x i32> }]] undef, <4 x i32> [[FIRST]], 0 +// CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, <4 x i32> }]] poison, <4 x i32> [[FIRST]], 0 // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], <4 x i32> [[SECOND]], 1 // CHECK: ret [[UAGG]] [[T1]] // CHECK-LABEL: define {{.*}} @take_int8(<4 x i32> %0, <4 x i32> %1) @@ -439,7 +439,7 @@ TEST(int5) // CHECK: [[FIRST:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1 // CHECK: [[SECOND:%.*]] = load i32, i32* [[T0]], align -// CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, i32 }]] undef, <4 x i32> [[FIRST]], 0 +// CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, i32 }]] poison, <4 x i32> [[FIRST]], 0 // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1 // CHECK: ret [[UAGG]] [[T1]] // CHECK-LABEL: define {{.*}} @take_int5(<4 x i32> %0, i32 %1) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Better bitfield access units (PR #65742)
nunoplopes wrote: Note that changing the memory accesses performed by clang (load or store) *is* an ABI change at IR level because of UB. Also, please have a look at the existing `-ffine-grained-bitfield-accesses` flag and the discussions around it and IPO. https://github.com/llvm/llvm-project/pull/65742 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CodeGen] Switch declaration of vtable information to be [0 x ptr] (PR #65596)
https://github.com/nunoplopes updated https://github.com/llvm/llvm-project/pull/65596: >From 8585d37c6526d46e08efb2b573ca9ba50dd68a9b Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 7 Sep 2023 11:07:03 +0100 Subject: [PATCH 1/2] [clang][CodeGen] Switch declaration of vtable information to be [0 x ptr] Before we had this code: @_ZTVN10__cxxabiv117__class_type_infoE = external global ptr now we'll produce: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr] This is because we may not know the exact size of this data, and clang issues gep inbounds with idx=2. Before, that gep would always result in poison. --- clang/lib/CodeGen/ItaniumCXXABI.cpp| 7 --- .../RelativeVTablesABI/child-vtable-in-comdat.cpp | 2 +- .../RelativeVTablesABI/parent-vtable-in-comdat.cpp | 2 +- .../RelativeVTablesABI/simple-vtable-definition.cpp| 2 +- clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp | 4 ++-- clang/test/CodeGenCXX/typeinfo-with-address-space.cpp | 4 ++-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index d64287ddf1217cb..58fb3defa830aad 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -3669,9 +3669,10 @@ void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) { // Check if the alias exists. If it doesn't, then get or create the global. if (CGM.getItaniumVTableContext().isRelativeLayout()) VTable = CGM.getModule().getNamedAlias(VTableName); - if (!VTable) -VTable = -CGM.getModule().getOrInsertGlobal(VTableName, CGM.GlobalsInt8PtrTy); + if (!VTable) { +llvm::Type *Ty = llvm::ArrayType::get(CGM.VoidPtrTy, 0); +VTable = CGM.getModule().getOrInsertGlobal(VTableName, Ty); + } CGM.setDSOLocal(cast(VTable->stripPointerCasts())); diff --git a/clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp index f7d7bc0e94a08f0..48b1d8ed65d7e55 100644 --- a/clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp +++ b/clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp @@ -14,7 +14,7 @@ // CHECK-DAG: @_ZTV1B.local = linkonce_odr hidden unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1B.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1B.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1B3fooEv to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1B.local, i32 0, i32 0, i32 2) to i64)) to i32)] }, comdat($_ZTV1B), align 4 // The RTTI objects aren’t that important, but it is good to know that they are emitted here since they are used in the vtable for B, and external references are used for RTTI stuff from A. -// CHECK-DAG: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global ptr +// CHECK-DAG: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global [0 x ptr] // CHECK-DAG: @_ZTS1B = // CHECK-DAG: @_ZTI1A = // CHECK-DAG: @_ZTI1B = diff --git a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp index f9e3382c489b4e1..5f5f9edf411a809 100644 --- a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp +++ b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp @@ -15,7 +15,7 @@ // The VTable for A is emitted here and in a comdat section since it has no key function, and is used in this module when creating an instance of A. // CHECK: @_ZTV1A.local = linkonce_odr hidden unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1A.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1A3fooEv to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32)] }, comdat($_ZTV1A), align 4 -// CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global ptr +// CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr] // CHECK: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", comdat, align 1 // CHECK: @_ZTI1A = linkonce_odr constant { ptr, ptr } { ptr getelementptr inbounds (i8, ptr @_ZTVN10__cxxabiv117__class_type_infoE, i32 8), ptr @_ZTS1A }, comdat, align 8 // CHECK: @_ZTI1A.rtti_proxy = hidden unnamed_addr constant ptr @_ZTI1A, comdat diff --git a/clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/simple-vtable-definition.cpp index a59d47dc816c03f..76de83d9d2cd466 100644 --- a/clang/test/CodeGenCXX/RelativeV
[clang] [clang][CodeGen] Switch declaration of vtable information to be [0 x ptr] (PR #65596)
@@ -14,8 +14,8 @@ class B : A { // NO-AS: @_ZTISt9type_info = external constant ptr // AS: @_ZTIi = external addrspace(1) constant ptr addrspace(1) // NO-AS: @_ZTIi = external constant ptr -// AS: @_ZTVN10__cxxabiv117__class_type_infoE = external addrspace(1) global ptr addrspace(1) -// NO-AS: @_ZTVN10__cxxabiv117__class_type_infoE = external global ptr +// AS: @_ZTVN10__cxxabiv117__class_type_infoE = external addrspace(1) global [0 x ptr] nunoplopes wrote: ok, changed! https://github.com/llvm/llvm-project/pull/65596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CodeGen] Switch declaration of vtable information to be [0 x ptr] (PR #65596)
https://github.com/nunoplopes closed https://github.com/llvm/llvm-project/pull/65596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CodeGen] Switch declaration of vtable information to be [0 x ptr] (PR #65596)
https://github.com/nunoplopes created https://github.com/llvm/llvm-project/pull/65596: Continuing the discussion in https://discourse.llvm.org/t/codegen-layout-of-si-class-type-info-doesnt-match-the-actual-size/73274 Before we had this code: @_ZTVN10__cxxabiv117__class_type_infoE = external global ptr now we'll produce: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr] This is because we may not know the exact size of this data, and clang issues gep inbounds with idx=2. Before, that gep would always result in poison. >From 8585d37c6526d46e08efb2b573ca9ba50dd68a9b Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 7 Sep 2023 11:07:03 +0100 Subject: [PATCH] [clang][CodeGen] Switch declaration of vtable information to be [0 x ptr] Before we had this code: @_ZTVN10__cxxabiv117__class_type_infoE = external global ptr now we'll produce: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr] This is because we may not know the exact size of this data, and clang issues gep inbounds with idx=2. Before, that gep would always result in poison. --- clang/lib/CodeGen/ItaniumCXXABI.cpp| 7 --- .../RelativeVTablesABI/child-vtable-in-comdat.cpp | 2 +- .../RelativeVTablesABI/parent-vtable-in-comdat.cpp | 2 +- .../RelativeVTablesABI/simple-vtable-definition.cpp| 2 +- clang/test/CodeGenCXX/RelativeVTablesABI/type-info.cpp | 4 ++-- clang/test/CodeGenCXX/typeinfo-with-address-space.cpp | 4 ++-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index d64287ddf1217cb..58fb3defa830aad 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -3669,9 +3669,10 @@ void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) { // Check if the alias exists. If it doesn't, then get or create the global. if (CGM.getItaniumVTableContext().isRelativeLayout()) VTable = CGM.getModule().getNamedAlias(VTableName); - if (!VTable) -VTable = -CGM.getModule().getOrInsertGlobal(VTableName, CGM.GlobalsInt8PtrTy); + if (!VTable) { +llvm::Type *Ty = llvm::ArrayType::get(CGM.VoidPtrTy, 0); +VTable = CGM.getModule().getOrInsertGlobal(VTableName, Ty); + } CGM.setDSOLocal(cast(VTable->stripPointerCasts())); diff --git a/clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp index f7d7bc0e94a08f0..48b1d8ed65d7e55 100644 --- a/clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp +++ b/clang/test/CodeGenCXX/RelativeVTablesABI/child-vtable-in-comdat.cpp @@ -14,7 +14,7 @@ // CHECK-DAG: @_ZTV1B.local = linkonce_odr hidden unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1B.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1B.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1B3fooEv to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1B.local, i32 0, i32 0, i32 2) to i64)) to i32)] }, comdat($_ZTV1B), align 4 // The RTTI objects aren’t that important, but it is good to know that they are emitted here since they are used in the vtable for B, and external references are used for RTTI stuff from A. -// CHECK-DAG: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global ptr +// CHECK-DAG: @_ZTVN10__cxxabiv120__si_class_type_infoE = external global [0 x ptr] // CHECK-DAG: @_ZTS1B = // CHECK-DAG: @_ZTI1A = // CHECK-DAG: @_ZTI1B = diff --git a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp index f9e3382c489b4e1..5f5f9edf411a809 100644 --- a/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp +++ b/clang/test/CodeGenCXX/RelativeVTablesABI/parent-vtable-in-comdat.cpp @@ -15,7 +15,7 @@ // The VTable for A is emitted here and in a comdat section since it has no key function, and is used in this module when creating an instance of A. // CHECK: @_ZTV1A.local = linkonce_odr hidden unnamed_addr constant { [3 x i32] } { [3 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint (ptr @_ZTI1A.rtti_proxy to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @_ZN1A3fooEv to i64), i64 ptrtoint (ptr getelementptr inbounds ({ [3 x i32] }, ptr @_ZTV1A.local, i32 0, i32 0, i32 2) to i64)) to i32)] }, comdat($_ZTV1A), align 4 -// CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global ptr +// CHECK: @_ZTVN10__cxxabiv117__class_type_infoE = external global [0 x ptr] // CHECK: @_ZTS1A = linkonce_odr constant [3 x i8] c"1A\00", comdat, align 1 // CHECK: @_ZTI1A = linkonce_odr constan
[clang] [clang][CodeGen] Switch declaration of vtable information to be [0 x ptr] (PR #65596)
https://github.com/nunoplopes review_requested https://github.com/llvm/llvm-project/pull/65596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][CodeGen] Switch declaration of vtable information to be [0 x ptr] (PR #65596)
https://github.com/nunoplopes review_requested https://github.com/llvm/llvm-project/pull/65596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2389488 - [NFC][clang] Strengthen checks in avx512f-builtins.c
Author: John McIver Date: 2022-12-04T14:55:41Z New Revision: 23894884377372d2ea048b452bf9a68de3e8515a URL: https://github.com/llvm/llvm-project/commit/23894884377372d2ea048b452bf9a68de3e8515a DIFF: https://github.com/llvm/llvm-project/commit/23894884377372d2ea048b452bf9a68de3e8515a.diff LOG: [NFC][clang] Strengthen checks in avx512f-builtins.c * Add check to unnamed portion of nontemporal attribute * Add end-of-line check to load instructions Added: Modified: clang/test/CodeGen/X86/avx512f-builtins.c Removed: diff --git a/clang/test/CodeGen/X86/avx512f-builtins.c b/clang/test/CodeGen/X86/avx512f-builtins.c index 8a0c273415275..12a406455d5ad 100644 --- a/clang/test/CodeGen/X86/avx512f-builtins.c +++ b/clang/test/CodeGen/X86/avx512f-builtins.c @@ -207,8 +207,8 @@ void test_mm512_mask_store_ps(void *p, __m512 a, __mmask16 m) void test_mm512_store_si512 (void *__P, __m512i __A) { // CHECK-LABEL: @test_mm512_store_si512 - // CHECK: load <8 x i64>, <8 x i64>* %__A.addr.i, align 64 - // CHECK: [[SI512_3:%.+]] = load i8*, i8** %__P.addr.i, align 8 + // CHECK: load <8 x i64>, <8 x i64>* %__A.addr.i, align 64{{$}} + // CHECK: [[SI512_3:%.+]] = load i8*, i8** %__P.addr.i, align 8{{$}} // CHECK: bitcast i8* [[SI512_3]] to <8 x i64>* // CHECK: store <8 x i64> _mm512_store_si512 ( __P,__A); @@ -217,8 +217,8 @@ void test_mm512_store_si512 (void *__P, __m512i __A) void test_mm512_store_epi32 (void *__P, __m512i __A) { // CHECK-LABEL: @test_mm512_store_epi32 - // CHECK: load <8 x i64>, <8 x i64>* %__A.addr.i, align 64 - // CHECK: [[Si32_3:%.+]] = load i8*, i8** %__P.addr.i, align 8 + // CHECK: load <8 x i64>, <8 x i64>* %__A.addr.i, align 64{{$}} + // CHECK: [[Si32_3:%.+]] = load i8*, i8** %__P.addr.i, align 8{{$}} // CHECK: bitcast i8* [[Si32_3]] to <8 x i64>* // CHECK: store <8 x i64> _mm512_store_epi32 ( __P,__A); @@ -227,8 +227,8 @@ void test_mm512_store_epi32 (void *__P, __m512i __A) void test_mm512_store_epi64 (void *__P, __m512i __A) { // CHECK-LABEL: @test_mm512_store_epi64 - // CHECK: load <8 x i64>, <8 x i64>* %__A.addr.i, align 64 - // CHECK: [[SI64_3:%.+]] = load i8*, i8** %__P.addr.i, align 8 + // CHECK: load <8 x i64>, <8 x i64>* %__A.addr.i, align 64{{$}} + // CHECK: [[SI64_3:%.+]] = load i8*, i8** %__P.addr.i, align 8{{$}} // CHECK: bitcast i8* [[SI64_3]] to <8 x i64>* // CHECK: store <8 x i64> _mm512_store_epi64 ( __P,__A); @@ -359,34 +359,34 @@ __m512d test_mm512_mask_loadu_pd (__m512d __W, __mmask8 __U, void *__P) __m512i test_mm512_load_si512 (void *__P) { // CHECK-LABEL: @test_mm512_load_si512 - // CHECK: [[LI512_1:%.+]] = load i8*, i8** %__P.addr.i, align 8 + // CHECK: [[LI512_1:%.+]] = load i8*, i8** %__P.addr.i, align 8{{$}} // CHECK: [[LI512_2:%.+]] = bitcast i8* [[LI512_1]] to <8 x i64>* - // CHECK: load <8 x i64>, <8 x i64>* [[LI512_2]], align 64 + // CHECK: load <8 x i64>, <8 x i64>* [[LI512_2]], align 64{{$}} return _mm512_load_si512 ( __P); } __m512i test_mm512_load_epi32 (void *__P) { // CHECK-LABEL: @test_mm512_load_epi32 - // CHECK: [[LI32_1:%.+]] = load i8*, i8** %__P.addr.i, align 8 + // CHECK: [[LI32_1:%.+]] = load i8*, i8** %__P.addr.i, align 8{{$}} // CHECK: [[LI32_2:%.+]] = bitcast i8* [[LI32_1]] to <8 x i64>* - // CHECK: load <8 x i64>, <8 x i64>* [[LI32_2]], align 64 + // CHECK: load <8 x i64>, <8 x i64>* [[LI32_2]], align 64{{$}} return _mm512_load_epi32 ( __P); } __m512i test_mm512_load_epi64 (void *__P) { // CHECK-LABEL: @test_mm512_load_epi64 - // CHECK: [[LI64_1:%.+]] = load i8*, i8** %__P.addr.i, align 8 + // CHECK: [[LI64_1:%.+]] = load i8*, i8** %__P.addr.i, align 8{{$}} // CHECK: [[LI64_2:%.+]] = bitcast i8* [[LI64_1]] to <8 x i64>* - // CHECK: load <8 x i64>, <8 x i64>* [[LI64_2]], align 64 + // CHECK: load <8 x i64>, <8 x i64>* [[LI64_2]], align 64{{$}} return _mm512_load_epi64 ( __P); } __m512 test_mm512_load_ps(void *p) { // CHECK-LABEL: @test_mm512_load_ps - // CHECK: load <16 x float>, <16 x float>* %{{.*}}, align 64 + // CHECK: load <16 x float>, <16 x float>* %{{.*}}, align 64{{$}} return _mm512_load_ps(p); } @@ -407,7 +407,7 @@ __m512 test_mm512_maskz_load_ps(__mmask16 __U, void *__P) __m512d test_mm512_load_pd(void *p) { // CHECK-LABEL: @test_mm512_load_pd - // CHECK: load <8 x double>, <8 x double>* %{{.*}}, align 64 + // CHECK: load <8 x double>, <8 x double>* %{{.*}}, align 64{{$}} return _mm512_load_pd(p); } @@ -4610,7 +4610,7 @@ __m128 test_mm_getmant_ss(__m128 __A, __m128 __B) { __mmask16 test_mm512_kmov(__mmask16 __A) { // CHECK-LABEL: @test_mm512_kmov - // CHECK: load i16, i16* %__A.addr.i, align 2 + // CHECK: load i16, i16* %__A.addr.i, align 2{{$}} return _mm512_kmov(__A); } @@ -8525,7 +8525,7 @@ __mmask16 test_cvtu32_mask16(__m512i A, __m512i B, unsigned int C) { __mmask16 test_lo
[clang] ee13633 - [NFC][clang] Strengthen checks in avx512fp16-builtins.c
Author: John McIver Date: 2022-12-04T14:57:43Z New Revision: ee13633c46cda3826d384d60c85057085025eebb URL: https://github.com/llvm/llvm-project/commit/ee13633c46cda3826d384d60c85057085025eebb DIFF: https://github.com/llvm/llvm-project/commit/ee13633c46cda3826d384d60c85057085025eebb.diff LOG: [NFC][clang] Strengthen checks in avx512fp16-builtins.c * Add end-of-line check to load instructions Added: Modified: clang/test/CodeGen/X86/avx512fp16-builtins.c Removed: diff --git a/clang/test/CodeGen/X86/avx512fp16-builtins.c b/clang/test/CodeGen/X86/avx512fp16-builtins.c index c3cf59a8705b..7bd4b2aac38b 100644 --- a/clang/test/CodeGen/X86/avx512fp16-builtins.c +++ b/clang/test/CodeGen/X86/avx512fp16-builtins.c @@ -1473,19 +1473,19 @@ __m128h test_mm_maskz_load_sh(__mmask8 __U, const void *__W) { __m512h test_mm512_load_ph(void *p) { // CHECK-LABEL: @test_mm512_load_ph - // CHECK: load <32 x half>, <32 x half>* %{{.*}}, align 64 + // CHECK: load <32 x half>, <32 x half>* %{{.*}}, align 64{{$}} return _mm512_load_ph(p); } __m256h test_mm256_load_ph(void *p) { // CHECK-LABEL: @test_mm256_load_ph - // CHECK: load <16 x half>, <16 x half>* %{{.*}}, align 32 + // CHECK: load <16 x half>, <16 x half>* %{{.*}}, align 32{{$}} return _mm256_load_ph(p); } __m128h test_mm_load_ph(void *p) { // CHECK-LABEL: @test_mm_load_ph - // CHECK: load <8 x half>, <8 x half>* %{{.*}}, align 16 + // CHECK: load <8 x half>, <8 x half>* %{{.*}}, align 16{{$}} return _mm_load_ph(p); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 64428c0 - [NFC][clang] Strengthen checks in matrix-type-operators.cpp
Author: John McIver Date: 2022-12-05T10:12:25Z New Revision: 64428c0ddf55295c270569db7f581ac7bedeff87 URL: https://github.com/llvm/llvm-project/commit/64428c0ddf55295c270569db7f581ac7bedeff87 DIFF: https://github.com/llvm/llvm-project/commit/64428c0ddf55295c270569db7f581ac7bedeff87.diff LOG: [NFC][clang] Strengthen checks in matrix-type-operators.cpp * Add tbaa attribute checks * Add end-of-line check to load instructions Added: Modified: clang/test/CodeGenCXX/matrix-type-operators.cpp Removed: diff --git a/clang/test/CodeGenCXX/matrix-type-operators.cpp b/clang/test/CodeGenCXX/matrix-type-operators.cpp index db10e2d9ce41d..d5d7e2d30a7d5 100644 --- a/clang/test/CodeGenCXX/matrix-type-operators.cpp +++ b/clang/test/CodeGenCXX/matrix-type-operators.cpp @@ -1,6 +1,5 @@ -// RUN: %clang_cc1 -O0 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - -std=c++11 | FileCheck %s +// RUN: %clang_cc1 -O0 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - -std=c++11 | FileCheck --check-prefixes=CHECK,NOOPT %s // RUN: %clang_cc1 -O1 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - -std=c++11 | FileCheck --check-prefixes=CHECK,OPT %s - typedef double dx5x5_t __attribute__((matrix_type(5, 5))); using fx2x3_t = float __attribute__((matrix_type(2, 3))); @@ -21,8 +20,10 @@ void test_add_template() { // CHECK: %call = call noundef <10 x float> @_Z3addIfLj2ELj5EEN8MyMatrixIT_XT0_EXT1_EE8matrix_tERS2_S4_(ptr noundef nonnull align 4 dereferenceable(40) %Mat1, ptr noundef nonnull align 4 dereferenceable(40) %Mat2) // CHECK-LABEL: define linkonce_odr noundef <10 x float> @_Z3addIfLj2ELj5EEN8MyMatrixIT_XT0_EXT1_EE8matrix_tERS2_S4_( - // CHECK: [[MAT1:%.*]] = load <10 x float>, ptr {{.*}}, align 4 - // CHECK: [[MAT2:%.*]] = load <10 x float>, ptr {{.*}}, align 4 + // NOOPT: [[MAT1:%.*]] = load <10 x float>, ptr {{.*}}, align 4{{$}} + // NOOPT: [[MAT2:%.*]] = load <10 x float>, ptr {{.*}}, align 4{{$}} + // OPT: [[MAT1:%.*]] = load <10 x float>, ptr {{.*}}, align 4, !tbaa !{{[0-9]+}}{{$}} + // OPT: [[MAT2:%.*]] = load <10 x float>, ptr {{.*}}, align 4, !tbaa !{{[0-9]+}}{{$}} // CHECK-NEXT: [[RES:%.*]] = fadd <10 x float> [[MAT1]], [[MAT2]] // CHECK-NEXT: ret <10 x float> [[RES]] @@ -41,8 +42,10 @@ void test_subtract_template() { // CHECK: %call = call noundef <10 x float> @_Z8subtractIfLj2ELj5EEN8MyMatrixIT_XT0_EXT1_EE8matrix_tERS2_S4_(ptr noundef nonnull align 4 dereferenceable(40) %Mat1, ptr noundef nonnull align 4 dereferenceable(40) %Mat2) // CHECK-LABEL: define linkonce_odr noundef <10 x float> @_Z8subtractIfLj2ELj5EEN8MyMatrixIT_XT0_EXT1_EE8matrix_tERS2_S4_( - // CHECK: [[MAT1:%.*]] = load <10 x float>, ptr {{.*}}, align 4 - // CHECK: [[MAT2:%.*]] = load <10 x float>, ptr {{.*}}, align 4 + // NOOPT: [[MAT1:%.*]] = load <10 x float>, ptr {{.*}}, align 4{{$}} + // NOOPT: [[MAT2:%.*]] = load <10 x float>, ptr {{.*}}, align 4{{$}} + // OPT: [[MAT1:%.*]] = load <10 x float>, ptr {{.*}}, align 4, !tbaa !{{[0-9]+}}{{$}} + // OPT: [[MAT2:%.*]] = load <10 x float>, ptr {{.*}}, align 4, !tbaa !{{[0-9]+}}{{$}} // CHECK-NEXT: [[RES:%.*]] = fsub <10 x float> [[MAT1]], [[MAT2]] // CHECK-NEXT: ret <10 x float> [[RES]] @@ -60,8 +63,9 @@ struct DoubleWrapper1 { void test_DoubleWrapper1_Sub1(MyMatrix &m) { // CHECK-LABEL: define{{.*}} void @_Z24test_DoubleWrapper1_Sub1R8MyMatrixIdLj10ELj9EE( - // CHECK: [[MATRIX:%.*]] = load <90 x double>, ptr {{.*}}, align 8 - // CHECK: [[SCALAR:%.*]] = call noundef double @_ZN14DoubleWrapper1cvdEv(ptr {{[^,]*}} %w1) + // NOOPT: [[MATRIX:%.*]] = load <90 x double>, ptr {{.*}}, align 8{{$}} + // OPT: [[MATRIX:%.*]] = load <90 x double>, ptr {{.*}}, align 8, !tbaa !{{[0-9]+}}{{$}} + // CHECK-NEXT: [[SCALAR:%.*]] = call noundef double @_ZN14DoubleWrapper1cvdEv(ptr {{[^,]*}} %w1) // CHECK-NEXT: [[SCALAR_EMBED:%.*]] = insertelement <90 x double> poison, double [[SCALAR]], i32 0 // CHECK-NEXT: [[SCALAR_EMBED1:%.*]] = shufflevector <90 x double> [[SCALAR_EMBED]], <90 x double> poison, <90 x i32> zeroinitializer // CHECK-NEXT: [[RES:%.*]] = fsub <90 x double> [[MATRIX]], [[SCALAR_EMBED1]] @@ -75,7 +79,8 @@ void test_DoubleWrapper1_Sub1(MyMatrix &m) { void test_DoubleWrapper1_Sub2(MyMatrix &m) { // CHECK-LABEL: define{{.*}} void @_Z24test_DoubleWrapper1_Sub2R8MyMatrixIdLj10ELj9EE( // CHECK: [[SCALAR:%.*]] = call noundef double @_ZN14DoubleWrapper1cvdEv(ptr {{[^,]*}} %w1) - // CHECK: [[MATRIX:%.*]] = load <90 x double>, ptr {{.*}}, align 8 + // NOOPT: [[MATRIX:%.*]] = load <90 x double>, ptr {{.*}}, align 8{{$}} + // OPT: [[MATRIX:%.*]] = load <90 x double>, ptr {{
[clang] 553bdf4 - [NFC][clang] Strengthen checks in matrix-type-operators.c
Author: John McIver Date: 2022-12-05T10:13:35Z New Revision: 553bdf4fde5a4638f3a7764a4f6c209b9cd36a09 URL: https://github.com/llvm/llvm-project/commit/553bdf4fde5a4638f3a7764a4f6c209b9cd36a09 DIFF: https://github.com/llvm/llvm-project/commit/553bdf4fde5a4638f3a7764a4f6c209b9cd36a09.diff LOG: [NFC][clang] Strengthen checks in matrix-type-operators.c * Add tbaa attribute checks * Add end-of-line check to load instructions Added: Modified: clang/test/CodeGen/matrix-type-operators.c Removed: diff --git a/clang/test/CodeGen/matrix-type-operators.c b/clang/test/CodeGen/matrix-type-operators.c index 2e85d6543a31..8f80877b271a 100644 --- a/clang/test/CodeGen/matrix-type-operators.c +++ b/clang/test/CodeGen/matrix-type-operators.c @@ -1,6 +1,7 @@ -// RUN: %clang_cc1 -no-opaque-pointers -O0 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK %s +// RUN: %clang_cc1 -no-opaque-pointers -O0 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,NOOPT %s // RUN: %clang_cc1 -no-opaque-pointers -O1 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck --check-prefixes=CHECK,OPT %s + typedef double dx5x5_t __attribute__((matrix_type(5, 5))); typedef float fx2x3_t __attribute__((matrix_type(2, 3))); typedef int ix9x3_t __attribute__((matrix_type(9, 3))); @@ -10,8 +11,10 @@ typedef unsigned long long ullx4x2_t __attribute__((matrix_type(4, 2))); void add_matrix_matrix_double(dx5x5_t a, dx5x5_t b, dx5x5_t c) { // CHECK-LABEL: define{{.*}} void @add_matrix_matrix_double(<25 x double> noundef %a, <25 x double> noundef %b, <25 x double> noundef %c) - // CHECK: [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8 - // CHECK-NEXT: [[C:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8 + // NOOPT: [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8{{$}} + // NOOPT-NEXT: [[C:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8{{$}} + // OPT: [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8, !tbaa !{{[0-9]+}}{{$}} + // OPT-NEXT:[[C:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8, !tbaa !{{[0-9]+}}{{$}} // CHECK-NEXT: [[RES:%.*]] = fadd <25 x double> [[B]], [[C]] // CHECK-NEXT: store <25 x double> [[RES]], <25 x double>* {{.*}}, align 8 @@ -20,8 +23,10 @@ void add_matrix_matrix_double(dx5x5_t a, dx5x5_t b, dx5x5_t c) { void add_compound_assign_matrix_double(dx5x5_t a, dx5x5_t b) { // CHECK-LABEL: define{{.*}} void @add_compound_assign_matrix_double(<25 x double> noundef %a, <25 x double> noundef %b) - // CHECK: [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8 - // CHECK-NEXT: [[A:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8 + // NOOPT: [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8{{$}} + // NOOPT-NEXT: [[A:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8{{$}} + // OPT: [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8, !tbaa !{{[0-9]+}}{{$}} + // OPT-NEXT:[[A:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8, !tbaa !{{[0-9]+}}{{$}} // CHECK-NEXT: [[RES:%.*]] = fadd <25 x double> [[A]], [[B]] // CHECK-NEXT: store <25 x double> [[RES]], <25 x double>* {{.*}}, align 8 @@ -30,8 +35,10 @@ void add_compound_assign_matrix_double(dx5x5_t a, dx5x5_t b) { void subtract_compound_assign_matrix_double(dx5x5_t a, dx5x5_t b) { // CHECK-LABEL: define{{.*}} void @subtract_compound_assign_matrix_double(<25 x double> noundef %a, <25 x double> noundef %b) - // CHECK: [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8 - // CHECK-NEXT: [[A:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8 + // NOOPT: [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8{{$}} + // NOOPT-NEXT: [[A:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8{{$}} + // OPT: [[B:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8, !tbaa !{{[0-9]+}}{{$}} + // OPT-NEXT:[[A:%.*]] = load <25 x double>, <25 x double>* {{.*}}, align 8, !tbaa !{{[0-9]+}}{{$}} // CHECK-NEXT: [[RES:%.*]] = fsub <25 x double> [[A]], [[B]] // CHECK-NEXT: store <25 x double> [[RES]], <25 x double>* {{.*}}, align 8 @@ -40,8 +47,10 @@ void subtract_compound_assign_matrix_double(dx5x5_t a, dx5x5_t b) { void add_matrix_matrix_float(fx2x3_t a, fx2x3_t b, fx2x3_t c) { // CHECK-LABEL: define{{.*}} void @add_matrix_matrix_float(<6 x float> noundef %a, <6 x float> noundef %b, <6 x float> noundef %c) - // CHECK: [[B:%.*]] = load <6 x float>, <6 x float>* {{.*}}, align 4 - // CHECK-NEXT: [[C:%.*]] = load <6 x float>, <6 x float>* {{.*}}, align 4 + // NOOPT: [[B:%.*]] =
[clang] 481170c - [Clang][CodeGen] Use poison instead of undef for extra argument in __builtin_amdgcn_mov_dpp [NFC]
Author: Manuel Brito Date: 2022-12-06T12:40:33Z New Revision: 481170cb551124ed89353dd55a89b1d9971e9a6d URL: https://github.com/llvm/llvm-project/commit/481170cb551124ed89353dd55a89b1d9971e9a6d DIFF: https://github.com/llvm/llvm-project/commit/481170cb551124ed89353dd55a89b1d9971e9a6d.diff LOG: [Clang][CodeGen] Use poison instead of undef for extra argument in __builtin_amdgcn_mov_dpp [NFC] Differential Revision: https://reviews.llvm.org/D138755 Added: Modified: clang/lib/CodeGen/CGBuiltin.cpp clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl Removed: diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 0138111758657..d40910b76b599 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -16905,7 +16905,7 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID, Args.push_back(EmitScalarExpr(E->getArg(I))); assert(Args.size() == 5 || Args.size() == 6); if (Args.size() == 5) - Args.insert(Args.begin(), llvm::UndefValue::get(Args[0]->getType())); + Args.insert(Args.begin(), llvm::PoisonValue::get(Args[0]->getType())); Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_update_dpp, Args[0]->getType()); return Builder.CreateCall(F, Args); diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl b/clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl index daba1b972787e..c7437d7c1e881 100644 --- a/clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl +++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-vi.cl @@ -101,7 +101,7 @@ void test_s_dcache_wb() } // CHECK-LABEL: @test_mov_dpp -// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 undef, i32 %src, i32 0, i32 0, i32 0, i1 false) +// CHECK: call i32 @llvm.amdgcn.update.dpp.i32(i32 poison, i32 %src, i32 0, i32 0, i32 0, i1 false) void test_mov_dpp(global int* out, int src) { *out = __builtin_amdgcn_mov_dpp(src, 0, 0, 0, false); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2482dbf - [Clang] Use poison instead of undef where its used as placeholder [NFC]
Author: Manuel Brito Date: 2022-12-11T16:18:06Z New Revision: 2482dbff461e981203f9c691b24d6017de46a441 URL: https://github.com/llvm/llvm-project/commit/2482dbff461e981203f9c691b24d6017de46a441 DIFF: https://github.com/llvm/llvm-project/commit/2482dbff461e981203f9c691b24d6017de46a441.diff LOG: [Clang] Use poison instead of undef where its used as placeholder [NFC] Differential Revision: https://reviews.llvm.org/D139745 Added: Modified: clang/lib/CodeGen/CGException.cpp clang/lib/CodeGen/CGExprScalar.cpp clang/test/CodeGen/builtinshufflevector2.c clang/test/CodeGenCXX/nrvo.cpp clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp clang/test/CodeGenCXX/vla-consruct.cpp clang/test/CodeGenCoroutines/coro-eh-cleanup-exp-namespace.cpp clang/test/CodeGenCoroutines/coro-eh-cleanup.cpp clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp clang/test/OpenMP/single_codegen.cpp clang/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp clang/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp clang/test/OpenMP/threadprivate_codegen.cpp Removed: diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index e5558baf89770..6fa7871588f78 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -1625,7 +1625,7 @@ llvm::BasicBlock *CodeGenFunction::getEHResumeBlock(bool isCleanup) { llvm::Value *Sel = getSelectorFromSlot(); llvm::Type *LPadType = llvm::StructType::get(Exn->getType(), Sel->getType()); - llvm::Value *LPadVal = llvm::UndefValue::get(LPadType); + llvm::Value *LPadVal = llvm::PoisonValue::get(LPadType); LPadVal = Builder.CreateInsertValue(LPadVal, Exn, 0, "lpad.val"); LPadVal = Builder.CreateInsertValue(LPadVal, Sel, 1, "lpad.val"); diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 27580705acd81..6e67d3da6f2b6 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -1667,7 +1667,7 @@ Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) { // newv = insert newv, x, i auto *RTy = llvm::FixedVectorType::get(LTy->getElementType(), MTy->getNumElements()); -Value* NewV = llvm::UndefValue::get(RTy); +Value* NewV = llvm::PoisonValue::get(RTy); for (unsigned i = 0, e = MTy->getNumElements(); i != e; ++i) { Value *IIndx = llvm::ConstantInt::get(CGF.SizeTy, i); Value *Indx = Builder.CreateExtractElement(Mask, IIndx, "shuf_idx"); diff --git a/clang/test/CodeGen/builtinshufflevector2.c b/clang/test/CodeGen/builtinshufflevector2.c index 8b9e452d7ef3a..10e8fe19f9b77 100644 --- a/clang/test/CodeGen/builtinshufflevector2.c +++ b/clang/test/CodeGen/builtinshufflevector2.c @@ -12,7 +12,7 @@ void clang_shufflevector_v_v( float4* A, float4 x, uint4 mask ) { // Here is where ToT Clang code generation makes a mistake. // It uses [[I]] as the insertion index instead of 0. // Similarly on the remaining insertelement. -// CHECK: [[V:%[a-zA-Z0-9._]+]] = insertelement <4 x float> undef, float [[E]], i{{[0-9]+}} 0 +// CHECK: [[V:%[a-zA-Z0-9._]+]] = insertelement <4 x float> poison, float [[E]], i{{[0-9]+}} 0 // CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i{{[0-9]+}} 1 // CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i{{[0-9]+}} [[I]] diff --git a/clang/test/CodeGenCXX/nrvo.cpp b/clang/test/CodeGenCXX/nrvo.cpp index c092ff21ef52b..6ac5afcc2ac19 100644 --- a/clang/test/CodeGenCXX/nrvo.cpp +++ b/clang/test/CodeGenCXX/nrvo.cpp @@ -268,7 +268,7 @@ X test1(bool B) { // CHECK-EH-03: eh.resume: // CHECK-EH-03-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 4 // CHECK-EH-03-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4 -// CHECK-EH-03-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0 +// CHECK-EH-03-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0 // CHECK-EH-03-NEXT:[[LPAD_VAL8:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], i32 [[SEL]], 1 // CHECK-EH-03-NEXT:resume { ptr, i32 } [[LPAD_VAL8]] // CHECK-EH-03: terminate.lpad: @@ -336,7 +336,7 @@ X test1(bool B) { // CHECK-EH-11: eh.resume: // CHECK-EH-11-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 4 // CHECK-EH-11-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4 -// CHECK-EH-11-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0 +// CHECK-EH-11-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0 // CHECK-EH-11-NEXT:[[LPAD_VAL5:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], i32 [[SEL]], 1 // CHECK-EH-11-NEXT:resume { ptr, i32
Re: [PATCH] D11948: Add some macros to abstract marking of parameters as "not null", and use them in
nlopes added a subscriber: nlopes. Comment at: include/cstring:96 @@ +95,3 @@ +int strncmp(const char* __s1, const char* __s2, size_t __n) +{ return ::memcmp(__s1, __s2, __n); } + typo here. http://reviews.llvm.org/D11948 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7b1cb72 - [SROA] Switch replacement of dead/UB/unreachable ops from undef to poison
Author: Nuno Lopes Date: 2022-01-10T14:04:26Z New Revision: 7b1cb72ad944b460c42adf6df635263064a457f3 URL: https://github.com/llvm/llvm-project/commit/7b1cb72ad944b460c42adf6df635263064a457f3 DIFF: https://github.com/llvm/llvm-project/commit/7b1cb72ad944b460c42adf6df635263064a457f3.diff LOG: [SROA] Switch replacement of dead/UB/unreachable ops from undef to poison SROA has 3 data-structures where it stores sets of instructions that should be deleted: - DeadUsers -> instructions that are UB or have no users - DeadOperands -> instructions that are UB or operands of useless phis - DeadInsts -> "dead" instructions, including loads of uninitialized memory with users The first 2 sets can be RAUW with poison instead of undef. No brainer as UB can be replaced with poison, and for instructions with no users RAUW is a NOP. The 3rd case cannot be currently replaced with poison because the set mixes the loads of uninit memory. I leave that alone for now. Another case where we can use poison is in the construction of vectors from multiple loads. The base vector for the first insertelement is now poison as it doesn't matter as it is fully overwritten by inserts. Differential Revision: https://reviews.llvm.org/D116887 Added: Modified: clang/test/CodeGen/aarch64-bf16-ldst-intrinsics.c llvm/lib/Transforms/Scalar/SROA.cpp llvm/test/Transforms/SROA/basictest-opaque-ptrs.ll llvm/test/Transforms/SROA/basictest.ll llvm/test/Transforms/SROA/non-capturing-call.ll llvm/test/Transforms/SROA/phi-and-select.ll Removed: diff --git a/clang/test/CodeGen/aarch64-bf16-ldst-intrinsics.c b/clang/test/CodeGen/aarch64-bf16-ldst-intrinsics.c index 0961c49192dcb..01d015782da6d 100644 --- a/clang/test/CodeGen/aarch64-bf16-ldst-intrinsics.c +++ b/clang/test/CodeGen/aarch64-bf16-ldst-intrinsics.c @@ -64,7 +64,7 @@ bfloat16x4_t test_vld1_dup_bf16(bfloat16_t const *ptr) { // CHECK64-NEXT:[[VLD1XN:%.*]] = tail call { <4 x bfloat>, <4 x bfloat> } @llvm.aarch64.neon.ld1x2.v4bf16.p0bf16(bfloat* [[PTR:%.*]]) // CHECK64-NEXT:[[VLD1XN_FCA_0_EXTRACT:%.*]] = extractvalue { <4 x bfloat>, <4 x bfloat> } [[VLD1XN]], 0 // CHECK64-NEXT:[[VLD1XN_FCA_1_EXTRACT:%.*]] = extractvalue { <4 x bfloat>, <4 x bfloat> } [[VLD1XN]], 1 -// CHECK64-NEXT:[[DOTFCA_0_0_INSERT:%.*]] = insertvalue [[STRUCT_BFLOAT16X4X2_T:%.*]] undef, <4 x bfloat> [[VLD1XN_FCA_0_EXTRACT]], 0, 0 +// CHECK64-NEXT:[[DOTFCA_0_0_INSERT:%.*]] = insertvalue [[STRUCT_BFLOAT16X4X2_T:%.*]] poison, <4 x bfloat> [[VLD1XN_FCA_0_EXTRACT]], 0, 0 // CHECK64-NEXT:[[DOTFCA_0_1_INSERT:%.*]] = insertvalue [[STRUCT_BFLOAT16X4X2_T]] [[DOTFCA_0_0_INSERT]], <4 x bfloat> [[VLD1XN_FCA_1_EXTRACT]], 0, 1 // CHECK64-NEXT:ret [[STRUCT_BFLOAT16X4X2_T]] [[DOTFCA_0_1_INSERT]] // @@ -75,7 +75,7 @@ bfloat16x4_t test_vld1_dup_bf16(bfloat16_t const *ptr) { // CHECK32-NEXT:[[VLD1XN_FCA_1_EXTRACT:%.*]] = extractvalue { <4 x bfloat>, <4 x bfloat> } [[VLD1XN]], 1 // CHECK32-NEXT:[[TMP0:%.*]] = bitcast <4 x bfloat> [[VLD1XN_FCA_0_EXTRACT]] to <2 x i32> // CHECK32-NEXT:[[TMP1:%.*]] = bitcast <4 x bfloat> [[VLD1XN_FCA_1_EXTRACT]] to <2 x i32> -// CHECK32-NEXT:[[DOTFCA_0_INSERT:%.*]] = insertvalue [2 x <2 x i32>] undef, <2 x i32> [[TMP0]], 0 +// CHECK32-NEXT:[[DOTFCA_0_INSERT:%.*]] = insertvalue [2 x <2 x i32>] poison, <2 x i32> [[TMP0]], 0 // CHECK32-NEXT:[[DOTFCA_1_INSERT:%.*]] = insertvalue [2 x <2 x i32>] [[DOTFCA_0_INSERT]], <2 x i32> [[TMP1]], 1 // CHECK32-NEXT:ret [2 x <2 x i32>] [[DOTFCA_1_INSERT]] // @@ -88,7 +88,7 @@ bfloat16x4x2_t test_vld1_bf16_x2(bfloat16_t const *ptr) { // CHECK64-NEXT:[[VLD1XN:%.*]] = tail call { <8 x bfloat>, <8 x bfloat> } @llvm.aarch64.neon.ld1x2.v8bf16.p0bf16(bfloat* [[PTR:%.*]]) // CHECK64-NEXT:[[VLD1XN_FCA_0_EXTRACT:%.*]] = extractvalue { <8 x bfloat>, <8 x bfloat> } [[VLD1XN]], 0 // CHECK64-NEXT:[[VLD1XN_FCA_1_EXTRACT:%.*]] = extractvalue { <8 x bfloat>, <8 x bfloat> } [[VLD1XN]], 1 -// CHECK64-NEXT:[[DOTFCA_0_0_INSERT:%.*]] = insertvalue [[STRUCT_BFLOAT16X8X2_T:%.*]] undef, <8 x bfloat> [[VLD1XN_FCA_0_EXTRACT]], 0, 0 +// CHECK64-NEXT:[[DOTFCA_0_0_INSERT:%.*]] = insertvalue [[STRUCT_BFLOAT16X8X2_T:%.*]] poison, <8 x bfloat> [[VLD1XN_FCA_0_EXTRACT]], 0, 0 // CHECK64-NEXT:[[DOTFCA_0_1_INSERT:%.*]] = insertvalue [[STRUCT_BFLOAT16X8X2_T]] [[DOTFCA_0_0_INSERT]], <8 x bfloat> [[VLD1XN_FCA_1_EXTRACT]], 0, 1 // CHECK64-NEXT:ret [[STRUCT_BFLOAT16X8X2_T]] [[DOTFCA_0_1_INSERT]] // @@ -99,7 +99,7 @@ bfloat16x4x2_t test_vld1_bf16_x2(bfloat16_t const *ptr) { // CHECK32-NEXT:[[VLD1XN_FCA_1_EXTRACT:%.*]] = extractvalue { <8 x bfloat>, <8 x bfloat> } [[VLD1XN]], 1 // CHECK32-NEXT:[[TMP0:%.*]] = bitcast <8 x bfloat> [[VLD1XN_FCA_0_EXTRACT]] to <4 x i32> // CHECK32-NEXT:[[TMP1:%.*]] = bitcast <8 x bfloat> [[VLD1XN_FCA_1_EXTRACT]] to <4 x i32> -// CHECK
[clang] b0afa6b - [clang] Change some placeholders from undef to poison [NFC]
Author: Nuno Lopes Date: 2024-11-19T15:18:40Z New Revision: b0afa6bab9581abc91f23c854b3bb45095cbb057 URL: https://github.com/llvm/llvm-project/commit/b0afa6bab9581abc91f23c854b3bb45095cbb057 DIFF: https://github.com/llvm/llvm-project/commit/b0afa6bab9581abc91f23c854b3bb45095cbb057.diff LOG: [clang] Change some placeholders from undef to poison [NFC] Added: Modified: clang/lib/CodeGen/CGExprComplex.cpp clang/lib/CodeGen/CGExprScalar.cpp clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/CodeGen/CodeGenModule.cpp Removed: diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp index 16fdcf6b828533..ac31dff11b585e 100644 --- a/clang/lib/CodeGen/CGExprComplex.cpp +++ b/clang/lib/CodeGen/CGExprComplex.cpp @@ -471,7 +471,7 @@ ComplexPairTy ComplexExprEmitter::VisitExpr(Expr *E) { CGF.ErrorUnsupported(E, "complex expression"); llvm::Type *EltTy = CGF.ConvertType(getComplexType(E->getType())->getElementType()); - llvm::Value *U = llvm::UndefValue::get(EltTy); + llvm::Value *U = llvm::PoisonValue::get(EltTy); return ComplexPairTy(U, U); } @@ -1449,7 +1449,7 @@ ComplexPairTy ComplexExprEmitter::VisitVAArgExpr(VAArgExpr *E) { CGF.ErrorUnsupported(E, "complex va_arg expression"); llvm::Type *EltTy = CGF.ConvertType(E->getType()->castAs()->getElementType()); -llvm::Value *U = llvm::UndefValue::get(EltTy); +llvm::Value *U = llvm::PoisonValue::get(EltTy); return ComplexPairTy(U, U); } diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 287d911e10ba58..4ae8a2b22b1bba 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -1828,7 +1828,7 @@ Value *ScalarExprEmitter::VisitExpr(Expr *E) { CGF.ErrorUnsupported(E, "scalar expression"); if (E->getType()->isVoidType()) return nullptr; - return llvm::UndefValue::get(CGF.ConvertType(E->getType())); + return llvm::PoisonValue::get(CGF.ConvertType(E->getType())); } Value * diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 6a2f82f9e13906..e2437d144f5c2d 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -486,7 +486,7 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { if (IndirectBranch) { llvm::PHINode *PN = cast(IndirectBranch->getAddress()); if (PN->getNumIncomingValues() == 0) { - PN->replaceAllUsesWith(llvm::UndefValue::get(PN->getType())); + PN->replaceAllUsesWith(llvm::PoisonValue::get(PN->getType())); PN->eraseFromParent(); } } @@ -1106,8 +1106,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, // Create a marker to make it easy to insert allocas into the entryblock // later. Don't create this with the builder, because we don't want it // folded. - llvm::Value *Undef = llvm::UndefValue::get(Int32Ty); - AllocaInsertPt = new llvm::BitCastInst(Undef, Int32Ty, "allocapt", EntryBB); + llvm::Value *Poison = llvm::PoisonValue::get(Int32Ty); + AllocaInsertPt = new llvm::BitCastInst(Poison, Int32Ty, "allocapt", EntryBB); ReturnBlock = getJumpDestInCurrentScope("return"); diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 4f456981cf0de8..b854eeb62a80ce 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -733,7 +733,7 @@ void CodeGenModule::checkAliases() { for (const GlobalDecl &GD : Aliases) { StringRef MangledName = getMangledName(GD); llvm::GlobalValue *Alias = GetGlobalValue(MangledName); -Alias->replaceAllUsesWith(llvm::UndefValue::get(Alias->getType())); +Alias->replaceAllUsesWith(llvm::PoisonValue::get(Alias->getType())); Alias->eraseFromParent(); } } @@ -5572,7 +5572,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D, } } else { ErrorUnsupported(D, "static initializer"); -Init = llvm::UndefValue::get(getTypes().ConvertType(T)); +Init = llvm::PoisonValue::get(getTypes().ConvertType(T)); } } else { Init = Initializer; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Change placeholder from `undef` to `poison` (PR #117064)
https://github.com/nunoplopes closed https://github.com/llvm/llvm-project/pull/117064 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Change placeholders from `undef` to `poison` (PR #119141)
https://github.com/nunoplopes closed https://github.com/llvm/llvm-project/pull/119141 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Change placeholder from `undef` to `poison` (PR #120446)
https://github.com/nunoplopes updated https://github.com/llvm/llvm-project/pull/120446 >From eac0aa0d6a60a61a4312b248229aa94559ca5add Mon Sep 17 00:00:00 2001 From: Pedro Lobo Date: Wed, 18 Dec 2024 15:58:46 + Subject: [PATCH] [clang] Change placeholder from `undef` to `poison` Call `insertvalue` with a `poison` operand instead of `undef`. --- clang/lib/CodeGen/MicrosoftCXXABI.cpp | 2 +- clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index d587daac5a88a9..90651c3bafe26e 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -3454,7 +3454,7 @@ llvm::Value *MicrosoftCXXABI::EmitNonNullMemberPointerConversion( if (inheritanceModelHasOnlyOneField(IsFunc, DstInheritance)) { Dst = FirstField; } else { -Dst = llvm::UndefValue::get(ConvertMemberPointerType(DstTy)); +Dst = llvm::PoisonValue::get(ConvertMemberPointerType(DstTy)); unsigned Idx = 0; Dst = Builder.CreateInsertValue(Dst, FirstField, Idx++); if (inheritanceModelHasNVOffsetField(IsFunc, DstInheritance)) diff --git a/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp b/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp index 2ac1961465d8a8..fc8a31e0350e5f 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp @@ -647,7 +647,7 @@ void (Multiple::*convertB2FuncToMultiple(void (B2::*mp)()))() { // CHECK: br i1 %{{.*}} label %{{.*}}, label %{{.*}} // //memptr.convert: ; preds = %entry -// CHECK: insertvalue { ptr, i32 } undef, ptr %[[mp]], 0 +// CHECK: insertvalue { ptr, i32 } poison, ptr %[[mp]], 0 // CHECK: insertvalue { ptr, i32 } %{{.*}}, i32 4, 1 // CHECK: br label // @@ -705,7 +705,7 @@ void (D::*convertCToD(void (C::*mp)()))() { // CHECK: %[[nv_adj:.*]] = select i1 %[[is_nvbase]], i32 %[[nv_disp]], i32 0 // CHECK: %[[dst_adj:.*]] = select i1 %[[is_nvbase]], i32 4, i32 0 // CHECK: %[[adj:.*]] = sub nsw i32 %[[nv_adj]], %[[dst_adj]] -// CHECK: insertvalue { ptr, i32, i32 } undef, ptr {{.*}}, 0 +// CHECK: insertvalue { ptr, i32, i32 } poison, ptr {{.*}}, 0 // CHECK: insertvalue { ptr, i32, i32 } {{.*}}, i32 %[[adj]], 1 // CHECK: insertvalue { ptr, i32, i32 } {{.*}}, i32 {{.*}}, 2 // CHECK: br label ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang] Change placeholder from `undef` to `poison` (PR #120446)
https://github.com/nunoplopes closed https://github.com/llvm/llvm-project/pull/120446 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Improve casting between i1 scalable vectors and i8 fixed vectors for -mrvv-vector-bits (PR #139190)
@@ -1476,8 +1486,14 @@ CoerceScalableToFixed(CodeGenFunction &CGF, llvm::FixedVectorType *ToTy, // If we are casting a scalable i1 predicate vector to a fixed i8 // vector, first bitcast the source. if (FromTy->getElementType()->isIntegerTy(1) && - FromTy->getElementCount().isKnownMultipleOf(8) && ToTy->getElementType() == CGF.Builder.getInt8Ty()) { +if (!FromTy->getElementCount().isKnownMultipleOf(8)) { + FromTy = llvm::ScalableVectorType::get( + FromTy->getElementType(), + llvm::alignTo<8>(FromTy->getElementCount().getKnownMinValue())); + llvm::Value *ZeroVec = llvm::Constant::getNullValue(FromTy); nunoplopes wrote: Yes, that's the semantics. A single poison bits taints the whole value. So when you bitcast a vector to elements with different sizes, you need to account for the lanes that share the original lane. In summary, you can't combine poison elements into a lane that is meaningful for you. https://github.com/llvm/llvm-project/pull/139190 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Improve casting between i1 scalable vectors and i8 fixed vectors for -mrvv-vector-bits (PR #139190)
@@ -1476,8 +1486,14 @@ CoerceScalableToFixed(CodeGenFunction &CGF, llvm::FixedVectorType *ToTy, // If we are casting a scalable i1 predicate vector to a fixed i8 // vector, first bitcast the source. if (FromTy->getElementType()->isIntegerTy(1) && - FromTy->getElementCount().isKnownMultipleOf(8) && ToTy->getElementType() == CGF.Builder.getInt8Ty()) { +if (!FromTy->getElementCount().isKnownMultipleOf(8)) { + FromTy = llvm::ScalableVectorType::get( + FromTy->getElementType(), + llvm::alignTo<8>(FromTy->getElementCount().getKnownMinValue())); + llvm::Value *ZeroVec = llvm::Constant::getNullValue(FromTy); nunoplopes wrote: That is just a missed optimization. Offering bit-level poison semantics is too complicated. No one managed to come up with a proposal for that. So, we have to go with value-wise poison semantics for the foreseeable future. https://github.com/llvm/llvm-project/pull/139190 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits