xref: /llvm-project/llvm/test/tools/llvm-reduce/remove-bbs-unreachable.ll (revision 45a91c1521b243b728d4ce69f8d19a449627d251)
1; Check that verification doesn't fail when reducing a function with
2; unreachable blocks.
3;
4; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=unreachable-basic-blocks --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
5; RUN: FileCheck -check-prefix=UNREACHABLE %s < %t
6
7; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=basic-blocks --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
8; RUN: FileCheck -check-prefix=REACHABLE %s < %t
9
10; CHECK-INTERESTINGNESS: test0
11; CHECK-INTERESTINGNESS: test1
12
13; UNREACHABLE: define void @test0() {
14; UNREACHABLE-NEXT: entry:
15; UNREACHABLE-NEXT:   br label %exit
16
17; UNREACHABLE-NOT: unreachable
18; UNREACHABLE: exit:
19; UNREACHABLE-NEXT: ret void
20
21
22; basic-blocks cannot deal with unreachable blocks, leave it behind
23; REACHABLE: define void @test0() {
24; REACHABLE: entry:
25; REACHABLE: unreachable:
26; REACHABLE: exit:
27
28define void @test0() {
29entry:
30  br label %exit
31
32unreachable:                                        ; No predecessors!
33  br label %exit
34
35exit:
36  ret void
37}
38
39; UNREACHABLE: define void @test1() {
40; UNREACHABLE-NEXT: entry:
41; UNREACHABLE-NEXT:   br label %exit
42
43; REACHABLE: define void @test1() {
44; REACHABLE: entry:
45; REACHABLE: unreachable:
46; REACHABLE: exit:
47define void @test1() {
48entry:
49  br label %exit
50
51unreachable:
52  br label %unreachable
53
54exit:
55  ret void
56}
57