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; 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 9; will be disabled. 10 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 15 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 20 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 29 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 38 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 function (f1) 43; CHECK-FUNCTION-PASS: BISECT: running pass (2) EarlyCSEPass on function (f2) 44; CHECK-FUNCTION-PASS: BISECT: running pass (3) EarlyCSEPass on function (f3) 45; CHECK-FUNCTION-PASS: BISECT: running pass (4) EarlyCSEPass on function (f4) 46 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 function (f1) 51; CHECK-LIMIT-FUNCTION-PASS: BISECT: running pass (2) EarlyCSEPass on function (f2) 52; CHECK-LIMIT-FUNCTION-PASS: BISECT: NOT running pass (3) EarlyCSEPass on function (f3) 53; CHECK-LIMIT-FUNCTION-PASS: BISECT: NOT running pass (4) EarlyCSEPass on function (f4) 54 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 SCC (f1) 59; CHECK-CGSCC-PASS: BISECT: running pass (2) PostOrderFunctionAttrsPass on SCC (f2) 60; CHECK-CGSCC-PASS: BISECT: running pass (3) PostOrderFunctionAttrsPass on SCC (f3) 61; CHECK-CGSCC-PASS: BISECT: running pass (4) PostOrderFunctionAttrsPass on SCC (f4) 62 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 SCC (f1) 67; CHECK-LIMIT-CGSCC-PASS: BISECT: running pass (2) PostOrderFunctionAttrsPass on SCC (f2) 68; CHECK-LIMIT-CGSCC-PASS: BISECT: running pass (3) PostOrderFunctionAttrsPass on SCC (f3) 69; CHECK-LIMIT-CGSCC-PASS: BISECT: NOT running pass (4) PostOrderFunctionAttrsPass on SCC (f4) 70 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 SCC (f1) 76; CHECK-MULTI-PASS: BISECT: running pass (3) EarlyCSEPass on function (f1) 77; CHECK-MULTI-PASS: BISECT: running pass (4) PostOrderFunctionAttrsPass on SCC (f2) 78; CHECK-MULTI-PASS: BISECT: running pass (5) EarlyCSEPass on function (f2) 79; CHECK-MULTI-PASS: BISECT: running pass (6) PostOrderFunctionAttrsPass on SCC (f3) 80; CHECK-MULTI-PASS: BISECT: running pass (7) EarlyCSEPass on function (f3) 81; CHECK-MULTI-PASS: BISECT: running pass (8) PostOrderFunctionAttrsPass on SCC (f4) 82; CHECK-MULTI-PASS: BISECT: running pass (9) EarlyCSEPass on function (f4) 83 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 SCC (f1) 89; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (3) EarlyCSEPass on function (f1) 90; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (4) PostOrderFunctionAttrsPass on SCC (f2) 91; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (5) EarlyCSEPass on function (f2) 92; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (6) PostOrderFunctionAttrsPass on SCC (f3) 93; CHECK-LIMIT-MULTI-PASS: BISECT: running pass (7) EarlyCSEPass on function (f3) 94; CHECK-LIMIT-MULTI-PASS: BISECT: NOT running pass (8) PostOrderFunctionAttrsPass on SCC (f4) 95; CHECK-LIMIT-MULTI-PASS: BISECT: NOT running pass (9) EarlyCSEPass on function (f4) 96 97 98declare i32 @g() 99 100define void @f1() { 101entry: 102 br label %loop.0 103loop.0: 104 br i1 undef, label %loop.0.0, label %loop.1 105loop.0.0: 106 br i1 undef, label %loop.0.0, label %loop.0.1 107loop.0.1: 108 br i1 undef, label %loop.0.1, label %loop.0 109loop.1: 110 br i1 undef, label %loop.1, label %loop.1.bb1 111loop.1.bb1: 112 br i1 undef, label %loop.1, label %loop.1.bb2 113loop.1.bb2: 114 br i1 undef, label %end, label %loop.1.0 115loop.1.0: 116 br i1 undef, label %loop.1.0, label %loop.1 117end: 118 ret void 119} 120 121define i32 @f2() { 122entry: 123 ret i32 0 124} 125 126define i32 @f3() { 127entry: 128 %temp = call i32 @g() 129 %icmp = icmp ugt i32 %temp, 2 130 br i1 %icmp, label %bb.true, label %bb.false 131bb.true: 132 %temp2 = call i32 @f2() 133 ret i32 %temp2 134bb.false: 135 ret i32 0 136} 137 138; This function is here to verify that opt-bisect can skip all passes for 139; functions that contain lifetime intrinsics. 140define void @f4() { 141entry: 142 %i = alloca i32, align 4 143 %tmp = bitcast i32* %i to i8* 144 call void @llvm.lifetime.start(i64 4, i8* %tmp) 145 br label %for.cond 146 147for.cond: 148 br i1 undef, label %for.body, label %for.end 149 150for.body: 151 br label %for.cond 152 153for.end: 154 ret void 155} 156 157declare void @llvm.lifetime.start(i64, i8* nocapture) 158