1# RUN: llc -run-pass=block-placement %s -o - | FileCheck %s
2
3--- |
4  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5  target triple = "x86_64-unknown-linux-gnu"
6
7  define void @_Z3fn1v() !dbg !6 {
8  entry:
9    %d = alloca i8, align 1
10    br i1 1, label %for.cond.cleanup, label %for.body
11
12  for.cond.cleanup:
13    ret void
14
15  for.body:
16    br i1 1, label %for.cond.cleanup, label %for.body.1
17
18  for.body.1:
19    br i1 1, label %for.cond.cleanup, label %for.body.2
20
21  for.body.2:
22    br i1 1, label %for.cond.cleanup, label %for.body.3
23
24  for.body.3:
25    br i1 1, label %for.cond.cleanup, label %for.body.4
26
27  for.body.4:
28    br i1 1, label %for.cond.cleanup, label %for.body.5
29
30  for.body.5:
31    br i1 1, label %for.cond.cleanup, label %for.body.6
32
33  for.body.6:
34    br i1 1, label %for.cond.cleanup, label %for.body.7
35
36  for.body.7:
37    br i1 1, label %for.cond.cleanup, label %for.body.8
38
39  for.body.8:
40    br i1 1, label %for.cond.cleanup, label %for.body.9
41
42  for.body.9:
43    br i1 1, label %for.cond.cleanup, label %for.body.10
44
45  for.body.10:
46    br i1 1, label %for.cond.cleanup, label %for.body.11
47
48  for.body.11:
49    %d.0.d.0..12 = load volatile i8, i8* %d, align 1
50    call void @llvm.dbg.value(metadata i8 %d.0.d.0..12, metadata !16, metadata !DIExpression()), !dbg !19
51    br label %for.cond.cleanup
52  }
53
54  declare void @llvm.dbg.value(metadata, metadata, metadata)
55
56  !llvm.dbg.cu = !{!0}
57  !llvm.module.flags = !{!3, !4, !5}
58
59  !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 7.0.0 (trunk 326606)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !2)
60  !1 = !DIFile(filename: "repro.cpp", directory: "/home/mdavis/bugs/bz-189869")
61  !2 = !{}
62  !3 = !{i32 2, !"Dwarf Version", i32 4}
63  !4 = !{i32 2, !"Debug Info Version", i32 3}
64  !5 = !{i32 1, !"wchar_size", i32 4}
65  !6 = distinct !DISubprogram(name: "fn1", linkageName: "_Z3fn1v", scope: !7, file: !7, line: 4, type: !8, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !15)
66  !7 = !DIFile(filename: "./repro.cpp", directory: "/home/mdavis/bugs/bz-189869")
67  !8 = !DISubroutineType(types: !9)
68  !9 = !{}
69  !15 = !{!16}
70  !16 = !DILocalVariable(name: "d", scope: !6, file: !7, line: 6, type: !17)
71  !17 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !18)
72  !18 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
73  !19 = !DILocation(line: 6, column: 17, scope: !6)
74
75...
76---
77# CHECK: name: _Z3fn1v
78# CHECK: bb.10.for.body.9
79# CHECK: renamable $al
80# CHECK-NEXT: TEST8rr killed renamable $al
81# CHECK-NEXT: JCC_1
82# CHECK-NOT: $al = IMPLICIT_DEF
83# CHECK: bb.12.for.body.10
84
85name:            _Z3fn1v
86alignment:       16
87tracksRegLiveness: true
88constants:
89body:             |
90  bb.0.entry:
91    successors: %bb.1, %bb.4
92    liveins: $rdi, $rbp, $r15, $r14, $r13, $r12, $rbx
93
94    renamable $al = MOV8ri 1
95    TEST8rr renamable $al, renamable $al, implicit-def $eflags
96    JCC_1 %bb.4, 5, implicit killed $eflags
97
98  bb.1.for.cond.cleanup:
99    successors: %bb.3, %bb.2
100    liveins: $ecx, $rdi
101
102    renamable $eax = MOV32rm $rsp, 1, $noreg, -16, $noreg
103    CMP32rm killed renamable $eax, $rip, 1, $noreg, $noreg, $noreg, implicit-def $eflags
104    JCC_1 %bb.3, 6, implicit $eflags
105
106  bb.2:
107    successors: %bb.3
108    liveins: $ebp, $ebx, $edx, $esi, $rdi, $r8d, $r9d, $r10d, $r11d, $r12d, $r13d, $r14d, $r15d
109
110  bb.3.for.cond.cleanup:
111    liveins: $rdi, $xmm3, $xmm4, $xmm5, $xmm6, $xmm7, $xmm9, $xmm13, $xmm14
112    RETQ
113
114  bb.4.for.body:
115    successors: %bb.1, %bb.5
116    liveins: $al, $rdi
117
118    renamable $ecx = XOR32rr undef $ecx, undef $ecx, implicit-def dead $eflags
119    TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
120    JCC_1 %bb.1, 5, implicit $eflags
121
122  bb.5.for.body.1:
123    successors: %bb.1, %bb.6
124    liveins: $ecx, $rdi
125
126    renamable $al = MOV8ri 1
127    TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
128    JCC_1 %bb.1, 5, implicit $eflags
129
130  bb.6.for.body.2:
131    successors: %bb.1, %bb.7
132    liveins: $ecx, $eflags, $rdi
133
134    JCC_1 %bb.1, 5, implicit $eflags
135
136  bb.7.for.body.3:
137    successors: %bb.1, %bb.8
138    liveins: $ecx, $rdi
139
140    renamable $al = MOV8ri 1
141    TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
142    JCC_1 %bb.1, 5, implicit $eflags
143
144  bb.8.for.body.4:
145    successors: %bb.1, %bb.9
146    liveins: $ecx, $eflags, $rdi
147
148    JCC_1 %bb.1, 5, implicit $eflags
149
150  bb.9.for.body.5:
151    successors: %bb.1, %bb.10
152    liveins: $ecx, $rdi
153
154    renamable $al = MOV8ri 1
155    TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
156    JCC_1 %bb.1, 5, implicit $eflags
157
158  bb.10.for.body.6:
159    successors: %bb.1, %bb.11
160    liveins: $ecx, $eflags, $rdi
161
162    JCC_1 %bb.1, 5, implicit $eflags
163
164  bb.11.for.body.7:
165    successors: %bb.1, %bb.12
166    liveins: $ecx, $rdi
167
168    renamable $al = MOV8ri 1
169    TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
170    JCC_1 %bb.1, 5, implicit $eflags
171
172  bb.12.for.body.8:
173    successors: %bb.1, %bb.13
174    liveins: $ecx, $eflags, $rdi
175
176    JCC_1 %bb.1, 5, implicit $eflags
177
178  bb.13.for.body.9:
179    successors: %bb.14, %bb.15
180    liveins: $rdi
181
182    renamable $al = MOV8ri 1
183    TEST8rr killed renamable $al, renamable $al, implicit-def $eflags
184    JCC_1 %bb.15, 4, implicit $eflags
185
186  bb.14:
187    successors: %bb.1
188    liveins: $rdi
189
190    renamable $ecx = XOR32rr undef $ecx, undef $ecx, implicit-def dead $eflags
191    JMP_1 %bb.1
192
193  bb.15.for.body.10:
194    successors: %bb.16, %bb.17
195    liveins: $eflags, $rdi
196
197    JCC_1 %bb.17, 4, implicit killed $eflags
198
199  bb.16:
200    successors: %bb.1
201    liveins: $rdi
202
203    JMP_1 %bb.1
204
205  bb.17.for.body.11:
206    successors: %bb.1
207    liveins: $rdi
208
209    dead renamable $al = MOV8rm $rsp, 1, $noreg, -121, $noreg
210    DBG_VALUE $al, $noreg, !16, !DIExpression(), debug-location !19
211    renamable $ecx = XOR32rr undef $ecx, undef $ecx, implicit-def dead $eflags
212    JMP_1 %bb.1
213...
214