xref: /llvm-project/llvm/test/tools/llvm-reduce/remove-bbs.ll (revision b022e08c185b42a875766ce12d34f7b3c1c759c2)
1; Test that llvm-reduce can remove uninteresting Basic Blocks, and remove them from instructions (i.e. SwitchInst, BranchInst and IndirectBrInst)
2; Note: if an uninteresting BB is the default case for a switch, the instruction is removed altogether (since the default case cannot be replaced)
3;
4; RUN: llvm-reduce -abort-on-invalid-reduction --delta-passes=basic-blocks --test FileCheck --test-arg --check-prefix=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
5; RUN: FileCheck -implicit-check-not=uninteresting %s < %t
6
7; CHECK-INTERESTINGNESS: store i32 0
8; CHECK-INTERESTINGNESS: store i32 1
9; CHECK-INTERESTINGNESS: store i32 2
10
11define void @main() {
12interesting:
13  store i32 0, ptr null
14  ; CHECK-NOT: switch i32 0, label %uninteresting
15  switch i32 0, label %uninteresting [
16    i32 1, label %interesting2
17  ]
18
19uninteresting:
20  ret void
21
22interesting2:
23  store i32 1, ptr null
24  ; CHECK: switch i32 1, label %interesting3
25  switch i32 1, label %interesting3 [
26    ; CHECK-NOT: i32 0, label %uninteresting
27    i32 0, label %uninteresting
28    ; CHECK: i32 1, label %interesting3
29    i32 1, label %interesting3
30  ]
31
32interesting3:
33  store i32 2, ptr null
34  ; CHECK: br label %interesting2
35  br i1 true, label %interesting2, label %uninteresting
36}
37