1 ; This file verifies the behavior of the OptBisect class, which is used to
2 ; diagnose optimization related failures. The tests check various
3 ; invocations that result in different sets of optimization passes that
4 ; are run in different ways.
6 ; Because the exact set of optimizations that will be run is expected to
7 ; change over time, the checks for disabling passes are written in a
8 ; conservative way that avoids assumptions about which specific passes
11 ; RUN: opt -disable-output -disable-verify \
12 ; RUN: -passes=inferattrs -opt-bisect-limit=-1 %s 2>&1 \
13 ; RUN: | FileCheck %s --check-prefix=CHECK-MODULE-PASS
14 ; CHECK-MODULE-PASS: BISECT: running pass (1) InferFunctionAttrsPass on [module]
16 ; RUN: opt -disable-output -disable-verify \
17 ; RUN: -passes=inferattrs -opt-bisect-limit=0 %s 2>&1 \
18 ; RUN: | FileCheck %s --check-prefix=CHECK-LIMIT-MODULE-PASS
19 ; CHECK-LIMIT-MODULE-PASS: BISECT: NOT running pass (1) InferFunctionAttrsPass on [module]
21 ; RUN: opt -disable-output -debug-pass-manager \
22 ; RUN: -passes=inferattrs -opt-bisect-limit=-1 %s 2>&1 \
23 ; RUN: | FileCheck %s --check-prefix=CHECK-REQUIRED-PASS
24 ; CHECK-REQUIRED-PASS: BISECT: running pass (1) InferFunctionAttrsPass on [module]
25 ; CHECK-REQUIRED-PASS-NOT: BISECT: {{.*}}VerifierPass
26 ; CHECK-REQUIRED-PASS: Running pass: VerifierPass
28 ; RUN: opt -disable-output -debug-pass-manager \
29 ; RUN: -passes=inferattrs -opt-bisect-limit=0 %s 2>&1 \
30 ; RUN: | FileCheck %s --check-prefix=CHECK-LIMIT-REQUIRED-PASS
31 ; CHECK-LIMIT-REQUIRED-PASS: BISECT: NOT running pass (1) InferFunctionAttrsPass on [module]
32 ; CHECK-LIMIT-REQUIRED-PASS-NOT: BISECT: {{.*}}VerifierPass
33 ; CHECK-LIMIT-REQUIRED-PASS: Running pass: VerifierPass
35 ; RUN: opt -disable-output -disable-verify \
36 ; RUN: -passes=early-cse -opt-bisect-limit=-1 %s 2>&1 \
37 ; RUN: | FileCheck %s --check-prefix=CHECK-FUNCTION-PASS
38 ; CHECK-FUNCTION-PASS: BISECT: running pass (1) EarlyCSEPass on f1
39 ; CHECK-FUNCTION-PASS: BISECT: running pass (2) EarlyCSEPass on f2
40 ; CHECK-FUNCTION-PASS: BISECT: running pass (3) EarlyCSEPass on f3
41 ; CHECK-FUNCTION-PASS: BISECT: running pass (4) EarlyCSEPass on f4
43 ; RUN: opt -disable-output -disable-verify \
44 ; RUN: -passes=early-cse -opt-bisect-limit=2 %s 2>&1 \
45 ; RUN: | FileCheck %s --check-prefix=CHECK-LIMIT-FUNCTION-PASS
46 ; CHECK-LIMIT-FUNCTION-PASS: BISECT: running pass (1) EarlyCSEPass on f1
47 ; CHECK-LIMIT-FUNCTION-PASS: BISECT: running pass (2) EarlyCSEPass on f2
48 ; CHECK-LIMIT-FUNCTION-PASS: BISECT: NOT running pass (3) EarlyCSEPass on f3
49 ; CHECK-LIMIT-FUNCTION-PASS: BISECT: NOT running pass (4) EarlyCSEPass on f4
51 ; RUN: opt -disable-output -disable-verify \
52 ; RUN: -passes=function-attrs -opt-bisect-limit=-1 %s 2>&1 \
53 ; RUN: | FileCheck %s --check-prefix=CHECK-CGSCC-PASS
54 ; CHECK-CGSCC-PASS: BISECT: running pass (1) PostOrderFunctionAttrsPass on (f1)
55 ; CHECK-CGSCC-PASS: BISECT: running pass (2) PostOrderFunctionAttrsPass on (f2)
56 ; CHECK-CGSCC-PASS: BISECT: running pass (3) PostOrderFunctionAttrsPass on (f3)
57 ; CHECK-CGSCC-PASS: BISECT: running pass (4) PostOrderFunctionAttrsPass on (f4)
59 ; RUN: opt -disable-output -disable-verify \
60 ; RUN: -passes=function-attrs -opt-bisect-limit=3 %s 2>&1 \
61 ; RUN: | FileCheck %s --check-prefix=CHECK-LIMIT-CGSCC-PASS
62 ; CHECK-LIMIT-CGSCC-PASS: BISECT: running pass (1) PostOrderFunctionAttrsPass on (f1)
63 ; CHECK-LIMIT-CGSCC-PASS: BISECT: running pass (2) PostOrderFunctionAttrsPass on (f2)
64 ; CHECK-LIMIT-CGSCC-PASS: BISECT: running pass (3) PostOrderFunctionAttrsPass on (f3)
65 ; CHECK-LIMIT-CGSCC-PASS: BISECT: NOT running pass (4) PostOrderFunctionAttrsPass on (f4)
67 ; RUN: opt -disable-output -disable-verify -opt-bisect-limit=-1 \
68 ; RUN: -passes='inferattrs,cgscc(function-attrs,function(early-cse))' %s 2>&1 \
69 ; RUN: | FileCheck %s --check-prefix=CHECK-MULTI-PASS
70 ; CHECK-MULTI-PASS: BISECT: running pass (1) InferFunctionAttrsPass on [module]
71 ; CHECK-MULTI-PASS: BISECT: running pass (2) PostOrderFunctionAttrsPass on (f1)
72 ; CHECK-MULTI-PASS: BISECT: running pass (3) EarlyCSEPass on f1
73 ; CHECK-MULTI-PASS: BISECT: running pass (4) PostOrderFunctionAttrsPass on (f2)
74 ; CHECK-MULTI-PASS: BISECT: running pass (5) EarlyCSEPass on f2
75 ; CHECK-MULTI-PASS: BISECT: running pass (6) PostOrderFunctionAttrsPass on (f3)
76 ; CHECK-MULTI-PASS: BISECT: running pass (7) EarlyCSEPass on f3
77 ; CHECK-MULTI-PASS: BISECT: running pass (8) PostOrderFunctionAttrsPass on (f4)
78 ; CHECK-MULTI-PASS: BISECT: running pass (9) EarlyCSEPass on f4
80 ; RUN: opt -disable-output -disable-verify -opt-bisect-limit=7 \
81 ; RUN: -passes='inferattrs,cgscc(function-attrs,function(early-cse))' %s 2>&1 \
82 ; RUN: | FileCheck %s --check-prefix=CHECK-LIMIT-MULTI-PASS
83 ; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (1) InferFunctionAttrsPass on [module]
84 ; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (2) PostOrderFunctionAttrsPass on (f1)
85 ; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (3) EarlyCSEPass on f1
86 ; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (4) PostOrderFunctionAttrsPass on (f2)
87 ; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (5) EarlyCSEPass on f2
88 ; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (6) PostOrderFunctionAttrsPass on (f3)
89 ; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (7) EarlyCSEPass on f3
90 ; CHECK-LIMIT-MULTI-PASS: BISECT: NOT running pass (8) PostOrderFunctionAttrsPass on (f4)
91 ; CHECK-LIMIT-MULTI-PASS: BISECT: NOT running pass (9) EarlyCSEPass on f4
93 ; Make sure we don't skip writing the output to stdout.
94 ; RUN: opt %s -opt-bisect-limit=0 -passes=early-cse | opt -S | FileCheck %s -check-prefix=CHECK-OUTPUT
95 ; RUN: opt %s -opt-bisect-limit=0 -passes=early-cse -S | FileCheck %s -check-prefix=CHECK-OUTPUT
96 ; CHECK-OUTPUT: define void @f1
98 ; Make sure we write ThinLTO bitcode
99 ; RUN: opt %s -opt-bisect-limit=0 -disable-verify -thinlto-bc -o /dev/null 2>&1 | FileCheck --allow-empty %s -check-prefix=CHECK-THINLTO
100 ; CHECK-THINLTO-NOT: NOT running pass
104 define void @f1(i1 %arg) {
108 br i1 %arg, label %loop.0.0, label %loop.1
110 br i1 %arg, label %loop.0.0, label %loop.0.1
112 br i1 %arg, label %loop.0.1, label %loop.0
114 br i1 %arg, label %loop.1, label %loop.1.bb1
116 br i1 %arg, label %loop.1, label %loop.1.bb2
118 br i1 %arg, label %end, label %loop.1.0
120 br i1 %arg, label %loop.1.0, label %loop.1
132 %temp = call i32 @g()
133 %icmp = icmp ugt i32 %temp, 2
134 br i1 %icmp, label %bb.true, label %bb.false
136 %temp2 = call i32 @f2()
142 ; This function is here to verify that opt-bisect can skip all passes for
143 ; functions that contain lifetime intrinsics.
144 define void @f4(i1 %arg) {
146 %i = alloca i32, align 4
147 call void @llvm.lifetime.start(i64 4, ptr %i)
151 br i1 %arg, label %for.body, label %for.end
160 declare void @llvm.lifetime.start(i64, ptr nocapture)