Skip to content

Commit b7e51b4

Browse files
authored
[IPSCCP] Infer attributes on arguments (#107114)
During inter-procedural SCCP, also infer attributes on arguments, not just return values. This allows other non-interprocedural passes to make use of the information later.
1 parent b29c5b6 commit b7e51b4

File tree

15 files changed

+91
-52
lines changed

15 files changed

+91
-52
lines changed

llvm/include/llvm/IR/Function.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,9 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
445445
/// gets the attribute from the list of attributes.
446446
Attribute getAttributeAtIndex(unsigned i, StringRef Kind) const;
447447

448+
/// Check if attribute of the given kind is set at the given index.
449+
bool hasAttributeAtIndex(unsigned Idx, Attribute::AttrKind Kind) const;
450+
448451
/// Return the attribute for the given attribute kind.
449452
Attribute getFnAttribute(Attribute::AttrKind Kind) const;
450453

llvm/include/llvm/Transforms/Utils/SCCPSolver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ class SCCPSolver {
104104
/// argument-tracked functions.
105105
bool isArgumentTrackedFunction(Function *F);
106106

107+
const SmallPtrSetImpl<Function *> &getArgumentTrackedFunctions() const;
108+
107109
/// Solve - Solve for constants and executable blocks.
108110
void solve();
109111

@@ -191,6 +193,7 @@ class SCCPSolver {
191193
BasicBlock *&NewUnreachableBB) const;
192194

193195
void inferReturnAttributes() const;
196+
void inferArgAttributes() const;
194197

195198
bool tryToReplaceWithConstant(Value *V);
196199

llvm/lib/IR/Function.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,11 @@ Attribute Function::getAttributeAtIndex(unsigned i, StringRef Kind) const {
765765
return AttributeSets.getAttributeAtIndex(i, Kind);
766766
}
767767

768+
bool Function::hasAttributeAtIndex(unsigned Idx,
769+
Attribute::AttrKind Kind) const {
770+
return AttributeSets.hasAttributeAtIndex(Idx, Kind);
771+
}
772+
768773
Attribute Function::getFnAttribute(Attribute::AttrKind Kind) const {
769774
return AttributeSets.getFnAttr(Kind);
770775
}

llvm/lib/Transforms/IPO/SCCP.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ static bool runIPSCCP(
278278
SmallVector<ReturnInst*, 8> ReturnsToZap;
279279

280280
Solver.inferReturnAttributes();
281+
Solver.inferArgAttributes();
281282
for (const auto &[F, ReturnValue] : Solver.getTrackedRetVals()) {
282283
assert(!F->getReturnType()->isVoidTy() &&
283284
"should not track void functions");

llvm/lib/Transforms/Utils/SCCPSolver.cpp

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -341,31 +341,45 @@ bool SCCPSolver::removeNonFeasibleEdges(BasicBlock *BB, DomTreeUpdater &DTU,
341341
return true;
342342
}
343343

344+
static void inferAttribute(Function *F, unsigned AttrIndex,
345+
const ValueLatticeElement &Val) {
346+
// If there is a known constant range for the value, add range attribute.
347+
if (Val.isConstantRange() && !Val.getConstantRange().isSingleElement()) {
348+
// Do not add range attribute if the value may include undef.
349+
if (Val.isConstantRangeIncludingUndef())
350+
return;
351+
352+
// Take the intersection of the existing attribute and the inferred range.
353+
Attribute OldAttr = F->getAttributeAtIndex(AttrIndex, Attribute::Range);
354+
ConstantRange CR = Val.getConstantRange();
355+
if (OldAttr.isValid())
356+
CR = CR.intersectWith(OldAttr.getRange());
357+
F->addAttributeAtIndex(
358+
AttrIndex, Attribute::get(F->getContext(), Attribute::Range, CR));
359+
return;
360+
}
361+
// Infer nonnull attribute.
362+
if (Val.isNotConstant() && Val.getNotConstant()->getType()->isPointerTy() &&
363+
Val.getNotConstant()->isNullValue() &&
364+
!F->hasAttributeAtIndex(AttrIndex, Attribute::NonNull)) {
365+
F->addAttributeAtIndex(AttrIndex,
366+
Attribute::get(F->getContext(), Attribute::NonNull));
367+
}
368+
}
369+
344370
void SCCPSolver::inferReturnAttributes() const {
345-
for (const auto &[F, ReturnValue] : getTrackedRetVals()) {
346-
347-
// If there is a known constant range for the return value, add range
348-
// attribute to the return value.
349-
if (ReturnValue.isConstantRange() &&
350-
!ReturnValue.getConstantRange().isSingleElement()) {
351-
// Do not add range metadata if the return value may include undef.
352-
if (ReturnValue.isConstantRangeIncludingUndef())
353-
continue;
371+
for (const auto &[F, ReturnValue] : getTrackedRetVals())
372+
inferAttribute(F, AttributeList::ReturnIndex, ReturnValue);
373+
}
354374

355-
// Take the intersection of the existing attribute and the inferred range.
356-
ConstantRange CR = ReturnValue.getConstantRange();
357-
if (F->hasRetAttribute(Attribute::Range))
358-
CR = CR.intersectWith(F->getRetAttribute(Attribute::Range).getRange());
359-
F->addRangeRetAttr(CR);
360-
continue;
361-
}
362-
// Infer nonnull return attribute.
363-
if (F->getReturnType()->isPointerTy() && ReturnValue.isNotConstant() &&
364-
ReturnValue.getNotConstant()->isNullValue() &&
365-
!F->hasRetAttribute(Attribute::NonNull)) {
366-
F->addRetAttr(Attribute::NonNull);
375+
void SCCPSolver::inferArgAttributes() const {
376+
for (Function *F : getArgumentTrackedFunctions()) {
377+
if (!isBlockExecutable(&F->front()))
367378
continue;
368-
}
379+
for (Argument &A : F->args())
380+
if (!A.getType()->isStructTy())
381+
inferAttribute(F, AttributeList::FirstArgIndex + A.getArgNo(),
382+
getLatticeValueFor(&A));
369383
}
370384
}
371385

@@ -766,6 +780,10 @@ class SCCPInstVisitor : public InstVisitor<SCCPInstVisitor> {
766780
return TrackingIncomingArguments.count(F);
767781
}
768782

783+
const SmallPtrSetImpl<Function *> &getArgumentTrackedFunctions() const {
784+
return TrackingIncomingArguments;
785+
}
786+
769787
void solve();
770788

771789
bool resolvedUndef(Instruction &I);
@@ -2140,6 +2158,11 @@ bool SCCPSolver::isArgumentTrackedFunction(Function *F) {
21402158
return Visitor->isArgumentTrackedFunction(F);
21412159
}
21422160

2161+
const SmallPtrSetImpl<Function *> &
2162+
SCCPSolver::getArgumentTrackedFunctions() const {
2163+
return Visitor->getArgumentTrackedFunctions();
2164+
}
2165+
21432166
void SCCPSolver::solve() { Visitor->solve(); }
21442167

21452168
bool SCCPSolver::resolvedUndefsIn(Function &F) {

llvm/test/Transforms/FunctionSpecialization/discover-transitive-phis.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ entry:
2929

3030
define internal i64 @foo(i64 %n, i1 %c1, i1 %c2, i1 %c3, i1 %c4, i1 %c5, i1 %c6, i1 %c7, i1 %c8, i1 %c9, i1 %c10) {
3131
; NOFUNCSPEC-LABEL: define internal range(i64 2, 7) i64 @foo(
32-
; NOFUNCSPEC-SAME: i64 [[N:%.*]], i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]], i1 [[C4:%.*]], i1 [[C5:%.*]], i1 [[C6:%.*]], i1 [[C7:%.*]], i1 [[C8:%.*]], i1 [[C9:%.*]], i1 [[C10:%.*]]) {
32+
; NOFUNCSPEC-SAME: i64 range(i64 3, 5) [[N:%.*]], i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]], i1 [[C4:%.*]], i1 [[C5:%.*]], i1 [[C6:%.*]], i1 [[C7:%.*]], i1 [[C8:%.*]], i1 [[C9:%.*]], i1 [[C10:%.*]]) {
3333
; NOFUNCSPEC-NEXT: entry:
3434
; NOFUNCSPEC-NEXT: br i1 [[C1]], label [[L1:%.*]], label [[L9:%.*]]
3535
; NOFUNCSPEC: l1:

llvm/test/Transforms/SCCP/ip-add-range-to-call.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
; can be added to call sites.
77
define internal i32 @callee(i32 %x) {
88
; CHECK-LABEL: define internal range(i32 0, 21) i32 @callee(
9-
; CHECK-SAME: i32 [[X:%.*]]) {
9+
; CHECK-SAME: i32 range(i32 0, 21) [[X:%.*]]) {
1010
; CHECK-NEXT: ret i32 [[X]]
1111
;
1212
ret i32 %x
@@ -133,7 +133,7 @@ define void @caller_cb3() {
133133
; should be added at call sites.
134134
define internal i32 @callee5(i32 %x, i32 %y) {
135135
; CHECK-LABEL: define internal i32 @callee5(
136-
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {
136+
; CHECK-SAME: i32 range(i32 10, 21) [[X:%.*]], i32 range(i32 100, 201) [[Y:%.*]]) {
137137
; CHECK-NEXT: [[C:%.*]] = icmp slt i32 [[X]], 15
138138
; CHECK-NEXT: br i1 [[C]], label [[BB1:%.*]], label [[BB2:%.*]]
139139
; CHECK: bb1:

llvm/test/Transforms/SCCP/ip-constant-ranges.ll

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
; Constant range for %a is [1, 48) and for %b is [301, 1000)
55
define internal i32 @f1(i32 %a, i32 %b) {
66
; CHECK-LABEL: define {{[^@]+}}@f1
7-
; CHECK-SAME: (i32 [[A:%.*]], i32 [[B:%.*]]) {
7+
; CHECK-SAME: (i32 range(i32 1, 48) [[A:%.*]], i32 range(i32 301, 1000) [[B:%.*]]) {
88
; CHECK-NEXT: entry:
99
; CHECK-NEXT: ret i32 poison
1010
;
@@ -27,7 +27,7 @@ entry:
2727
; Constant range for %x is [47, 302)
2828
define internal i32 @f2(i32 %x) {
2929
; CHECK-LABEL: define {{[^@]+}}@f2
30-
; CHECK-SAME: (i32 [[X:%.*]]) {
30+
; CHECK-SAME: (i32 range(i32 47, 302) [[X:%.*]]) {
3131
; CHECK-NEXT: entry:
3232
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X]], 300
3333
; CHECK-NEXT: [[CMP4:%.*]] = icmp ugt i32 [[X]], 300
@@ -79,7 +79,7 @@ entry:
7979

8080
define internal i32 @f3(i32 %x) {
8181
; CHECK-LABEL: define {{[^@]+}}@f3
82-
; CHECK-SAME: (i32 [[X:%.*]]) {
82+
; CHECK-SAME: (i32 range(i32 0, 2) [[X:%.*]]) {
8383
; CHECK-NEXT: entry:
8484
; CHECK-NEXT: ret i32 poison
8585
;
@@ -116,7 +116,7 @@ end:
116116

117117
define internal i32 @f4(i32 %x) {
118118
; CHECK-LABEL: define {{[^@]+}}@f4
119-
; CHECK-SAME: (i32 [[X:%.*]]) {
119+
; CHECK-SAME: (i32 range(i32 301, -2147483648) [[X:%.*]]) {
120120
; CHECK-NEXT: entry:
121121
; CHECK-NEXT: ret i32 poison
122122
;
@@ -170,7 +170,7 @@ entry:
170170

171171
define internal i1 @test_unreachable_callee(i32 %a) {
172172
; CHECK-LABEL: define {{[^@]+}}@test_unreachable_callee
173-
; CHECK-SAME: (i32 [[A:%.*]]) {
173+
; CHECK-SAME: (i32 range(i32 1, 3) [[A:%.*]]) {
174174
; CHECK-NEXT: entry:
175175
; CHECK-NEXT: ret i1 poison
176176
;
@@ -199,7 +199,7 @@ define double @test_struct({ double, double } %test) {
199199
; Constant range for %x is [47, 302)
200200
define internal i32 @f5(i32 %x) {
201201
; CHECK-LABEL: define {{[^@]+}}@f5
202-
; CHECK-SAME: (i32 [[X:%.*]]) {
202+
; CHECK-SAME: (i32 range(i32 47, 302) [[X:%.*]]) {
203203
; CHECK-NEXT: entry:
204204
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X]], undef
205205
; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i32 undef, [[X]]
@@ -282,7 +282,7 @@ entry:
282282

283283
define internal i32 @callee6.1(i32 %i) {
284284
; CHECK-LABEL: define {{[^@]+}}@callee6.1
285-
; CHECK-SAME: (i32 [[I:%.*]]) {
285+
; CHECK-SAME: (i32 range(i32 30, 44) [[I:%.*]]) {
286286
; CHECK-NEXT: [[RES:%.*]] = call i32 @callee6.2(i32 [[I]])
287287
; CHECK-NEXT: ret i32 poison
288288
;
@@ -292,7 +292,7 @@ define internal i32 @callee6.1(i32 %i) {
292292

293293
define internal i32 @callee6.2(i32 %i) {
294294
; CHECK-LABEL: define {{[^@]+}}@callee6.2
295-
; CHECK-SAME: (i32 [[I:%.*]]) {
295+
; CHECK-SAME: (i32 range(i32 30, 44) [[I:%.*]]) {
296296
; CHECK-NEXT: br label [[IF_THEN:%.*]]
297297
; CHECK: if.then:
298298
; CHECK-NEXT: ret i32 poison

llvm/test/Transforms/SCCP/ip-ranges-casts.ll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
; x = [100, 301)
55
define internal i1 @f.trunc(i32 %x) {
66
; CHECK-LABEL: define internal i1 @f.trunc(
7-
; CHECK-SAME: i32 [[X:%.*]]) {
7+
; CHECK-SAME: i32 range(i32 100, 301) [[X:%.*]]) {
88
; CHECK-NEXT: [[T_1:%.*]] = trunc nuw nsw i32 [[X]] to i16
99
; CHECK-NEXT: [[C_2:%.*]] = icmp sgt i16 [[T_1]], 299
1010
; CHECK-NEXT: [[C_4:%.*]] = icmp slt i16 [[T_1]], 101
@@ -60,7 +60,7 @@ define i1 @caller1() {
6060
; x = [100, 301)
6161
define internal i1 @f.zext(i32 %x, i32 %y) {
6262
; CHECK-LABEL: define internal i1 @f.zext(
63-
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {
63+
; CHECK-SAME: i32 range(i32 100, 301) [[X:%.*]], i32 range(i32 -120, 901) [[Y:%.*]]) {
6464
; CHECK-NEXT: [[T_1:%.*]] = zext nneg i32 [[X]] to i64
6565
; CHECK-NEXT: [[C_2:%.*]] = icmp sgt i64 [[T_1]], 299
6666
; CHECK-NEXT: [[C_4:%.*]] = icmp slt i64 [[T_1]], 101
@@ -114,7 +114,7 @@ define i1 @caller.zext() {
114114
; x = [100, 301)
115115
define internal i1 @f.sext(i32 %x, i32 %y) {
116116
; CHECK-LABEL: define internal i1 @f.sext(
117-
; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {
117+
; CHECK-SAME: i32 range(i32 100, 301) [[X:%.*]], i32 range(i32 -120, 901) [[Y:%.*]]) {
118118
; CHECK-NEXT: [[T_1:%.*]] = zext nneg i32 [[X]] to i64
119119
; CHECK-NEXT: [[C_2:%.*]] = icmp sgt i64 [[T_1]], 299
120120
; CHECK-NEXT: [[C_4:%.*]] = icmp slt i64 [[T_1]], 101
@@ -166,7 +166,7 @@ define i1 @caller.sext() {
166166
; There's nothing we can do besides going to the full range or overdefined.
167167
define internal i1 @f.fptosi(i32 %x) {
168168
; CHECK-LABEL: define internal i1 @f.fptosi(
169-
; CHECK-SAME: i32 [[X:%.*]]) {
169+
; CHECK-SAME: i32 range(i32 100, 301) [[X:%.*]]) {
170170
; CHECK-NEXT: [[TO_DOUBLE:%.*]] = uitofp nneg i32 [[X]] to double
171171
; CHECK-NEXT: [[ADD:%.*]] = fadd double 0.000000e+00, [[TO_DOUBLE]]
172172
; CHECK-NEXT: [[TO_I32:%.*]] = fptosi double [[ADD]] to i32
@@ -208,7 +208,7 @@ define i1 @caller.fptosi() {
208208
; There's nothing we can do besides going to the full range or overdefined.
209209
define internal i1 @f.fpext(i16 %x) {
210210
; CHECK-LABEL: define internal i1 @f.fpext(
211-
; CHECK-SAME: i16 [[X:%.*]]) {
211+
; CHECK-SAME: i16 range(i16 100, 301) [[X:%.*]]) {
212212
; CHECK-NEXT: [[TO_FLOAT:%.*]] = uitofp nneg i16 [[X]] to float
213213
; CHECK-NEXT: [[TO_DOUBLE:%.*]] = fpext float [[TO_FLOAT]] to double
214214
; CHECK-NEXT: [[TO_I64:%.*]] = fptoui float [[TO_FLOAT]] to i64
@@ -251,7 +251,7 @@ define i1 @caller.fpext() {
251251
; There's nothing we can do besides going to the full range or overdefined.
252252
define internal i1 @f.inttoptr.ptrtoint(i64 %x) {
253253
; CHECK-LABEL: define internal i1 @f.inttoptr.ptrtoint(
254-
; CHECK-SAME: i64 [[X:%.*]]) {
254+
; CHECK-SAME: i64 range(i64 100, 301) [[X:%.*]]) {
255255
; CHECK-NEXT: [[TO_PTR:%.*]] = inttoptr i64 [[X]] to ptr
256256
; CHECK-NEXT: [[TO_I64:%.*]] = ptrtoint ptr [[TO_PTR]] to i64
257257
; CHECK-NEXT: [[C_1:%.*]] = icmp sgt i64 [[TO_I64]], 300
@@ -325,7 +325,7 @@ entry:
325325

326326
define internal i64 @f.sext_to_zext(i32 %t) {
327327
; CHECK-LABEL: define internal range(i64 0, 2) i64 @f.sext_to_zext(
328-
; CHECK-SAME: i32 [[T:%.*]]) {
328+
; CHECK-SAME: i32 range(i32 0, 2) [[T:%.*]]) {
329329
; CHECK-NEXT: [[A:%.*]] = zext nneg i32 [[T]] to i64
330330
; CHECK-NEXT: ret i64 [[A]]
331331
;

llvm/test/Transforms/SCCP/ip-ranges-phis.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
define internal i32 @f1(i32 %x) {
55
; CHECK-LABEL: define {{[^@]+}}@f1
6-
; CHECK-SAME: (i32 [[X:%.*]]) {
6+
; CHECK-SAME: (i32 range(i32 0, 2) [[X:%.*]]) {
77
; CHECK-NEXT: ret i32 poison
88
;
99
%cmp = icmp sgt i32 %x, 300
@@ -40,7 +40,7 @@ end:
4040

4141
define internal i32 @f2(i32 %x, i32 %y, i32 %z, i1 %cmp.1, i1 %cmp.2) {
4242
; CHECK-LABEL: define {{[^@]+}}@f2
43-
; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]], i1 [[CMP_1:%.*]], i1 [[CMP_2:%.*]]) {
43+
; CHECK-SAME: (i32 range(i32 0, 2) [[X:%.*]], i32 range(i32 -10, 2) [[Y:%.*]], i32 range(i32 1, 11) [[Z:%.*]], i1 [[CMP_1:%.*]], i1 [[CMP_2:%.*]]) {
4444
; CHECK-NEXT: entry:
4545
; CHECK-NEXT: br i1 [[CMP_1]], label [[IF_TRUE_1:%.*]], label [[END:%.*]]
4646
; CHECK: if.true.1:
@@ -133,7 +133,7 @@ end:
133133

134134
define internal i32 @f3(i32 %x, i32 %y, i1 %cmp.1) {
135135
; CHECK-LABEL: define {{[^@]+}}@f3
136-
; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]], i1 [[CMP_1:%.*]]) {
136+
; CHECK-SAME: (i32 range(i32 0, 6) [[X:%.*]], i32 [[Y:%.*]], i1 [[CMP_1:%.*]]) {
137137
; CHECK-NEXT: entry:
138138
; CHECK-NEXT: br i1 [[CMP_1]], label [[IF_TRUE_1:%.*]], label [[END:%.*]]
139139
; CHECK: if.true.1:

llvm/test/Transforms/SCCP/ip-ranges-select.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ define void @caller.1(ptr %arg) {
1818

1919
define internal i32 @callee.1(i32 %arg) {
2020
; CHECK-LABEL: define {{[^@]+}}@callee.1
21-
; CHECK-SAME: (i32 [[ARG:%.*]]) {
21+
; CHECK-SAME: (i32 range(i32 2, 5) [[ARG:%.*]]) {
2222
; CHECK-NEXT: [[SEL:%.*]] = select i1 false, i32 16, i32 [[ARG]]
2323
; CHECK-NEXT: br label [[BB10:%.*]]
2424
; CHECK: bb10:
@@ -40,7 +40,7 @@ declare void @use(i32)
4040

4141
define internal i1 @f1(i32 %x, i32 %y, i1 %cmp) {
4242
; CHECK-LABEL: define {{[^@]+}}@f1
43-
; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]], i1 [[CMP:%.*]]) {
43+
; CHECK-SAME: (i32 range(i32 10, 21) [[X:%.*]], i32 range(i32 100, 201) [[Y:%.*]], i1 [[CMP:%.*]]) {
4444
; CHECK-NEXT: [[SEL_1:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[Y]]
4545
; CHECK-NEXT: [[C_2:%.*]] = icmp sgt i32 [[SEL_1]], 100
4646
; CHECK-NEXT: [[C_3:%.*]] = icmp eq i32 [[SEL_1]], 50

llvm/test/Transforms/SCCP/musttail-call.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ define internal ptr @no_side_effects(i8 %v) readonly nounwind willreturn {
7171
; return value should stay as it is, and should not be zapped.
7272
define internal ptr @dont_zap_me(i8 %v) {
7373
; CHECK-LABEL: define {{[^@]+}}@dont_zap_me
74-
; CHECK-SAME: (i8 [[V:%.*]]) {
74+
; CHECK-SAME: (i8 range(i8 2, 0) [[V:%.*]]) {
7575
; CHECK-NEXT: [[I1:%.*]] = call i32 @external()
7676
; CHECK-NEXT: ret ptr null
7777
;

llvm/test/Transforms/SCCP/pointer-nonnull.ll

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,13 @@ define ptr @ret_maybe_null_pointer(ptr %p) {
248248
}
249249

250250
define internal void @ip_nonnull_arg_callee(ptr %p) {
251-
; CHECK-LABEL: define internal void @ip_nonnull_arg_callee(
252-
; CHECK-SAME: ptr [[P:%.*]]) {
253-
; CHECK-NEXT: ret void
251+
; SCCP-LABEL: define internal void @ip_nonnull_arg_callee(
252+
; SCCP-SAME: ptr [[P:%.*]]) {
253+
; SCCP-NEXT: ret void
254+
;
255+
; IPSCCP-LABEL: define internal void @ip_nonnull_arg_callee(
256+
; IPSCCP-SAME: ptr nonnull [[P:%.*]]) {
257+
; IPSCCP-NEXT: ret void
254258
;
255259
ret void
256260
}

llvm/test/Transforms/SCCP/resolvedundefsin-tracked-fn.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ entry:
5656

5757
define internal i1 @test1_g(ptr %h, i32 %i) #0 {
5858
; CHECK-LABEL: define {{[^@]+}}@test1_g
59-
; CHECK-SAME: (ptr [[H:%.*]], i32 [[I:%.*]]) {
59+
; CHECK-SAME: (ptr [[H:%.*]], i32 range(i32 0, 2) [[I:%.*]]) {
6060
; CHECK-NEXT: entry:
6161
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[I]], 0
6262
; CHECK-NEXT: br i1 [[TOBOOL]], label [[LAND_RHS:%.*]], label [[LAND_END:%.*]]
@@ -221,7 +221,7 @@ exit:
221221

222222
define internal i1 @test3_g(ptr %h, i32 %i) {
223223
; CHECK-LABEL: define {{[^@]+}}@test3_g
224-
; CHECK-SAME: (ptr [[H:%.*]], i32 [[I:%.*]]) {
224+
; CHECK-SAME: (ptr [[H:%.*]], i32 range(i32 0, 2) [[I:%.*]]) {
225225
; CHECK-NEXT: entry:
226226
; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[I]], 0
227227
; CHECK-NEXT: br i1 [[TOBOOL]], label [[LAND_RHS:%.*]], label [[LAND_END:%.*]]

llvm/test/Transforms/SCCP/switch.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ switch.2:
207207
; range information.
208208
define internal i32 @test_ip_range(i32 %x) {
209209
; CHECK-LABEL: define internal range(i32 1, 4) i32 @test_ip_range(
210-
; CHECK-SAME: i32 [[X:%.*]]) {
210+
; CHECK-SAME: i32 range(i32 1, 4) [[X:%.*]]) {
211211
; CHECK-NEXT: switch i32 [[X]], label [[DEFAULT_UNREACHABLE:%.*]] [
212212
; CHECK-NEXT: i32 3, label [[SWITCH_3:%.*]]
213213
; CHECK-NEXT: i32 1, label [[SWITCH_1:%.*]]

0 commit comments

Comments
 (0)