Skip to content

Commit 9834ff9

Browse files
committed
[SimplifyCFG] Supporting hoisting/sinking callbases with differing attrs
Some (many) attributes can safely be dropped to enable sinking. For example removing `nonnull` on a return/param can't affect correctness.
1 parent 5ea0260 commit 9834ff9

File tree

6 files changed

+120
-118
lines changed

6 files changed

+120
-118
lines changed

llvm/include/llvm/IR/InstrTypes.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,6 +1461,22 @@ class CallBase : public Instruction {
14611461
///
14621462
void setAttributes(AttributeList A) { Attrs = A; }
14631463

1464+
/// Try to intersect the attributes from 'this' CallBase and the
1465+
/// 'Other' CallBase. Sets the intersected attributes to 'this' and
1466+
/// return true if successful. Doesn't modify 'this' and returns
1467+
/// false if unsuccessful.
1468+
bool tryIntersectAttributes(const CallBase *Other) {
1469+
if (this == Other)
1470+
return true;
1471+
AttributeList AL = getAttributes();
1472+
AttributeList ALOther = Other->getAttributes();
1473+
auto Intersected = AL.intersectWith(getContext(), ALOther);
1474+
if (!Intersected)
1475+
return false;
1476+
setAttributes(*Intersected);
1477+
return true;
1478+
}
1479+
14641480
/// Determine whether this call has the given attribute. If it does not
14651481
/// then determine if the called function has the attribute, but only if
14661482
/// the attribute is allowed for the call.

llvm/include/llvm/IR/Instruction.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -881,16 +881,20 @@ class Instruction : public User,
881881
/// This is like isIdenticalTo, except that it ignores the
882882
/// SubclassOptionalData flags, which may specify conditions under which the
883883
/// instruction's result is undefined.
884-
bool isIdenticalToWhenDefined(const Instruction *I) const LLVM_READONLY;
884+
bool
885+
isIdenticalToWhenDefined(const Instruction *I,
886+
bool IntersectAttrs = false) const LLVM_READONLY;
885887

886888
/// When checking for operation equivalence (using isSameOperationAs) it is
887889
/// sometimes useful to ignore certain attributes.
888890
enum OperationEquivalenceFlags {
889891
/// Check for equivalence ignoring load/store alignment.
890-
CompareIgnoringAlignment = 1<<0,
892+
CompareIgnoringAlignment = 1 << 0,
891893
/// Check for equivalence treating a type and a vector of that type
892894
/// as equivalent.
893-
CompareUsingScalarTypes = 1<<1
895+
CompareUsingScalarTypes = 1 << 1,
896+
/// Check for equivalence with intersected callbase attrs.
897+
CompareUsingIntersectedAttrs = 1 << 2,
894898
};
895899

896900
/// This function determines if the specified instruction executes the same
@@ -911,8 +915,8 @@ class Instruction : public User,
911915
/// @returns true if the specific instruction has the same opcde specific
912916
/// characteristics as the current one. Determine if one instruction has the
913917
/// same state as another.
914-
bool hasSameSpecialState(const Instruction *I2,
915-
bool IgnoreAlignment = false) const LLVM_READONLY;
918+
bool hasSameSpecialState(const Instruction *I2, bool IgnoreAlignment = false,
919+
bool IntersectAttrs = false) const LLVM_READONLY;
916920

917921
/// Return true if there are any uses of this instruction in blocks other than
918922
/// the specified block. Note that PHI nodes are considered to evaluate their

llvm/lib/IR/Instruction.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -785,11 +785,21 @@ const char *Instruction::getOpcodeName(unsigned OpCode) {
785785
/// This must be kept in sync with FunctionComparator::cmpOperations in
786786
/// lib/Transforms/IPO/MergeFunctions.cpp.
787787
bool Instruction::hasSameSpecialState(const Instruction *I2,
788-
bool IgnoreAlignment) const {
788+
bool IgnoreAlignment,
789+
bool IntersectAttrs) const {
789790
auto I1 = this;
790791
assert(I1->getOpcode() == I2->getOpcode() &&
791792
"Can not compare special state of different instructions");
792793

794+
auto CheckAttrsSame = [IntersectAttrs](const CallBase *CB0,
795+
const CallBase *CB1) {
796+
return IntersectAttrs
797+
? CB0->getAttributes()
798+
.intersectWith(CB0->getContext(), CB1->getAttributes())
799+
.has_value()
800+
: CB0->getAttributes() == CB1->getAttributes();
801+
};
802+
793803
if (const AllocaInst *AI = dyn_cast<AllocaInst>(I1))
794804
return AI->getAllocatedType() == cast<AllocaInst>(I2)->getAllocatedType() &&
795805
(AI->getAlign() == cast<AllocaInst>(I2)->getAlign() ||
@@ -811,15 +821,15 @@ bool Instruction::hasSameSpecialState(const Instruction *I2,
811821
if (const CallInst *CI = dyn_cast<CallInst>(I1))
812822
return CI->isTailCall() == cast<CallInst>(I2)->isTailCall() &&
813823
CI->getCallingConv() == cast<CallInst>(I2)->getCallingConv() &&
814-
CI->getAttributes() == cast<CallInst>(I2)->getAttributes() &&
824+
CheckAttrsSame(CI, cast<CallInst>(I2)) &&
815825
CI->hasIdenticalOperandBundleSchema(*cast<CallInst>(I2));
816826
if (const InvokeInst *CI = dyn_cast<InvokeInst>(I1))
817827
return CI->getCallingConv() == cast<InvokeInst>(I2)->getCallingConv() &&
818-
CI->getAttributes() == cast<InvokeInst>(I2)->getAttributes() &&
828+
CheckAttrsSame(CI, cast<InvokeInst>(I2)) &&
819829
CI->hasIdenticalOperandBundleSchema(*cast<InvokeInst>(I2));
820830
if (const CallBrInst *CI = dyn_cast<CallBrInst>(I1))
821831
return CI->getCallingConv() == cast<CallBrInst>(I2)->getCallingConv() &&
822-
CI->getAttributes() == cast<CallBrInst>(I2)->getAttributes() &&
832+
CheckAttrsSame(CI, cast<CallBrInst>(I2)) &&
823833
CI->hasIdenticalOperandBundleSchema(*cast<CallBrInst>(I2));
824834
if (const InsertValueInst *IVI = dyn_cast<InsertValueInst>(I1))
825835
return IVI->getIndices() == cast<InsertValueInst>(I2)->getIndices();
@@ -857,10 +867,10 @@ bool Instruction::isIdenticalTo(const Instruction *I) const {
857867
SubclassOptionalData == I->SubclassOptionalData;
858868
}
859869

860-
bool Instruction::isIdenticalToWhenDefined(const Instruction *I) const {
870+
bool Instruction::isIdenticalToWhenDefined(const Instruction *I,
871+
bool IntersectAttrs) const {
861872
if (getOpcode() != I->getOpcode() ||
862-
getNumOperands() != I->getNumOperands() ||
863-
getType() != I->getType())
873+
getNumOperands() != I->getNumOperands() || getType() != I->getType())
864874
return false;
865875

866876
// If both instructions have no operands, they are identical.
@@ -879,15 +889,16 @@ bool Instruction::isIdenticalToWhenDefined(const Instruction *I) const {
879889
otherPHI->block_begin());
880890
}
881891

882-
return this->hasSameSpecialState(I);
892+
return this->hasSameSpecialState(I, /*IgnoreAlignment=*/false, IntersectAttrs);
883893
}
884894

885895
// Keep this in sync with FunctionComparator::cmpOperations in
886896
// lib/Transforms/IPO/MergeFunctions.cpp.
887897
bool Instruction::isSameOperationAs(const Instruction *I,
888898
unsigned flags) const {
889899
bool IgnoreAlignment = flags & CompareIgnoringAlignment;
890-
bool UseScalarTypes = flags & CompareUsingScalarTypes;
900+
bool UseScalarTypes = flags & CompareUsingScalarTypes;
901+
bool IntersectAttrs = flags & CompareUsingIntersectedAttrs;
891902

892903
if (getOpcode() != I->getOpcode() ||
893904
getNumOperands() != I->getNumOperands() ||
@@ -905,7 +916,7 @@ bool Instruction::isSameOperationAs(const Instruction *I,
905916
getOperand(i)->getType() != I->getOperand(i)->getType())
906917
return false;
907918

908-
return this->hasSameSpecialState(I, IgnoreAlignment);
919+
return this->hasSameSpecialState(I, IgnoreAlignment, IntersectAttrs);
909920
}
910921

911922
bool Instruction::isUsedOutsideOfBlock(const BasicBlock *BB) const {

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ static void hoistLockstepIdenticalDbgVariableRecords(
15941594

15951595
static bool areIdenticalUpToCommutativity(const Instruction *I1,
15961596
const Instruction *I2) {
1597-
if (I1->isIdenticalToWhenDefined(I2))
1597+
if (I1->isIdenticalToWhenDefined(I2, /*IntersectAttrs=*/true))
15981598
return true;
15991599

16001600
if (auto *Cmp1 = dyn_cast<CmpInst>(I1))
@@ -1910,6 +1910,14 @@ bool SimplifyCFGOpt::hoistCommonCodeFromSuccessors(Instruction *TI,
19101910
if (!I2->use_empty())
19111911
I2->replaceAllUsesWith(I1);
19121912
I1->andIRFlags(I2);
1913+
if (auto *CB = dyn_cast<CallBase>(I1)) {
1914+
bool Success = CB->tryIntersectAttributes(cast<CallBase>(I2));
1915+
assert(Success && "We should not be trying to hoist callbases "
1916+
"with non-intersectable attributes");
1917+
// For NDEBUG Compile.
1918+
(void)Success;
1919+
}
1920+
19131921
combineMetadataForCSE(I1, I2, true);
19141922
// I1 and I2 are being combined into a single instruction. Its debug
19151923
// location is the merged locations of the original instructions.
@@ -2130,7 +2138,7 @@ static bool canSinkInstructions(
21302138
const Instruction *I0 = Insts.front();
21312139
const auto I0MMRA = MMRAMetadata(*I0);
21322140
for (auto *I : Insts) {
2133-
if (!I->isSameOperationAs(I0))
2141+
if (!I->isSameOperationAs(I0, Instruction::CompareUsingIntersectedAttrs))
21342142
return false;
21352143

21362144
// swifterror pointers can only be used by a load or store; sinking a load
@@ -2287,6 +2295,13 @@ static void sinkLastInstruction(ArrayRef<BasicBlock*> Blocks) {
22872295
I0->applyMergedLocation(I0->getDebugLoc(), I->getDebugLoc());
22882296
combineMetadataForCSE(I0, I, true);
22892297
I0->andIRFlags(I);
2298+
if (auto *CB = dyn_cast<CallBase>(I0)) {
2299+
bool Success = CB->tryIntersectAttributes(cast<CallBase>(I));
2300+
assert(Success && "We should not be trying to sink callbases "
2301+
"with non-intersectable attributes");
2302+
// For NDEBUG Compile.
2303+
(void)Success;
2304+
}
22902305
}
22912306

22922307
for (User *U : make_early_inc_range(I0->users())) {

llvm/test/Transforms/SimplifyCFG/hoist-cb-diff-attrs.ll

Lines changed: 28 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@ declare void @side.effect()
77
define ptr @test_hoist_int_attrs(i1 %c, ptr %p, i64 %x) {
88
; CHECK-LABEL: define {{[^@]+}}@test_hoist_int_attrs
99
; CHECK-SAME: (i1 [[C:%.*]], ptr [[P:%.*]], i64 [[X:%.*]]) {
10-
; CHECK-NEXT: br i1 [[C]], label [[IF:%.*]], label [[ELSE:%.*]]
10+
; CHECK-NEXT: [[R:%.*]] = call ptr @foo(ptr align 32 dereferenceable(50) dereferenceable_or_null(100) [[P]], i64 range(i64 10, 100000) [[X]]) #[[ATTR0:[0-9]+]]
11+
; CHECK-NEXT: br i1 [[C]], label [[COMMON_RET:%.*]], label [[ELSE:%.*]]
1112
; CHECK: common.ret:
12-
; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi ptr [ [[R:%.*]], [[IF]] ], [ [[R2:%.*]], [[ELSE]] ]
13-
; CHECK-NEXT: ret ptr [[COMMON_RET_OP]]
14-
; CHECK: if:
15-
; CHECK-NEXT: [[R]] = call ptr @foo(ptr align 64 dereferenceable(50) dereferenceable_or_null(100) [[P]], i64 range(i64 10, 1000) [[X]]) #[[ATTR0:[0-9]+]]
16-
; CHECK-NEXT: br label [[COMMON_RET:%.*]]
13+
; CHECK-NEXT: ret ptr [[R]]
1714
; CHECK: else:
18-
; CHECK-NEXT: [[R2]] = call ptr @foo(ptr align 32 dereferenceable(100) dereferenceable_or_null(200) [[P]], i64 range(i64 10000, 100000) [[X]]) #[[ATTR1:[0-9]+]]
1915
; CHECK-NEXT: call void @side.effect()
2016
; CHECK-NEXT: br label [[COMMON_RET]]
2117
;
@@ -33,15 +29,11 @@ else:
3329
define ptr @test_hoist_int_attrs2(i1 %c, ptr %p, i64 %x) {
3430
; CHECK-LABEL: define {{[^@]+}}@test_hoist_int_attrs2
3531
; CHECK-SAME: (i1 [[C:%.*]], ptr [[P:%.*]], i64 [[X:%.*]]) {
36-
; CHECK-NEXT: br i1 [[C]], label [[IF:%.*]], label [[ELSE:%.*]]
32+
; CHECK-NEXT: [[R:%.*]] = call ptr @foo(ptr dereferenceable(50) [[P]], i64 range(i64 10, 1000) [[X]]) #[[ATTR1:[0-9]+]]
33+
; CHECK-NEXT: br i1 [[C]], label [[COMMON_RET:%.*]], label [[ELSE:%.*]]
3734
; CHECK: common.ret:
38-
; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi ptr [ [[R:%.*]], [[IF]] ], [ [[R2:%.*]], [[ELSE]] ]
39-
; CHECK-NEXT: ret ptr [[COMMON_RET_OP]]
40-
; CHECK: if:
41-
; CHECK-NEXT: [[R]] = call ptr @foo(ptr dereferenceable(50) [[P]], i64 range(i64 10, 1000) [[X]]) #[[ATTR0]]
42-
; CHECK-NEXT: br label [[COMMON_RET:%.*]]
35+
; CHECK-NEXT: ret ptr [[R]]
4336
; CHECK: else:
44-
; CHECK-NEXT: [[R2]] = call ptr @foo(ptr align 32 dereferenceable(100) dereferenceable_or_null(200) [[P]], i64 range(i64 11, 100) [[X]]) #[[ATTR2:[0-9]+]]
4537
; CHECK-NEXT: call void @side.effect()
4638
; CHECK-NEXT: br label [[COMMON_RET]]
4739
;
@@ -59,15 +51,11 @@ else:
5951
define ptr @test_hoist_bool_attrs2(i1 %c, ptr %p, i64 %x) {
6052
; CHECK-LABEL: define {{[^@]+}}@test_hoist_bool_attrs2
6153
; CHECK-SAME: (i1 [[C:%.*]], ptr [[P:%.*]], i64 [[X:%.*]]) {
62-
; CHECK-NEXT: br i1 [[C]], label [[IF:%.*]], label [[ELSE:%.*]]
54+
; CHECK-NEXT: [[R:%.*]] = call noundef ptr @foo(ptr nonnull [[P]], i64 noundef [[X]]) #[[ATTR2:[0-9]+]]
55+
; CHECK-NEXT: br i1 [[C]], label [[COMMON_RET:%.*]], label [[ELSE:%.*]]
6356
; CHECK: common.ret:
64-
; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi ptr [ [[R:%.*]], [[IF]] ], [ [[R2:%.*]], [[ELSE]] ]
65-
; CHECK-NEXT: ret ptr [[COMMON_RET_OP]]
66-
; CHECK: if:
67-
; CHECK-NEXT: [[R]] = call noundef ptr @foo(ptr noundef nonnull readnone [[P]], i64 noundef [[X]]) #[[ATTR3:[0-9]+]]
68-
; CHECK-NEXT: br label [[COMMON_RET:%.*]]
57+
; CHECK-NEXT: ret ptr [[R]]
6958
; CHECK: else:
70-
; CHECK-NEXT: [[R2]] = call noundef nonnull ptr @foo(ptr nonnull readonly [[P]], i64 noundef [[X]]) #[[ATTR4:[0-9]+]]
7159
; CHECK-NEXT: call void @side.effect()
7260
; CHECK-NEXT: br label [[COMMON_RET]]
7361
;
@@ -85,15 +73,11 @@ else:
8573
define ptr @test_hoist_bool_attrs3(i1 %c, ptr %p, i64 %x) {
8674
; CHECK-LABEL: define {{[^@]+}}@test_hoist_bool_attrs3
8775
; CHECK-SAME: (i1 [[C:%.*]], ptr [[P:%.*]], i64 [[X:%.*]]) {
88-
; CHECK-NEXT: br i1 [[C]], label [[IF:%.*]], label [[ELSE:%.*]]
76+
; CHECK-NEXT: [[R:%.*]] = call nonnull ptr @foo(ptr [[P]], i64 noundef [[X]]) #[[ATTR3:[0-9]+]]
77+
; CHECK-NEXT: br i1 [[C]], label [[COMMON_RET:%.*]], label [[ELSE:%.*]]
8978
; CHECK: common.ret:
90-
; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi ptr [ [[R:%.*]], [[IF]] ], [ [[R2:%.*]], [[ELSE]] ]
91-
; CHECK-NEXT: ret ptr [[COMMON_RET_OP]]
92-
; CHECK: if:
93-
; CHECK-NEXT: [[R]] = call nonnull ptr @foo(ptr noundef readonly [[P]], i64 noundef [[X]]) #[[ATTR5:[0-9]+]]
94-
; CHECK-NEXT: br label [[COMMON_RET:%.*]]
79+
; CHECK-NEXT: ret ptr [[R]]
9580
; CHECK: else:
96-
; CHECK-NEXT: [[R2]] = call noundef nonnull ptr @foo(ptr nonnull writeonly [[P]], i64 noundef [[X]]) #[[ATTR6:[0-9]+]]
9781
; CHECK-NEXT: call void @side.effect()
9882
; CHECK-NEXT: br label [[COMMON_RET]]
9983
;
@@ -116,10 +100,10 @@ define ptr @test_hoist_bool_attrs_fail_non_droppable(i1 %c, ptr %p, i64 %x) {
116100
; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi ptr [ [[R:%.*]], [[IF]] ], [ [[R2:%.*]], [[ELSE]] ]
117101
; CHECK-NEXT: ret ptr [[COMMON_RET_OP]]
118102
; CHECK: if:
119-
; CHECK-NEXT: [[R]] = call nonnull ptr @foo(ptr noundef readonly [[P]], i64 noundef [[X]]) #[[ATTR5]]
103+
; CHECK-NEXT: [[R]] = call nonnull ptr @foo(ptr noundef readonly [[P]], i64 noundef [[X]]) #[[ATTR4:[0-9]+]]
120104
; CHECK-NEXT: br label [[COMMON_RET:%.*]]
121105
; CHECK: else:
122-
; CHECK-NEXT: [[R2]] = call noundef nonnull ptr @foo(ptr nonnull writeonly [[P]], i64 noundef [[X]]) #[[ATTR7:[0-9]+]]
106+
; CHECK-NEXT: [[R2]] = call noundef nonnull ptr @foo(ptr nonnull writeonly [[P]], i64 noundef [[X]]) #[[ATTR5:[0-9]+]]
123107
; CHECK-NEXT: call void @side.effect()
124108
; CHECK-NEXT: br label [[COMMON_RET]]
125109
;
@@ -142,10 +126,10 @@ define ptr @test_hoist_bool_attrs_fail_non_droppable2(i1 %c, ptr %p, i64 %x) {
142126
; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi ptr [ [[R:%.*]], [[IF]] ], [ [[R2:%.*]], [[ELSE]] ]
143127
; CHECK-NEXT: ret ptr [[COMMON_RET_OP]]
144128
; CHECK: if:
145-
; CHECK-NEXT: [[R]] = call nonnull ptr @foo(ptr noundef readonly [[P]], i64 noundef [[X]]) #[[ATTR8:[0-9]+]]
129+
; CHECK-NEXT: [[R]] = call nonnull ptr @foo(ptr noundef readonly [[P]], i64 noundef [[X]]) #[[ATTR6:[0-9]+]]
146130
; CHECK-NEXT: br label [[COMMON_RET:%.*]]
147131
; CHECK: else:
148-
; CHECK-NEXT: [[R2]] = call noundef nonnull ptr @foo(ptr nonnull writeonly byval(i64) [[P]], i64 noundef [[X]]) #[[ATTR7]]
132+
; CHECK-NEXT: [[R2]] = call noundef nonnull ptr @foo(ptr nonnull writeonly byval(i64) [[P]], i64 noundef [[X]]) #[[ATTR5]]
149133
; CHECK-NEXT: call void @side.effect()
150134
; CHECK-NEXT: br label [[COMMON_RET]]
151135
;
@@ -168,10 +152,10 @@ define ptr @test_hoist_bool_attrs_fail_non_droppable3(i1 %c, ptr %p, i64 %x) {
168152
; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi ptr [ [[R:%.*]], [[IF]] ], [ [[R2:%.*]], [[ELSE]] ]
169153
; CHECK-NEXT: ret ptr [[COMMON_RET_OP]]
170154
; CHECK: if:
171-
; CHECK-NEXT: [[R]] = call nonnull ptr @foo(ptr noundef readonly byval(i32) [[P]], i64 noundef [[X]]) #[[ATTR8]]
155+
; CHECK-NEXT: [[R]] = call nonnull ptr @foo(ptr noundef readonly byval(i32) [[P]], i64 noundef [[X]]) #[[ATTR6]]
172156
; CHECK-NEXT: br label [[COMMON_RET:%.*]]
173157
; CHECK: else:
174-
; CHECK-NEXT: [[R2]] = call noundef nonnull ptr @foo(ptr nonnull writeonly byval(i64) [[P]], i64 noundef [[X]]) #[[ATTR7]]
158+
; CHECK-NEXT: [[R2]] = call noundef nonnull ptr @foo(ptr nonnull writeonly byval(i64) [[P]], i64 noundef [[X]]) #[[ATTR5]]
175159
; CHECK-NEXT: call void @side.effect()
176160
; CHECK-NEXT: br label [[COMMON_RET]]
177161
;
@@ -189,15 +173,11 @@ else:
189173
define ptr @test_hoist_bool_attrs4(i1 %c, ptr %p, i64 %x) {
190174
; CHECK-LABEL: define {{[^@]+}}@test_hoist_bool_attrs4
191175
; CHECK-SAME: (i1 [[C:%.*]], ptr [[P:%.*]], i64 [[X:%.*]]) {
192-
; CHECK-NEXT: br i1 [[C]], label [[IF:%.*]], label [[ELSE:%.*]]
176+
; CHECK-NEXT: [[R:%.*]] = call nonnull ptr @foo(ptr byval(i64) [[P]], i64 noundef [[X]]) #[[ATTR5]]
177+
; CHECK-NEXT: br i1 [[C]], label [[COMMON_RET:%.*]], label [[ELSE:%.*]]
193178
; CHECK: common.ret:
194-
; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi ptr [ [[R:%.*]], [[IF]] ], [ [[R2:%.*]], [[ELSE]] ]
195-
; CHECK-NEXT: ret ptr [[COMMON_RET_OP]]
196-
; CHECK: if:
197-
; CHECK-NEXT: [[R]] = call nonnull ptr @foo(ptr noundef readonly byval(i64) [[P]], i64 noundef [[X]]) #[[ATTR8]]
198-
; CHECK-NEXT: br label [[COMMON_RET:%.*]]
179+
; CHECK-NEXT: ret ptr [[R]]
199180
; CHECK: else:
200-
; CHECK-NEXT: [[R2]] = call noundef nonnull ptr @foo(ptr nonnull writeonly byval(i64) [[P]], i64 noundef [[X]]) #[[ATTR7]]
201181
; CHECK-NEXT: call void @side.effect()
202182
; CHECK-NEXT: br label [[COMMON_RET]]
203183
;
@@ -212,13 +192,11 @@ else:
212192
ret ptr %r2
213193
}
214194
;.
215-
; CHECK: attributes #[[ATTR0]] = { memory(read) }
216-
; CHECK: attributes #[[ATTR1]] = { memory(write) }
217-
; CHECK: attributes #[[ATTR2]] = { memory(none) }
218-
; CHECK: attributes #[[ATTR3]] = { cold mustprogress nocallback nofree nosync willreturn }
219-
; CHECK: attributes #[[ATTR4]] = { mustprogress nocallback nofree willreturn }
220-
; CHECK: attributes #[[ATTR5]] = { alwaysinline cold nocallback nofree nosync willreturn }
221-
; CHECK: attributes #[[ATTR6]] = { alwaysinline nosync willreturn }
222-
; CHECK: attributes #[[ATTR7]] = { nosync willreturn }
223-
; CHECK: attributes #[[ATTR8]] = { cold nocallback nofree nosync willreturn }
195+
; CHECK: attributes #[[ATTR0]] = { memory(readwrite) }
196+
; CHECK: attributes #[[ATTR1]] = { memory(read) }
197+
; CHECK: attributes #[[ATTR2]] = { mustprogress nocallback nofree willreturn }
198+
; CHECK: attributes #[[ATTR3]] = { alwaysinline nosync willreturn }
199+
; CHECK: attributes #[[ATTR4]] = { alwaysinline cold nocallback nofree nosync willreturn }
200+
; CHECK: attributes #[[ATTR5]] = { nosync willreturn }
201+
; CHECK: attributes #[[ATTR6]] = { cold nocallback nofree nosync willreturn }
224202
;.

0 commit comments

Comments
 (0)