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-NOT: BISECT: {{.*}} VerifierPass
25 ; CHECK-REQUIRED-PASS: Running pass: VerifierPass
26 ; CHECK-REQUIRED-PASS: BISECT: running pass (1) InferFunctionAttrsPass on [module]
27 ; CHECK-REQUIRED-PASS-NOT: BISECT: {{.*}} VerifierPass
28 ; CHECK-REQUIRED-PASS: Running pass: VerifierPass
30 ; RUN: opt -disable-output -debug-pass-manager \
31 ; RUN: -passes=inferattrs -opt-bisect-limit=0 %s 2>&1 \
32 ; RUN: | FileCheck %s --check-prefix=CHECK-LIMIT-REQUIRED-PASS
33 ; CHECK-LIMIT-REQUIRED-PASS-NOT: BISECT: {{.*}} VerifierPass
34 ; CHECK-LIMIT-REQUIRED-PASS: Running pass: VerifierPass
35 ; CHECK-LIMIT-REQUIRED-PASS: BISECT: NOT running pass (1) InferFunctionAttrsPass on [module]
36 ; CHECK-LIMIT-REQUIRED-PASS-NOT: BISECT: {{.*}} VerifierPass
37 ; CHECK-LIMIT-REQUIRED-PASS: Running pass: VerifierPass
39 ; RUN: opt -disable-output -disable-verify \
40 ; RUN: -passes=early-cse -opt-bisect-limit=-1 %s 2>&1 \
41 ; RUN: | FileCheck %s --check-prefix=CHECK-FUNCTION-PASS
42 ; CHECK-FUNCTION-PASS: BISECT: running pass (1) EarlyCSEPass on f1
43 ; CHECK-FUNCTION-PASS: BISECT: running pass (2) EarlyCSEPass on f2
44 ; CHECK-FUNCTION-PASS: BISECT: running pass (3) EarlyCSEPass on f3
45 ; CHECK-FUNCTION-PASS: BISECT: running pass (4) EarlyCSEPass on f4
47 ; RUN: opt -disable-output -disable-verify \
48 ; RUN: -passes=early-cse -opt-bisect-limit=2 %s 2>&1 \
49 ; RUN: | FileCheck %s --check-prefix=CHECK-LIMIT-FUNCTION-PASS
50 ; CHECK-LIMIT-FUNCTION-PASS: BISECT: running pass (1) EarlyCSEPass on f1
51 ; CHECK-LIMIT-FUNCTION-PASS: BISECT: running pass (2) EarlyCSEPass on f2
52 ; CHECK-LIMIT-FUNCTION-PASS: BISECT: NOT running pass (3) EarlyCSEPass on f3
53 ; CHECK-LIMIT-FUNCTION-PASS: BISECT: NOT running pass (4) EarlyCSEPass on f4
55 ; RUN: opt -disable-output -disable-verify \
56 ; RUN: -passes=function-attrs -opt-bisect-limit=-1 %s 2>&1 \
57 ; RUN: | FileCheck %s --check-prefix=CHECK-CGSCC-PASS
58 ; CHECK-CGSCC-PASS: BISECT: running pass (1) PostOrderFunctionAttrsPass on (f1)
59 ; CHECK-CGSCC-PASS: BISECT: running pass (2) PostOrderFunctionAttrsPass on (f2)
60 ; CHECK-CGSCC-PASS: BISECT: running pass (3) PostOrderFunctionAttrsPass on (f3)
61 ; CHECK-CGSCC-PASS: BISECT: running pass (4) PostOrderFunctionAttrsPass on (f4)
63 ; RUN: opt -disable-output -disable-verify \
64 ; RUN: -passes=function-attrs -opt-bisect-limit=3 %s 2>&1 \
65 ; RUN: | FileCheck %s --check-prefix=CHECK-LIMIT-CGSCC-PASS
66 ; CHECK-LIMIT-CGSCC-PASS: BISECT: running pass (1) PostOrderFunctionAttrsPass on (f1)
67 ; CHECK-LIMIT-CGSCC-PASS: BISECT: running pass (2) PostOrderFunctionAttrsPass on (f2)
68 ; CHECK-LIMIT-CGSCC-PASS: BISECT: running pass (3) PostOrderFunctionAttrsPass on (f3)
69 ; CHECK-LIMIT-CGSCC-PASS: BISECT: NOT running pass (4) PostOrderFunctionAttrsPass on (f4)
71 ; RUN: opt -disable-output -disable-verify -opt-bisect-limit=-1 \
72 ; RUN: -passes='inferattrs,cgscc(function-attrs,function(early-cse))' %s 2>&1 \
73 ; RUN: | FileCheck %s --check-prefix=CHECK-MULTI-PASS
74 ; CHECK-MULTI-PASS: BISECT: running pass (1) InferFunctionAttrsPass on [module]
75 ; CHECK-MULTI-PASS: BISECT: running pass (2) PostOrderFunctionAttrsPass on (f1)
76 ; CHECK-MULTI-PASS: BISECT: running pass (3) EarlyCSEPass on f1
77 ; CHECK-MULTI-PASS: BISECT: running pass (4) PostOrderFunctionAttrsPass on (f2)
78 ; CHECK-MULTI-PASS: BISECT: running pass (5) EarlyCSEPass on f2
79 ; CHECK-MULTI-PASS: BISECT: running pass (6) PostOrderFunctionAttrsPass on (f3)
80 ; CHECK-MULTI-PASS: BISECT: running pass (7) EarlyCSEPass on f3
81 ; CHECK-MULTI-PASS: BISECT: running pass (8) PostOrderFunctionAttrsPass on (f4)
82 ; CHECK-MULTI-PASS: BISECT: running pass (9) EarlyCSEPass on f4
84 ; RUN: opt -disable-output -disable-verify -opt-bisect-limit=7 \
85 ; RUN: -passes='inferattrs,cgscc(function-attrs,function(early-cse))' %s 2>&1 \
86 ; RUN: | FileCheck %s --check-prefix=CHECK-LIMIT-MULTI-PASS
87 ; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (1) InferFunctionAttrsPass on [module]
88 ; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (2) PostOrderFunctionAttrsPass on (f1)
89 ; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (3) EarlyCSEPass on f1
90 ; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (4) PostOrderFunctionAttrsPass on (f2)
91 ; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (5) EarlyCSEPass on f2
92 ; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (6) PostOrderFunctionAttrsPass on (f3)
93 ; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (7) EarlyCSEPass on f3
94 ; CHECK-LIMIT-MULTI-PASS: BISECT: NOT running pass (8) PostOrderFunctionAttrsPass on (f4)
95 ; CHECK-LIMIT-MULTI-PASS: BISECT: NOT running pass (9) EarlyCSEPass on f4
97 ; Make sure we don't skip writing the output to stdout.
98 ; RUN: opt %s -opt-bisect-limit=0 -passes=early-cse | opt -S | FileCheck %s -check-prefix=CHECK-OUTPUT
99 ; RUN: opt %s -opt-bisect-limit=0 -passes=early-cse -S | FileCheck %s -check-prefix=CHECK-OUTPUT
100 ; CHECK-OUTPUT: define void @f1
108 br i1 undef, label %loop.0.0, label %loop.1
110 br i1 undef, label %loop.0.0, label %loop.0.1
112 br i1 undef, label %loop.0.1, label %loop.0
114 br i1 undef, label %loop.1, label %loop.1.bb1
116 br i1 undef, label %loop.1, label %loop.1.bb2
118 br i1 undef, label %end, label %loop.1.0
120 br i1 undef, 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.
146 %i = alloca i32, align 4
147 %tmp = bitcast i32* %i to i8*
148 call void @llvm.lifetime.start(i64 4, i8* %tmp)
152 br i1 undef, label %for.body, label %for.end
161 declare void @llvm.lifetime.start(i64, i8* nocapture)