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. 5; 6; This set of tests exercises the legacy pass manager interface to the OptBisect 7; class. Because the exact set of optimizations that will be run may 8; change over time, these tests are written in a more general manner than the 9; corresponding tests for the new pass manager. 10; 11; Don't use NEXT checks or hard-code pass numbering so that this won't fail if 12; new passes are inserted. 13 14 15; Verify that the file can be compiled to an object file at -O3 with all 16; skippable passes skipped. 17 18; RUN: opt -O3 -opt-bisect-limit=0 < %s | llc -O3 -opt-bisect-limit=0 19 20 21; Verify that no skippable passes are run with -opt-bisect-limit=0. 22 23; RUN: opt -disable-output -disable-verify -O3 -opt-bisect-limit=0 %s 2>&1 \ 24; RUN: | FileCheck %s --check-prefix=CHECK-SKIP-ALL 25; CHECK-SKIP-ALL: BISECT: NOT running pass ({{[0-9]+}}) 26; CHECK-SKIP-ALL-NOT: BISECT: running pass ({{[0-9]+}}) 27 28 29; Verify that no passes run at -O0 are skipped 30; RUN: opt -opt-bisect-limit=0 < %s 2>&1 | FileCheck %s --check-prefix=OPTBISECT-O0 31; OPTBISECT-O0-NOT: BISECT: NOT running 32 33; FIXME: There are still some AMDGPU passes being skipped that run at -O0. 34; XFAIL: r600, amdgcn 35 36; Verify that we can use the opt-bisect-helper.py script (derived from 37; utils/bisect) to locate the optimization that inlines the call to 38; f2() in f3(). 39 40; RUN: %python %S/opt-bisect-helper.py --start=0 --end=256 --optcmd=opt \ 41; RUN: --filecheckcmd=FileCheck --test=%s \ 42; RUN: --prefix=CHECK-BISECT-INLINE-HELPER \ 43; RUN: | FileCheck %s --check-prefix=CHECK-BISECT-INLINE-RESULT 44; The helper script uses this to find the optimization that inlines the call. 45; CHECK-BISECT-INLINE-HELPER: call i32 @f2() 46; These checks verifies that the optimization was found. 47; CHECK-BISECT-INLINE-RESULT-NOT: Last good count: 0 48; CHECK-BISECT-INLINE-RESULT: Last good count: {{[0-9]+}} 49 50 51; Test a module pass. 52 53; RUN: opt -disable-output -disable-verify -deadargelim -opt-bisect-limit=-1 %s \ 54; RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEADARG 55; CHECK-DEADARG: BISECT: running pass ({{[0-9]+}}) Dead Argument Elimination on module 56 57; RUN: opt -disable-output -disable-verify -deadargelim -opt-bisect-limit=0 %s \ 58; RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-DEADARG 59; CHECK-NOT-DEADARG: BISECT: NOT running pass ({{[0-9]+}}) Dead Argument Elimination on module 60 61 62; Test an SCC pass. 63 64; RUN: opt -disable-output -disable-verify -inline -opt-bisect-limit=-1 %s \ 65; RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-INLINE 66; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (<<null function>>) 67; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (g) 68; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f1) 69; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f2) 70; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f3) 71; CHECK-INLINE: BISECT: running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (<<null function>>) 72 73; RUN: opt -disable-output -disable-verify -inline -opt-bisect-limit=0 %s \ 74; RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-INLINE 75; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (<<null function>>) 76; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (g) 77; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f1) 78; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f2) 79; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (f3) 80; CHECK-NOT-INLINE: BISECT: NOT running pass ({{[0-9]+}}) Function Integration/Inlining on SCC (<<null function>>) 81 82 83; Test a function pass. 84 85; RUN: opt -disable-output -disable-verify -early-cse -opt-bisect-limit=-1 \ 86; RUN: %s 2>&1 | FileCheck %s --check-prefix=CHECK-EARLY-CSE 87; CHECK-EARLY-CSE: BISECT: running pass ({{[0-9]+}}) Early CSE on function (f1) 88; CHECK-EARLY-CSE: BISECT: running pass ({{[0-9]+}}) Early CSE on function (f2) 89; CHECK-EARLY-CSE: BISECT: running pass ({{[0-9]+}}) Early CSE on function (f3) 90 91; RUN: opt -disable-output -disable-verify -early-cse -opt-bisect-limit=0 %s \ 92; RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-EARLY-CSE 93; CHECK-NOT-EARLY-CSE: BISECT: NOT running pass ({{[0-9]+}}) Early CSE on function (f1) 94; CHECK-NOT-EARLY-CSE: BISECT: NOT running pass ({{[0-9]+}}) Early CSE on function (f2) 95; CHECK-NOT-EARLY-CSE: BISECT: NOT running pass ({{[0-9]+}}) Early CSE on function (f3) 96 97 98; Test a loop pass. 99 100; RUN: opt -disable-output -disable-verify -loop-reduce -opt-bisect-limit=-1 \ 101; RUN: %s 2>&1 | FileCheck %s --check-prefix=CHECK-LOOP-REDUCE 102; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop 103; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop 104; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop 105; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop 106; CHECK-LOOP-REDUCE: BISECT: running pass ({{[0-9]+}}) Loop Strength Reduction on loop 107 108; RUN: opt -disable-output -disable-verify -loop-reduce -opt-bisect-limit=0 \ 109; RUN: %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOT-LOOP-REDUCE 110; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop 111; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop 112; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop 113; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop 114; CHECK-NOT-LOOP-REDUCE: BISECT: NOT running pass ({{[0-9]+}}) Loop Strength Reduction on loop 115 116 117declare i32 @g() 118 119define void @f1() { 120entry: 121 br label %loop.0 122loop.0: 123 br i1 undef, label %loop.0.0, label %loop.1 124loop.0.0: 125 br i1 undef, label %loop.0.0, label %loop.0.1 126loop.0.1: 127 br i1 undef, label %loop.0.1, label %loop.0 128loop.1: 129 br i1 undef, label %loop.1, label %loop.1.bb1 130loop.1.bb1: 131 br i1 undef, label %loop.1, label %loop.1.bb2 132loop.1.bb2: 133 br i1 undef, label %end, label %loop.1.0 134loop.1.0: 135 br i1 undef, label %loop.1.0, label %loop.1 136end: 137 ret void 138} 139 140define i32 @f2() { 141entry: 142 ret i32 0 143} 144 145define i32 @f3() { 146entry: 147 %temp = call i32 @g() 148 %icmp = icmp ugt i32 %temp, 2 149 br i1 %icmp, label %bb.true, label %bb.false 150bb.true: 151 %temp2 = call i32 @f2() 152 ret i32 %temp2 153bb.false: 154 ret i32 0 155} 156 157; This function is here to verify that opt-bisect can skip all passes for 158; functions that contain lifetime intrinsics. 159define void @f4() { 160entry: 161 %i = alloca i32, align 4 162 %tmp = bitcast i32* %i to i8* 163 call void @llvm.lifetime.start(i64 4, i8* %tmp) 164 br label %for.cond 165 166for.cond: 167 br i1 undef, label %for.body, label %for.end 168 169for.body: 170 br label %for.cond 171 172for.end: 173 ret void 174} 175 176declare void @llvm.lifetime.start(i64, i8* nocapture) 177 178