[llvm] 73a836a - [Attributor] Look through indirect calls (#65197)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 8 12:14:42 PDT 2023
Author: Johannes Doerfert
Date: 2023-09-08T12:14:38-07:00
New Revision: 73a836a4642d9572493faf584bef1df0a0df0d2f
URL: https://github.com/llvm/llvm-project/commit/73a836a4642d9572493faf584bef1df0a0df0d2f
DIFF: https://github.com/llvm/llvm-project/commit/73a836a4642d9572493faf584bef1df0a0df0d2f.diff
LOG: [Attributor] Look through indirect calls (#65197)
Through the new `Attributor::checkForAllCallees` we can look through
indirect calls and visit all potential callees if they are known. Most
AAs will do that implicitly now via `AACalleeToCallSite`, thus, most AAs
are able to deal with missing callees for call site IR positions.
Differential Revision: https://reviews.llvm.org/D112290
Added:
Modified:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/test/Transforms/Attributor/liveness.ll
llvm/test/Transforms/Attributor/nounwind.ll
llvm/test/Transforms/Attributor/value-simplify.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 296aeb99e405698..bd1bd8261123e51 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -2125,6 +2125,15 @@ struct Attributor {
const AAIsDead *FnLivenessAA,
DepClassTy DepClass = DepClassTy::OPTIONAL);
+ /// Check \p Pred on all potential Callees of \p CB.
+ ///
+ /// This method will evaluate \p Pred with all potential callees of \p CB as
+ /// input and return true if \p Pred does. If some callees might be unknown
+ /// this function will return false.
+ bool checkForAllCallees(
+ function_ref<bool(ArrayRef<const Function *> Callees)> Pred,
+ const AbstractAttribute &QueryingAA, const CallBase &CB);
+
/// Check \p Pred on all (transitive) uses of \p V.
///
/// This method will evaluate \p Pred on all (transitive) uses of the
@@ -3295,7 +3304,7 @@ struct AbstractAttribute : public IRPosition, public AADepGraphNode {
/// Return true if this AA requires a "callee" (or an associted function) for
/// a call site positon. Default is optimistic to minimize AAs.
- static bool requiresCalleeForCallBase() { return true; }
+ static bool requiresCalleeForCallBase() { return false; }
/// Return true if this AA requires non-asm "callee" for a call site positon.
static bool requiresNonAsmForCallBase() { return true; }
@@ -3852,9 +3861,6 @@ struct AANoAlias
Attribute::AttrKind ImpliedAttributeKind,
bool IgnoreSubsumingPositions = false);
- /// See AbstractAttribute::requiresCalleeForCallBase
- static bool requiresCalleeForCallBase() { return false; }
-
/// See AbstractAttribute::requiresCallersForArgOrFunction
static bool requiresCallersForArgOrFunction() { return true; }
@@ -4699,6 +4705,9 @@ struct AAMemoryLocation
AAMemoryLocation(const IRPosition &IRP, Attributor &A) : IRAttribute(IRP) {}
+ /// See AbstractAttribute::requiresCalleeForCallBase.
+ static bool requiresCalleeForCallBase() { return true; }
+
/// See AbstractAttribute::hasTrivialInitializer.
static bool hasTrivialInitializer() { return false; }
@@ -5481,10 +5490,6 @@ struct AACallEdges : public StateWrapper<BooleanState, AbstractAttribute>,
AACallEdges(const IRPosition &IRP, Attributor &A)
: Base(IRP), AACallGraphNode(A) {}
- /// The callee value is tracked beyond a simple stripPointerCasts, so we allow
- /// unknown callees.
- static bool requiresCalleeForCallBase() { return false; }
-
/// See AbstractAttribute::requiresNonAsmForCallBase.
static bool requiresNonAsmForCallBase() { return false; }
@@ -6310,9 +6315,6 @@ struct AAIndirectCallInfo
AAIndirectCallInfo(const IRPosition &IRP, Attributor &A)
: StateWrapper<BooleanState, AbstractAttribute>(IRP) {}
- /// The point is to derive callees, after all.
- static bool requiresCalleeForCallBase() { return false; }
-
/// See AbstractAttribute::isValidIRPositionForInit
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP) {
if (IRP.getPositionKind() != IRPosition::IRP_CALL_SITE)
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 029f314b96901cc..1ffafc65ba63a4f 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -1733,6 +1733,21 @@ bool Attributor::isAssumedDead(const BasicBlock &BB,
return false;
}
+bool Attributor::checkForAllCallees(
+ function_ref<bool(ArrayRef<const Function *>)> Pred,
+ const AbstractAttribute &QueryingAA, const CallBase &CB) {
+ if (const Function *Callee = dyn_cast<Function>(CB.getCalledOperand()))
+ return Pred(Callee);
+
+ const auto *CallEdgesAA = getAAFor<AACallEdges>(
+ QueryingAA, IRPosition::callsite_function(CB), DepClassTy::OPTIONAL);
+ if (!CallEdgesAA || CallEdgesAA->hasUnknownCallee())
+ return false;
+
+ const auto &Callees = CallEdgesAA->getOptimisticEdges();
+ return Pred(Callees.getArrayRef());
+}
+
bool Attributor::checkForAllUses(
function_ref<bool(const Use &, bool &)> Pred,
const AbstractAttribute &QueryingAA, const Value &V,
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 26c560cee2173a8..2f6d8c65c541676 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -604,36 +604,42 @@ struct AACalleeToCallSite : public BaseType {
"returned positions!");
auto &S = this->getState();
- const Function *AssociatedFunction =
- this->getIRPosition().getAssociatedFunction();
- if (!AssociatedFunction)
- return S.indicatePessimisticFixpoint();
-
CallBase &CB = cast<CallBase>(this->getAnchorValue());
if (IntroduceCallBaseContext)
LLVM_DEBUG(dbgs() << "[Attributor] Introducing call base context:" << CB
<< "\n");
- IRPosition FnPos =
- IRPKind == llvm::IRPosition::IRP_CALL_SITE_RETURNED
- ? IRPosition::returned(*AssociatedFunction,
- IntroduceCallBaseContext ? &CB : nullptr)
- : IRPosition::function(*AssociatedFunction,
- IntroduceCallBaseContext ? &CB : nullptr);
-
- // If possible, use the hasAssumedIRAttr interface.
- if (Attribute::isEnumAttrKind(IRAttributeKind)) {
- bool IsKnown;
- if (!AA::hasAssumedIRAttr<IRAttributeKind>(A, this, FnPos,
- DepClassTy::REQUIRED, IsKnown))
- return S.indicatePessimisticFixpoint();
- return ChangeStatus::UNCHANGED;
- }
+ ChangeStatus Changed = ChangeStatus::UNCHANGED;
+ auto CalleePred = [&](ArrayRef<const Function *> Callees) {
+ for (const Function *Callee : Callees) {
+ IRPosition FnPos =
+ IRPKind == llvm::IRPosition::IRP_CALL_SITE_RETURNED
+ ? IRPosition::returned(*Callee,
+ IntroduceCallBaseContext ? &CB : nullptr)
+ : IRPosition::function(
+ *Callee, IntroduceCallBaseContext ? &CB : nullptr);
+ // If possible, use the hasAssumedIRAttr interface.
+ if (Attribute::isEnumAttrKind(IRAttributeKind)) {
+ bool IsKnown;
+ if (!AA::hasAssumedIRAttr<IRAttributeKind>(
+ A, this, FnPos, DepClassTy::REQUIRED, IsKnown))
+ return false;
+ continue;
+ }
- const AAType *AA = A.getAAFor<AAType>(*this, FnPos, DepClassTy::REQUIRED);
- if (!AA)
+ const AAType *AA =
+ A.getAAFor<AAType>(*this, FnPos, DepClassTy::REQUIRED);
+ if (!AA)
+ return false;
+ Changed |= clampStateAndIndicateChange(S, AA->getState());
+ if (S.isAtFixpoint())
+ return S.isValidState();
+ }
+ return true;
+ };
+ if (!A.checkForAllCallees(CalleePred, *this, CB))
return S.indicatePessimisticFixpoint();
- return clampStateAndIndicateChange(S, AA->getState());
+ return Changed;
}
};
diff --git a/llvm/test/Transforms/Attributor/liveness.ll b/llvm/test/Transforms/Attributor/liveness.ll
index 5b9ad021ff66f12..06195b97ac5fd99 100644
--- a/llvm/test/Transforms/Attributor/liveness.ll
+++ b/llvm/test/Transforms/Attributor/liveness.ll
@@ -2359,12 +2359,12 @@ define void @call_via_pointer_with_dead_args(ptr %a, ptr %b, ptr %fp) {
define internal void @call_via_pointer_with_dead_args_internal_a(ptr %a, ptr %b, ptr %fp) {
; TUNIT-LABEL: define {{[^@]+}}@call_via_pointer_with_dead_args_internal_a
; TUNIT-SAME: (ptr [[A:%.*]], ptr noundef nonnull align 128 dereferenceable(4) [[B:%.*]]) {
-; TUNIT-NEXT: call void @called_via_pointer(ptr [[A]], ptr [[B]], ptr [[A]], i64 -1, ptr null)
+; TUNIT-NEXT: call void @called_via_pointer(ptr [[A]], ptr nonnull align 128 dereferenceable(4) [[B]], ptr [[A]], i64 -1, ptr null)
; TUNIT-NEXT: ret void
;
; CGSCC-LABEL: define {{[^@]+}}@call_via_pointer_with_dead_args_internal_a
; CGSCC-SAME: (ptr [[A:%.*]], ptr noundef nonnull align 128 dereferenceable(4) [[B:%.*]]) {
-; CGSCC-NEXT: call void @called_via_pointer(ptr [[A]], ptr nocapture nofree noundef nonnull [[B]], ptr nocapture nofree [[A]], i64 noundef -1, ptr nofree noundef null)
+; CGSCC-NEXT: call void @called_via_pointer(ptr [[A]], ptr nocapture nofree noundef nonnull align 128 dereferenceable(4) [[B]], ptr nocapture nofree [[A]], i64 noundef -1, ptr nofree noundef null)
; CGSCC-NEXT: ret void
;
call void %fp(ptr %a, ptr %b, ptr %a, i64 -1, ptr null)
@@ -2373,7 +2373,7 @@ define internal void @call_via_pointer_with_dead_args_internal_a(ptr %a, ptr %b,
define internal void @call_via_pointer_with_dead_args_internal_b(ptr %a, ptr %b, ptr %fp) {
; TUNIT-LABEL: define {{[^@]+}}@call_via_pointer_with_dead_args_internal_b
; TUNIT-SAME: (ptr [[A:%.*]], ptr noundef nonnull align 128 dereferenceable(4) [[B:%.*]]) {
-; TUNIT-NEXT: call void @called_via_pointer_internal_2(ptr [[A]], ptr [[B]], ptr [[A]], i64 -1, ptr null)
+; TUNIT-NEXT: call void @called_via_pointer_internal_2(ptr [[A]], ptr nonnull align 128 dereferenceable(4) [[B]], ptr [[A]], i64 -1, ptr null)
; TUNIT-NEXT: ret void
;
; CGSCC-LABEL: define {{[^@]+}}@call_via_pointer_with_dead_args_internal_b
diff --git a/llvm/test/Transforms/Attributor/nounwind.ll b/llvm/test/Transforms/Attributor/nounwind.ll
index f3d6873cea9d303..147ba3e6a72eb1c 100644
--- a/llvm/test/Transforms/Attributor/nounwind.ll
+++ b/llvm/test/Transforms/Attributor/nounwind.ll
@@ -151,27 +151,14 @@ define i32 @catch_thing_user() {
}
define void @two_potential_callees_pos1(i1 %c) {
-; TUNIT: Function Attrs: norecurse
+; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
; TUNIT-LABEL: define {{[^@]+}}@two_potential_callees_pos1
-; TUNIT-SAME: (i1 [[C:%.*]]) #[[ATTR3:[0-9]+]] {
-; TUNIT-NEXT: [[FP:%.*]] = select i1 [[C]], ptr @foo1, ptr @scc1_foo
-; TUNIT-NEXT: [[TMP1:%.*]] = icmp eq ptr [[FP]], @scc1_foo
-; TUNIT-NEXT: br i1 [[TMP1]], label [[TMP2:%.*]], label [[TMP3:%.*]]
-; TUNIT: 2:
-; TUNIT-NEXT: call void @scc1_foo()
-; TUNIT-NEXT: br label [[TMP6:%.*]]
-; TUNIT: 3:
-; TUNIT-NEXT: br i1 true, label [[TMP4:%.*]], label [[TMP5:%.*]]
-; TUNIT: 4:
-; TUNIT-NEXT: call void @foo1()
-; TUNIT-NEXT: br label [[TMP6]]
-; TUNIT: 5:
-; TUNIT-NEXT: unreachable
-; TUNIT: 6:
+; TUNIT-SAME: (i1 [[C:%.*]]) #[[ATTR0]] {
; TUNIT-NEXT: ret void
;
+; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn
; CGSCC-LABEL: define {{[^@]+}}@two_potential_callees_pos1
-; CGSCC-SAME: (i1 [[C:%.*]]) {
+; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR2:[0-9]+]] {
; CGSCC-NEXT: [[FP:%.*]] = select i1 [[C]], ptr @foo1, ptr @scc1_foo
; CGSCC-NEXT: [[TMP1:%.*]] = icmp eq ptr [[FP]], @scc1_foo
; CGSCC-NEXT: br i1 [[TMP1]], label [[TMP2:%.*]], label [[TMP3:%.*]]
@@ -193,8 +180,9 @@ define void @two_potential_callees_pos1(i1 %c) {
ret void
}
define void @two_potential_callees_pos2(i1 %c) {
+; CHECK: Function Attrs: nounwind
; CHECK-LABEL: define {{[^@]+}}@two_potential_callees_pos2
-; CHECK-SAME: (i1 [[C:%.*]]) {
+; CHECK-SAME: (i1 [[C:%.*]]) #[[ATTR1]] {
; CHECK-NEXT: [[FP:%.*]] = select i1 [[C]], ptr @foo2, ptr @scc1_foo
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq ptr [[FP]], @scc1_foo
; CHECK-NEXT: br i1 [[TMP1]], label [[TMP2:%.*]], label [[TMP3:%.*]]
@@ -248,8 +236,8 @@ declare void @__cxa_end_catch()
; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
; TUNIT: attributes #[[ATTR1]] = { nounwind }
; TUNIT: attributes #[[ATTR2]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
-; TUNIT: attributes #[[ATTR3]] = { norecurse }
;.
; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
; CGSCC: attributes #[[ATTR1]] = { nounwind }
+; CGSCC: attributes #[[ATTR2]] = { mustprogress nofree nosync nounwind willreturn }
;.
diff --git a/llvm/test/Transforms/Attributor/value-simplify.ll b/llvm/test/Transforms/Attributor/value-simplify.ll
index 415f39e7b292ca6..cbdc190c6ea6341 100644
--- a/llvm/test/Transforms/Attributor/value-simplify.ll
+++ b/llvm/test/Transforms/Attributor/value-simplify.ll
@@ -109,11 +109,11 @@ define i32 @test2_1(i1 %c) {
; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR3:[0-9]+]] {
; CGSCC-NEXT: br i1 [[C]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
; CGSCC: if.true:
-; CGSCC-NEXT: [[CALL:%.*]] = tail call i32 @return0() #[[ATTR13:[0-9]+]]
+; CGSCC-NEXT: [[CALL:%.*]] = tail call i32 @return0() #[[ATTR12:[0-9]+]]
; CGSCC-NEXT: [[RET0:%.*]] = add i32 [[CALL]], 1
; CGSCC-NEXT: br label [[END:%.*]]
; CGSCC: if.false:
-; CGSCC-NEXT: [[RET1:%.*]] = tail call i32 @return1() #[[ATTR13]]
+; CGSCC-NEXT: [[RET1:%.*]] = tail call i32 @return1() #[[ATTR12]]
; CGSCC-NEXT: br label [[END]]
; CGSCC: end:
; CGSCC-NEXT: [[RET:%.*]] = phi i32 [ [[RET0]], [[IF_TRUE]] ], [ [[RET1]], [[IF_FALSE]] ]
@@ -145,7 +145,7 @@ define i32 @test2_2(i1 %c) {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@test2_2
; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR3]] {
-; CGSCC-NEXT: [[RET:%.*]] = tail call noundef i32 @test2_1(i1 noundef [[C]]) #[[ATTR13]]
+; CGSCC-NEXT: [[RET:%.*]] = tail call noundef i32 @test2_1(i1 noundef [[C]]) #[[ATTR12]]
; CGSCC-NEXT: ret i32 [[RET]]
;
%ret = tail call i32 @test2_1(i1 %c)
@@ -172,7 +172,7 @@ define void @test3(i1 %c) {
; CGSCC: if.true:
; CGSCC-NEXT: br label [[END:%.*]]
; CGSCC: if.false:
-; CGSCC-NEXT: [[RET1:%.*]] = tail call i32 @return1() #[[ATTR14:[0-9]+]]
+; CGSCC-NEXT: [[RET1:%.*]] = tail call i32 @return1() #[[ATTR13:[0-9]+]]
; CGSCC-NEXT: br label [[END]]
; CGSCC: end:
; CGSCC-NEXT: [[R:%.*]] = phi i32 [ 1, [[IF_TRUE]] ], [ [[RET1]], [[IF_FALSE]] ]
@@ -303,7 +303,7 @@ define i1 @ipccp2() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@ipccp2
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[R:%.*]] = call noundef i1 @ipccp2i() #[[ATTR13]]
+; CGSCC-NEXT: [[R:%.*]] = call noundef i1 @ipccp2i() #[[ATTR12]]
; CGSCC-NEXT: ret i1 [[R]]
;
%r = call i1 @ipccp2i(i1 true)
@@ -337,7 +337,7 @@ define i1 @ipccp2b() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@ipccp2b
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[R:%.*]] = call noundef i1 @ipccp2ib() #[[ATTR13]]
+; CGSCC-NEXT: [[R:%.*]] = call noundef i1 @ipccp2ib() #[[ATTR12]]
; CGSCC-NEXT: ret i1 [[R]]
;
%r = call i1 @ipccp2ib(i1 true)
@@ -372,7 +372,7 @@ define i32 @ipccp3() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@ipccp3
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp3i() #[[ATTR13]]
+; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp3i() #[[ATTR12]]
; CGSCC-NEXT: ret i32 [[R]]
;
%r = call i32 @ipccp3i(i32 7)
@@ -401,7 +401,7 @@ define internal i32 @ipccp4ib(i32 %a) {
; CGSCC-SAME: () #[[ATTR3]] {
; CGSCC-NEXT: br label [[T:%.*]]
; CGSCC: t:
-; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp4ia(i1 noundef true) #[[ATTR13]]
+; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp4ia(i1 noundef true) #[[ATTR12]]
; CGSCC-NEXT: ret i32 [[R]]
; CGSCC: f:
; CGSCC-NEXT: unreachable
@@ -432,7 +432,7 @@ define i32 @ipccp4(i1 %c) {
; CGSCC: t:
; CGSCC-NEXT: br label [[F]]
; CGSCC: f:
-; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp4ib() #[[ATTR13]]
+; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp4ib() #[[ATTR12]]
; CGSCC-NEXT: ret i32 [[R]]
;
br i1 %c, label %t, label %f
@@ -469,7 +469,7 @@ define ptr @complicated_args_inalloca(ptr %arg) {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@complicated_args_inalloca
; CGSCC-SAME: (ptr nofree noundef nonnull readnone dereferenceable(4) [[ARG:%.*]]) #[[ATTR3]] {
-; CGSCC-NEXT: [[CALL:%.*]] = call noalias noundef nonnull dereferenceable(4) ptr @test_inalloca(ptr noalias nofree noundef nonnull writeonly inalloca(i32) dereferenceable(4) [[ARG]]) #[[ATTR13]]
+; CGSCC-NEXT: [[CALL:%.*]] = call noalias noundef nonnull dereferenceable(4) ptr @test_inalloca(ptr noalias nofree noundef nonnull writeonly inalloca(i32) dereferenceable(4) [[ARG]]) #[[ATTR12]]
; CGSCC-NEXT: ret ptr [[CALL]]
;
%call = call ptr @test_inalloca(ptr inalloca(i32) %arg)
@@ -500,8 +500,8 @@ define ptr @complicated_args_preallocated() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn
; CGSCC-LABEL: define {{[^@]+}}@complicated_args_preallocated
; CGSCC-SAME: () #[[ATTR4:[0-9]+]] {
-; CGSCC-NEXT: [[C:%.*]] = call token @llvm.call.preallocated.setup(i32 noundef 1) #[[ATTR14]]
-; CGSCC-NEXT: [[CALL:%.*]] = call ptr @test_preallocated(ptr nofree noundef writeonly preallocated(i32) align 4294967296 null) #[[ATTR15:[0-9]+]] [ "preallocated"(token [[C]]) ]
+; CGSCC-NEXT: [[C:%.*]] = call token @llvm.call.preallocated.setup(i32 noundef 1) #[[ATTR13]]
+; CGSCC-NEXT: [[CALL:%.*]] = call ptr @test_preallocated(ptr nofree noundef writeonly preallocated(i32) align 4294967296 null) #[[ATTR14:[0-9]+]] [ "preallocated"(token [[C]]) ]
; CGSCC-NEXT: unreachable
;
%c = call token @llvm.call.preallocated.setup(i32 1)
@@ -539,7 +539,7 @@ define void @complicated_args_sret(ptr %b) {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(argmem: write)
; CGSCC-LABEL: define {{[^@]+}}@complicated_args_sret
; CGSCC-SAME: (ptr nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[B:%.*]]) #[[ATTR6:[0-9]+]] {
-; CGSCC-NEXT: call void @test_sret(ptr nofree noundef writeonly sret([[STRUCT_X:%.*]]) align 4294967296 dereferenceable_or_null(8) null, ptr nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[B]]) #[[ATTR16:[0-9]+]]
+; CGSCC-NEXT: call void @test_sret(ptr nofree noundef writeonly sret([[STRUCT_X:%.*]]) align 4294967296 dereferenceable_or_null(8) null, ptr nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[B]]) #[[ATTR15:[0-9]+]]
; CGSCC-NEXT: ret void
;
call void @test_sret(ptr sret(%struct.X) null, ptr %b)
@@ -563,7 +563,7 @@ define ptr @complicated_args_nest() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@complicated_args_nest
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[CALL:%.*]] = call noalias noundef align 4294967296 ptr @test_nest(ptr nofree noundef readnone align 4294967296 null) #[[ATTR13]]
+; CGSCC-NEXT: [[CALL:%.*]] = call noalias noundef align 4294967296 ptr @test_nest(ptr nofree noundef readnone align 4294967296 null) #[[ATTR12]]
; CGSCC-NEXT: ret ptr [[CALL]]
;
%call = call ptr @test_nest(ptr null)
@@ -603,7 +603,7 @@ define void @complicated_args_byval() {
; CGSCC-LABEL: define {{[^@]+}}@complicated_args_byval
; CGSCC-SAME: () #[[ATTR4]] {
; CGSCC-NEXT: [[TMP1:%.*]] = load ptr, ptr @S, align 8
-; CGSCC-NEXT: call void @test_byval(ptr nofree writeonly [[TMP1]]) #[[ATTR16]]
+; CGSCC-NEXT: call void @test_byval(ptr nofree writeonly [[TMP1]]) #[[ATTR15]]
; CGSCC-NEXT: ret void
;
call void @test_byval(ptr byval(%struct.X) @S)
@@ -719,7 +719,7 @@ define i8 @caller0() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@caller0
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR13]]
+; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
; CGSCC-NEXT: ret i8 [[C]]
;
%c = call i8 @callee(i8 undef)
@@ -734,7 +734,7 @@ define i8 @caller1() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@caller1
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR13]]
+; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
; CGSCC-NEXT: ret i8 [[C]]
;
%c = call i8 @callee(i8 undef)
@@ -749,7 +749,7 @@ define i8 @caller2() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@caller2
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR13]]
+; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
; CGSCC-NEXT: ret i8 [[C]]
;
%c = call i8 @callee(i8 undef)
@@ -764,7 +764,7 @@ define i8 @caller_middle() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@caller_middle
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR13]]
+; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
; CGSCC-NEXT: ret i8 [[C]]
;
%c = call i8 @callee(i8 42)
@@ -779,7 +779,7 @@ define i8 @caller3() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@caller3
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR13]]
+; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
; CGSCC-NEXT: ret i8 [[C]]
;
%c = call i8 @callee(i8 undef)
@@ -794,7 +794,7 @@ define i8 @caller4() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@caller4
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR13]]
+; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
; CGSCC-NEXT: ret i8 [[C]]
;
%c = call i8 @callee(i8 undef)
@@ -820,7 +820,7 @@ define void @user_as3() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(write)
; CGSCC-LABEL: define {{[^@]+}}@user_as3
; CGSCC-SAME: () #[[ATTR7:[0-9]+]] {
-; CGSCC-NEXT: [[CALL:%.*]] = call fastcc align 4 ptr addrspace(3) @const_ptr_return_as3() #[[ATTR13]]
+; CGSCC-NEXT: [[CALL:%.*]] = call fastcc align 4 ptr addrspace(3) @const_ptr_return_as3() #[[ATTR12]]
; CGSCC-NEXT: store i32 0, ptr addrspace(3) [[CALL]], align 4
; CGSCC-NEXT: ret void
;
@@ -839,7 +839,7 @@ define void @user() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(write)
; CGSCC-LABEL: define {{[^@]+}}@user
; CGSCC-SAME: () #[[ATTR7]] {
-; CGSCC-NEXT: [[CALL:%.*]] = call fastcc align 4 ptr @const_ptr_return() #[[ATTR13]]
+; CGSCC-NEXT: [[CALL:%.*]] = call fastcc align 4 ptr @const_ptr_return() #[[ATTR12]]
; CGSCC-NEXT: store i32 0, ptr [[CALL]], align 4
; CGSCC-NEXT: ret void
;
@@ -858,7 +858,7 @@ define i1 @test_merge_with_undef_values_ptr(i1 %c) {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@test_merge_with_undef_values_ptr
; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR3]] {
-; CGSCC-NEXT: [[R1:%.*]] = call i1 @undef_then_null(i1 [[C]]) #[[ATTR13]]
+; CGSCC-NEXT: [[R1:%.*]] = call i1 @undef_then_null(i1 [[C]]) #[[ATTR12]]
; CGSCC-NEXT: ret i1 [[R1]]
;
%r1 = call i1 @undef_then_null(i1 %c, ptr undef, ptr undef)
@@ -895,7 +895,7 @@ define i1 @test_merge_with_undef_values(i1 %c) {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@test_merge_with_undef_values
; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR3]] {
-; CGSCC-NEXT: [[R1:%.*]] = call i1 @undef_then_1(i1 [[C]]) #[[ATTR13]]
+; CGSCC-NEXT: [[R1:%.*]] = call i1 @undef_then_1(i1 [[C]]) #[[ATTR12]]
; CGSCC-NEXT: ret i1 [[R1]]
;
%r1 = call i1 @undef_then_1(i1 %c, i32 undef, i32 undef)
@@ -933,7 +933,7 @@ define i32 @test_select(i32 %c) {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@test_select
; CGSCC-SAME: (i32 [[C:%.*]]) #[[ATTR3]] {
-; CGSCC-NEXT: [[CALL:%.*]] = call noundef i32 @select() #[[ATTR13]]
+; CGSCC-NEXT: [[CALL:%.*]] = call noundef i32 @select() #[[ATTR12]]
; CGSCC-NEXT: ret i32 [[CALL]]
;
%call = call i32 @select(i1 1, i32 42, i32 %c)
@@ -968,11 +968,11 @@ define i1 @icmp() {
define void @test_callee_is_undef(ptr %fn) {
; TUNIT-LABEL: define {{[^@]+}}@test_callee_is_undef
; TUNIT-SAME: (ptr nocapture nofree [[FN:%.*]]) {
-; TUNIT-NEXT: unreachable
+; TUNIT-NEXT: call void @unknown_calle_arg_is_undef(ptr nocapture nofree noundef [[FN]])
+; TUNIT-NEXT: ret void
;
; CGSCC-LABEL: define {{[^@]+}}@test_callee_is_undef
-; CGSCC-SAME: (ptr nocapture nofree [[FN:%.*]]) {
-; CGSCC-NEXT: call void @callee_is_undef()
+; CGSCC-SAME: (ptr nocapture nofree noundef nonnull [[FN:%.*]]) {
; CGSCC-NEXT: call void @unknown_calle_arg_is_undef(ptr nocapture nofree noundef nonnull [[FN]])
; CGSCC-NEXT: ret void
;
@@ -982,9 +982,9 @@ define void @test_callee_is_undef(ptr %fn) {
}
define internal void @callee_is_undef(ptr %fn) {
;
-; CGSCC: Function Attrs: norecurse memory(readwrite, argmem: none)
+; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@callee_is_undef
-; CGSCC-SAME: () #[[ATTR8:[0-9]+]] {
+; CGSCC-SAME: () #[[ATTR1]] {
; CGSCC-NEXT: unreachable
;
call void %fn()
@@ -992,10 +992,10 @@ define internal void @callee_is_undef(ptr %fn) {
}
define internal void @unknown_calle_arg_is_undef(ptr %fn, i32 %arg) {
;
-; CGSCC-LABEL: define {{[^@]+}}@unknown_calle_arg_is_undef
-; CGSCC-SAME: (ptr nocapture nofree noundef nonnull [[FN:%.*]]) {
-; CGSCC-NEXT: call void [[FN]](i32 undef)
-; CGSCC-NEXT: ret void
+; CHECK-LABEL: define {{[^@]+}}@unknown_calle_arg_is_undef
+; CHECK-SAME: (ptr nocapture nofree noundef nonnull [[FN:%.*]]) {
+; CHECK-NEXT: call void [[FN]](i32 undef)
+; CHECK-NEXT: ret void
;
call void %fn(i32 %arg)
ret void
@@ -1083,7 +1083,7 @@ define i1 @test_cmp_null_after_cast() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@test_cmp_null_after_cast
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[C:%.*]] = call noundef i1 @cmp_null_after_cast() #[[ATTR13]]
+; CGSCC-NEXT: [[C:%.*]] = call noundef i1 @cmp_null_after_cast() #[[ATTR12]]
; CGSCC-NEXT: ret i1 [[C]]
;
%c = call i1 @cmp_null_after_cast(i32 0, i8 0)
@@ -1202,7 +1202,7 @@ define i1 @test_liveness(i1 %c) {
; CGSCC-NEXT: br label [[F]]
; CGSCC: f:
; CGSCC-NEXT: [[P:%.*]] = phi i1 [ true, [[ENTRY:%.*]] ], [ false, [[T]] ]
-; CGSCC-NEXT: [[RC1:%.*]] = call noundef i1 @ret(i1 noundef [[P]]) #[[ATTR13]]
+; CGSCC-NEXT: [[RC1:%.*]] = call noundef i1 @ret(i1 noundef [[P]]) #[[ATTR12]]
; CGSCC-NEXT: ret i1 [[RC1]]
;
entry:
@@ -1274,7 +1274,7 @@ define internal i8 @memcpy_uses_store(i8 %arg) {
; CGSCC-NEXT: [[SRC:%.*]] = alloca i8, align 1
; CGSCC-NEXT: [[DST:%.*]] = alloca i8, align 1
; CGSCC-NEXT: store i8 [[ARG]], ptr [[SRC]], align 1
-; CGSCC-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[DST]], ptr noalias nocapture nofree noundef nonnull readonly dereferenceable(1) [[SRC]], i32 noundef 1, i1 noundef false) #[[ATTR17:[0-9]+]]
+; CGSCC-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[DST]], ptr noalias nocapture nofree noundef nonnull readonly dereferenceable(1) [[SRC]], i32 noundef 1, i1 noundef false) #[[ATTR16:[0-9]+]]
; CGSCC-NEXT: [[L:%.*]] = load i8, ptr [[DST]], align 1
; CGSCC-NEXT: ret i8 [[L]]
;
@@ -1296,7 +1296,7 @@ define i8 @memcpy_uses_store_caller(i8 %arg) {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@memcpy_uses_store_caller
; CGSCC-SAME: (i8 [[ARG:%.*]]) #[[ATTR3]] {
-; CGSCC-NEXT: [[R:%.*]] = call i8 @memcpy_uses_store(i8 [[ARG]]) #[[ATTR13]]
+; CGSCC-NEXT: [[R:%.*]] = call i8 @memcpy_uses_store(i8 [[ARG]]) #[[ATTR12]]
; CGSCC-NEXT: ret i8 [[R]]
;
%r = call i8 @memcpy_uses_store(i8 %arg)
@@ -1320,12 +1320,12 @@ define i32 @test_speculatable_expr() norecurse {
;
; CGSCC: Function Attrs: norecurse nosync memory(none)
; CGSCC-LABEL: define {{[^@]+}}@test_speculatable_expr
-; CGSCC-SAME: () #[[ATTR10:[0-9]+]] {
+; CGSCC-SAME: () #[[ATTR9:[0-9]+]] {
; CGSCC-NEXT: [[STACK:%.*]] = alloca i32, align 4
-; CGSCC-NEXT: [[SPEC_RESULT:%.*]] = call i32 @speculatable() #[[ATTR18:[0-9]+]]
+; CGSCC-NEXT: [[SPEC_RESULT:%.*]] = call i32 @speculatable() #[[ATTR17:[0-9]+]]
; CGSCC-NEXT: [[PLUS1:%.*]] = add i32 [[SPEC_RESULT]], 1
; CGSCC-NEXT: store i32 [[PLUS1]], ptr [[STACK]], align 4
-; CGSCC-NEXT: [[RSPEC:%.*]] = call i32 @ret_speculatable_expr(i32 [[PLUS1]]) #[[ATTR18]]
+; CGSCC-NEXT: [[RSPEC:%.*]] = call i32 @ret_speculatable_expr(i32 [[PLUS1]]) #[[ATTR17]]
; CGSCC-NEXT: ret i32 [[RSPEC]]
;
%stack = alloca i32
@@ -1434,7 +1434,7 @@ define internal void @indirect() {
;
; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
; CGSCC-LABEL: define {{[^@]+}}@indirect
-; CGSCC-SAME: () #[[ATTR11:[0-9]+]] {
+; CGSCC-SAME: () #[[ATTR10:[0-9]+]] {
; CGSCC-NEXT: store i32 0, ptr @x, align 4
; CGSCC-NEXT: ret void
;
@@ -1447,7 +1447,7 @@ define internal void @broker(ptr %ptr) {
; TUNIT-LABEL: define {{[^@]+}}@broker
; TUNIT-SAME: () #[[ATTR1]] {
; TUNIT-NEXT: entry:
-; TUNIT-NEXT: call void @indirect()
+; TUNIT-NEXT: call void @indirect() #[[ATTR16:[0-9]+]]
; TUNIT-NEXT: call void @unknown()
; TUNIT-NEXT: ret void
;
@@ -1455,7 +1455,7 @@ define internal void @broker(ptr %ptr) {
; CGSCC-LABEL: define {{[^@]+}}@broker
; CGSCC-SAME: () #[[ATTR2]] {
; CGSCC-NEXT: entry:
-; CGSCC-NEXT: call void @indirect() #[[ATTR19:[0-9]+]]
+; CGSCC-NEXT: call void @indirect() #[[ATTR18:[0-9]+]]
; CGSCC-NEXT: call void @unknown()
; CGSCC-NEXT: ret void
;
@@ -1649,6 +1649,7 @@ dead5:
; TUNIT: attributes #[[ATTR13]] = { nofree nosync nounwind willreturn }
; TUNIT: attributes #[[ATTR14]] = { nosync }
; TUNIT: attributes #[[ATTR15]] = { nosync nounwind memory(read) }
+; TUNIT: attributes #[[ATTR16]] = { nounwind memory(write) }
;.
; CGSCC: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn }
; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
@@ -1658,18 +1659,17 @@ dead5:
; CGSCC: attributes #[[ATTR5]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
; CGSCC: attributes #[[ATTR6]] = { mustprogress nofree nosync nounwind willreturn memory(argmem: write) }
; CGSCC: attributes #[[ATTR7]] = { mustprogress nofree nosync nounwind willreturn memory(write) }
-; CGSCC: attributes #[[ATTR8]] = { norecurse memory(readwrite, argmem: none) }
-; CGSCC: attributes #[[ATTR9:[0-9]+]] = { speculatable memory(none) }
-; CGSCC: attributes #[[ATTR10]] = { norecurse nosync memory(none) }
-; CGSCC: attributes #[[ATTR11]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
-; CGSCC: attributes #[[ATTR12:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
-; CGSCC: attributes #[[ATTR13]] = { nofree nosync willreturn }
-; CGSCC: attributes #[[ATTR14]] = { nofree willreturn }
-; CGSCC: attributes #[[ATTR15]] = { nofree nounwind willreturn }
-; CGSCC: attributes #[[ATTR16]] = { nofree nounwind willreturn memory(write) }
-; CGSCC: attributes #[[ATTR17]] = { nofree willreturn memory(readwrite) }
-; CGSCC: attributes #[[ATTR18]] = { nosync }
-; CGSCC: attributes #[[ATTR19]] = { nounwind }
+; CGSCC: attributes #[[ATTR8:[0-9]+]] = { speculatable memory(none) }
+; CGSCC: attributes #[[ATTR9]] = { norecurse nosync memory(none) }
+; CGSCC: attributes #[[ATTR10]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
+; CGSCC: attributes #[[ATTR11:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
+; CGSCC: attributes #[[ATTR12]] = { nofree nosync willreturn }
+; CGSCC: attributes #[[ATTR13]] = { nofree willreturn }
+; CGSCC: attributes #[[ATTR14]] = { nofree nounwind willreturn }
+; CGSCC: attributes #[[ATTR15]] = { nofree nounwind willreturn memory(write) }
+; CGSCC: attributes #[[ATTR16]] = { nofree willreturn memory(readwrite) }
+; CGSCC: attributes #[[ATTR17]] = { nosync }
+; CGSCC: attributes #[[ATTR18]] = { nounwind }
;.
; TUNIT: [[RNG0]] = !{i32 0, i32 -2147483648}
;.
More information about the llvm-commits
mailing list