1
- ;; This test verifies that -gc-empty-basic-blocks removes empty blocks.
1
+ ;; This test verifies that -gc-empty-basic-blocks removes regular empty blocks
2
+ ;; but does not remove empty blocks which have their address taken.
2
3
; RUN: llc < %s -mtriple=x86_64 -O0 -gc-empty-basic-blocks | FileCheck %s
3
4
5
+ ;; This function has a regular empty block.
4
6
define void @foo (i1 zeroext %0 ) nounwind {
5
7
br i1 %0 , label %2 , label %empty_block
6
8
@@ -10,7 +12,7 @@ define void @foo(i1 zeroext %0) nounwind {
10
12
; CHECK-NEXT: jmp .LBB0_3
11
13
12
14
2 : ; preds = %1
13
- %3 = call i32 @bar ()
15
+ %3 = call i32 @baz ()
14
16
br label %4
15
17
16
18
; CHECK-LABEL: .LBB0_1:
@@ -19,8 +21,8 @@ define void @foo(i1 zeroext %0) nounwind {
19
21
empty_block: ; preds = %1
20
22
unreachable
21
23
22
- ; CHECK-NOT: %empty_block
23
- ; CHECK-NOT: .LBB0_2
24
+ ; CHECK-NOT: %empty_block
25
+ ; CHECK-NOT: .LBB0_2
24
26
25
27
4 : ; preds = %2, %empty_block
26
28
ret void
@@ -30,4 +32,23 @@ empty_block: ; preds = %1
30
32
31
33
}
32
34
33
- declare i32 @bar ()
35
+ ;; This function has an empty block which has its address taken. Check that it
36
+ ;; is not removed by -gc-empty-basic-blocks.
37
+ define void @bar (i1 zeroext %0 ) nounwind {
38
+ entry:
39
+ %1 = select i1 %0 , ptr blockaddress (@bar , %empty_block ), ptr blockaddress (@bar , %bb2 ) ; <ptr> [#uses=1]
40
+ indirectbr ptr %1 , [label %empty_block , label %bb2 ]
41
+
42
+ ; CHECK-LABEL: bar:
43
+
44
+ empty_block: ; preds = %entry
45
+ unreachable
46
+
47
+ ; CHECK-LABEL: .LBB1_1: # %empty_block
48
+
49
+ bb2: ; preds = %entry
50
+ %2 = call i32 @baz ()
51
+ ret void
52
+ }
53
+
54
+ declare i32 @baz ()
0 commit comments