Skip to content

Commit f78610a

Browse files
authored
[InstCombine] Add function attribute instcombine-no-verify-fixpoint (#113822)
This patch introduces a function attribute `instcombine-no-verify-fixpoint` to avoids disabling fix-point verification for unrelated tests in the same file. Address comment #112642 (comment).
1 parent fa4790e commit f78610a

File tree

12 files changed

+43
-41
lines changed

12 files changed

+43
-41
lines changed

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5464,6 +5464,8 @@ static bool combineInstructionsOverFunction(
54645464
BranchProbabilityInfo *BPI, ProfileSummaryInfo *PSI,
54655465
const InstCombineOptions &Opts) {
54665466
auto &DL = F.getDataLayout();
5467+
bool VerifyFixpoint = Opts.VerifyFixpoint &&
5468+
!F.hasFnAttribute("instcombine-no-verify-fixpoint");
54675469

54685470
/// Builder - This is an IRBuilder that automatically inserts new
54695471
/// instructions into the worklist when they are created.
@@ -5488,7 +5490,7 @@ static bool combineInstructionsOverFunction(
54885490
while (true) {
54895491
++Iteration;
54905492

5491-
if (Iteration > Opts.MaxIterations && !Opts.VerifyFixpoint) {
5493+
if (Iteration > Opts.MaxIterations && !VerifyFixpoint) {
54925494
LLVM_DEBUG(dbgs() << "\n\n[IC] Iteration limit #" << Opts.MaxIterations
54935495
<< " on " << F.getName()
54945496
<< " reached; stopping without verifying fixpoint\n");
@@ -5510,9 +5512,11 @@ static bool combineInstructionsOverFunction(
55105512
MadeIRChange = true;
55115513
if (Iteration > Opts.MaxIterations) {
55125514
report_fatal_error(
5513-
"Instruction Combining did not reach a fixpoint after " +
5514-
Twine(Opts.MaxIterations) + " iterations. " +
5515-
"Use 'instcombine<no-verify-fixpoint>' to suppress this error.",
5515+
"Instruction Combining on " + Twine(F.getName()) +
5516+
" did not reach a fixpoint after " + Twine(Opts.MaxIterations) +
5517+
" iterations. " +
5518+
"Use 'instcombine<no-verify-fixpoint>' or function attribute "
5519+
"'instcombine-no-verify-fixpoint' to suppress this error.",
55165520
/*GenCrashDiag=*/false);
55175521
}
55185522
}

llvm/test/Analysis/ValueTracking/numsignbits-from-assume.ll

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt < %s -passes='instcombine<no-verify-fixpoint>' -S | FileCheck %s
3-
4-
; FIXME: This does not currently reach a fix point, because an assume can only
5-
; be propagated backwards after its argument has been simplified.
2+
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
63

74
define i32 @computeNumSignBits_add1(i32 %in) {
85
; CHECK-LABEL: @computeNumSignBits_add1(

llvm/test/Transforms/InstCombine/2007-10-31-RangeCrash.ll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2-
; RUN: opt < %s -S -passes='instcombine<no-verify-fixpoint>' | FileCheck %s
2+
; RUN: opt < %s -S -passes=instcombine | FileCheck %s
33

44
; We do not reach a fixpoint, because we first have to infer nsw on the IV add,
55
; and could eliminate the icmp slt afterwards, but don't revisit it.
66

77
target datalayout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f128:64:128"
88

9-
define i32 @test() {
10-
; CHECK-LABEL: define i32 @test() {
9+
define i32 @test() "instcombine-no-verify-fixpoint" {
10+
; CHECK-LABEL: define i32 @test(
11+
; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
1112
; CHECK-NEXT: entry:
1213
; CHECK-NEXT: br i1 true, label [[BB_I:%.*]], label [[CALCULATECOLORSPECIFICBLACKLEVEL_EXIT:%.*]]
1314
; CHECK: bb.i:

llvm/test/Transforms/InstCombine/cast_phi.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt < %s -passes="instcombine<no-verify-fixpoint>" -S | FileCheck %s
2+
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
33

44
target datalayout = "n32:64"
55

@@ -309,7 +309,7 @@ exit:
309309
ret i64 %r
310310
}
311311

312-
define i8 @trunc_in_loop_exit_block() {
312+
define i8 @trunc_in_loop_exit_block() "instcombine-no-verify-fixpoint" {
313313
; CHECK-LABEL: @trunc_in_loop_exit_block(
314314
; CHECK-NEXT: entry:
315315
; CHECK-NEXT: br label [[LOOP:%.*]]

llvm/test/Transforms/InstCombine/constant-fold-iteration.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
; RUN: opt < %s -passes='instcombine<no-verify-fixpoint>' -S -debug 2>&1 | FileCheck %s
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt < %s -passes=instcombine -S -debug 2>&1 | FileCheck %s
23
; REQUIRES: asserts
34
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
45

56
; This test disables fixpoint verification, because that would cause a second
67
; iteration for verification.
78

8-
define i32 @a() nounwind readnone {
9+
define i32 @a() nounwind readnone "instcombine-no-verify-fixpoint" {
910
entry:
1011
%cmp = icmp eq i32 0, ptrtoint (ptr @a to i32)
1112
%ext = zext i1 %cmp to i32

llvm/test/Transforms/InstCombine/icmp-or.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt < %s -passes='instcombine<no-verify-fixpoint>' -S | FileCheck %s
2+
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
33

44
declare void @use(i8)
55

@@ -432,7 +432,7 @@ define i1 @icmp_or_xor_2_ne_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
432432
; simplify `%cmp_1 = icmp eq i64 %xor, 0`, `%xor = xor i64 %x1, %y1`
433433
; has one use which allows for complete simplification (rooted on
434434
; `%or1 = or i1 %cmp, %cmp_1` so we don't end up adding it back).
435-
define i1 @icmp_or_xor_2_3_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
435+
define i1 @icmp_or_xor_2_3_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) "instcombine-no-verify-fixpoint" {
436436
; CHECK-LABEL: @icmp_or_xor_2_3_fail(
437437
; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
438438
; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]
@@ -453,7 +453,7 @@ define i1 @icmp_or_xor_2_3_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
453453

454454
; negative test - xor multiuse
455455

456-
define i1 @icmp_or_xor_2_4_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) {
456+
define i1 @icmp_or_xor_2_4_fail(i64 %x1, i64 %y1, i64 %x2, i64 %y2) "instcombine-no-verify-fixpoint" {
457457
; CHECK-LABEL: @icmp_or_xor_2_4_fail(
458458
; CHECK-NEXT: [[XOR:%.*]] = xor i64 [[X1:%.*]], [[Y1:%.*]]
459459
; CHECK-NEXT: [[XOR1:%.*]] = xor i64 [[X2:%.*]], [[Y2:%.*]]

llvm/test/Transforms/InstCombine/pr55228.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt -S -passes='instcombine<no-verify-fixpoint>' < %s | FileCheck %s
2+
; RUN: opt -S -passes=instcombine < %s | FileCheck %s
33

44
; This does not reach a fixpoint, because the global initializer is not in
55
; folded form. This will not happen if preceded by a GlobalOpt run.
@@ -9,7 +9,7 @@ target datalayout = "p:8:8"
99
@g = external global i8
1010
@c = constant ptr getelementptr inbounds (i8, ptr @g, i64 1)
1111

12-
define i1 @test(ptr %p) {
12+
define i1 @test(ptr %p) "instcombine-no-verify-fixpoint" {
1313
; CHECK-LABEL: @test(
1414
; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[P:%.*]], getelementptr inbounds (i8, ptr @g, i64 1)
1515
; CHECK-NEXT: ret i1 [[CMP]]

llvm/test/Transforms/InstCombine/shift.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt < %s -passes='instcombine<no-verify-fixpoint>' -S | FileCheck %s
3-
4-
; The fuzzer-generated @ashr_out_of_range test case does not reach a fixpoint,
5-
; because a logical and it not relaxed to a bitwise and in one iteration.
2+
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
63

74
declare void @use(i64)
85
declare void @use_i32(i32)
@@ -1735,9 +1732,12 @@ define i177 @lshr_out_of_range2(i177 %Y, ptr %A2, ptr %ptr) {
17351732
ret i177 %B1
17361733
}
17371734

1735+
; The fuzzer-generated @ashr_out_of_range test case does not reach a fixpoint,
1736+
; because a logical and it not relaxed to a bitwise and in one iteration.
1737+
17381738
; OSS Fuzz #5032
17391739
; https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=5032
1740-
define void @ashr_out_of_range(ptr %A) {
1740+
define void @ashr_out_of_range(ptr %A) "instcombine-no-verify-fixpoint" {
17411741
; CHECK-LABEL: @ashr_out_of_range(
17421742
; CHECK-NEXT: [[L:%.*]] = load i177, ptr [[A:%.*]], align 4
17431743
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i177 [[L]], -1

llvm/test/Transforms/InstCombine/sink_instruction.ll

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt -passes='instcombine<no-verify-fixpoint>' -S < %s | FileCheck %s
3-
4-
; We fail to reach a fixpoint, because sunk instructions get revisited too
5-
; early. In @test2 the sunk add is revisited before the dominating condition
6-
; is visited and added to the DomConditionCache.
2+
; RUN: opt -passes=instcombine -S < %s | FileCheck %s
73

84
;; This tests that the instructions in the entry blocks are sunk into each
95
;; arm of the 'if'.
@@ -31,9 +27,12 @@ endif: ; preds = %entry
3127
ret i32 %tmp.2
3228
}
3329

30+
; We fail to reach a fixpoint, because sunk instructions get revisited too
31+
; early. In @test2 the sunk add is revisited before the dominating condition
32+
; is visited and added to the DomConditionCache.
3433

3534
;; PHI use, sink divide before call.
36-
define i32 @test2(i32 %x) nounwind ssp {
35+
define i32 @test2(i32 %x) nounwind ssp "instcombine-no-verify-fixpoint" {
3736
; CHECK-LABEL: @test2(
3837
; CHECK-NEXT: entry:
3938
; CHECK-NEXT: br label [[BB:%.*]]

llvm/test/Transforms/InstCombine/zext-or-icmp.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt < %s -passes='instcombine<no-verify-fixpoint>' -S | FileCheck %s
2+
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
33

44
define i8 @zext_or_icmp_icmp(i8 %a, i8 %b) {
55
; CHECK-LABEL: @zext_or_icmp_icmp(
@@ -168,7 +168,7 @@ define i32 @PR49475(i32 %x, i16 %y) {
168168

169169
; This would infinite-loop.
170170

171-
define i8 @PR49475_infloop(i32 %t0, i16 %insert, i64 %e, i8 %i162) {
171+
define i8 @PR49475_infloop(i32 %t0, i16 %insert, i64 %e, i8 %i162) "instcombine-no-verify-fixpoint" {
172172
; CHECK-LABEL: @PR49475_infloop(
173173
; CHECK-NEXT: [[B2:%.*]] = icmp eq i16 [[INSERT:%.*]], 0
174174
; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[T0:%.*]], 1

llvm/test/Transforms/PGOProfile/chr.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt < %s -passes='require<profile-summary>,function(chr,instcombine<no-verify-fixpoint>,simplifycfg)' -S | FileCheck %s
3-
4-
; FIXME: This does not currently reach a fix point, because we don't make use
5-
; of a freeze that is pushed up the instruction chain later.
2+
; RUN: opt < %s -passes='require<profile-summary>,function(chr,instcombine,simplifycfg)' -S | FileCheck %s
63

74
declare void @foo()
85
declare void @bar()
@@ -1910,6 +1907,9 @@ bb4:
19101907
ret i32 %v13
19111908
}
19121909

1910+
; FIXME: This does not currently reach a fix point, because we don't make use
1911+
; of a freeze that is pushed up the instruction chain later.
1912+
19131913
; Test the case where two scopes share a common instruction to hoist (%cmp.i).
19141914
; Two scopes would hoist it to their hoist points, but since the outer scope
19151915
; hoists (entry/bb6-9) it first to its hoist point, it'd be wrong (causing bad
@@ -1928,7 +1928,7 @@ bb4:
19281928
; foo();
19291929
; }
19301930
; return 45;
1931-
define i32 @test_chr_21(i64 %i, i64 %k, i64 %j) !prof !14 {
1931+
define i32 @test_chr_21(i64 %i, i64 %k, i64 %j) "instcombine-no-verify-fixpoint" !prof !14 {
19321932
; CHECK-LABEL: @test_chr_21(
19331933
; CHECK-NEXT: entry:
19341934
; CHECK-NEXT: [[I_FR:%.*]] = freeze i64 [[I:%.*]]

llvm/test/Transforms/SimpleLoopUnswitch/2007-08-01-LCSSA.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2-
; RUN: opt < %s -S -passes='loop(simple-loop-unswitch),instcombine<no-verify-fixpoint>' -verify-memoryssa | FileCheck %s
2+
; RUN: opt < %s -S -passes='loop(simple-loop-unswitch),instcombine' -verify-memoryssa | FileCheck %s
33

44
; We do not reach a fixpoint, because we first have to infer nsw on the IV add,
55
; and could eliminate the icmp slt afterwards, but don't revisit it.
@@ -8,9 +8,9 @@
88

99
declare i32 @strcmp(ptr, ptr)
1010

11-
define i32 @_ZN9Generator6strregEPKc(ptr %this, ptr %s) {
11+
define i32 @_ZN9Generator6strregEPKc(ptr %this, ptr %s) "instcombine-no-verify-fixpoint" {
1212
; CHECK-LABEL: define i32 @_ZN9Generator6strregEPKc(
13-
; CHECK-SAME: ptr [[THIS:%.*]], ptr [[S:%.*]]) {
13+
; CHECK-SAME: ptr [[THIS:%.*]], ptr [[S:%.*]]) #[[ATTR0:[0-9]+]] {
1414
; CHECK-NEXT: entry:
1515
; CHECK-NEXT: [[TMP122:%.*]] = icmp eq ptr [[S]], null
1616
; CHECK-NEXT: br label [[BB184:%.*]]

0 commit comments

Comments
 (0)