1 ; RUN: opt -S -o - -structurizecfg %s | FileCheck %s
3 define void @if_then_else(ptr addrspace(1) %out, i1 %arg) !dbg !7 {
4 ; CHECK: @if_then_else(
6 ; CHECK: br i1 {{.*}}, label %if.else, label %Flow, !dbg [[ITE_ENTRY_DL:![0-9]+]]
8 ; CHECK: br i1 {{.*}}, label %if.then, label %exit, !dbg [[ITE_ENTRY_DL]]
10 ; CHECK: br label %exit, !dbg [[ITE_IFTHEN_DL:![0-9]+]]
12 ; CHECK: br label %Flow, !dbg [[ITE_IFELSE_DL:![0-9]+]]
16 br i1 %arg, label %if.then, label %if.else, !dbg !8
19 store i32 0, ptr addrspace(1) %out, !dbg !9
20 br label %exit, !dbg !10
23 store i32 1, ptr addrspace(1) %out, !dbg !11
24 br label %exit, !dbg !12
30 define void @while_loop(ptr addrspace(1) %out) !dbg !14 {
33 ; CHECK: br label %while.header, !dbg [[WHILE_ENTRY_DL:![0-9]+]]
34 ; CHECK: while.header:
35 ; CHECK: br i1 {{.*}}, label %while.body, label %Flow, !dbg [[WHILE_HEADER_DL:![0-9]+]]
37 ; CHECK: br label %Flow, !dbg [[WHILE_BODY_DL:![0-9]+]]
39 ; CHECK: br i1 {{.*}}, label %exit, label %while.header, !dbg [[WHILE_HEADER_DL]]
43 br label %while.header, !dbg !15
46 %cond = call i1 @loop_condition(), !dbg !16
47 br i1 %cond, label %while.body, label %exit, !dbg !17
50 store i32 1, ptr addrspace(1) %out, !dbg !18
51 br label %while.header, !dbg !19
57 define void @while_multiple_exits(ptr addrspace(1) %out) !dbg !21 {
58 ; CHECK: @while_multiple_exits(
60 ; CHECK: br label %while.header, !dbg [[WHILEME_ENTRY_DL:![0-9]+]]
61 ; CHECK: while.header:
62 ; CHECK: br i1 {{.*}}, label %while.exiting, label %Flow, !dbg [[WHILEME_HEADER_DL:![0-9]+]]
63 ; CHECK: while.exiting:
64 ; CHECK: br label %Flow, !dbg [[WHILEME_EXITING_DL:![0-9]+]]
66 ; CHECK: br i1 {{.*}}, label %exit, label %while.header, !dbg [[WHILEME_HEADER_DL]]
70 br label %while.header, !dbg !22
73 %cond0 = call i1 @loop_condition(), !dbg !23
74 br i1 %cond0, label %while.exiting, label %exit, !dbg !24
77 %cond1 = call i1 @loop_condition(), !dbg !25
78 br i1 %cond1, label %while.header, label %exit, !dbg !26
84 define void @nested_if_then_else(ptr addrspace(1) %out, i1 %a, i1 %b) !dbg !28 {
85 ; CHECK: @nested_if_then_else(
87 ; CHECK: br i1 {{.*}}, label %if.else, label %Flow4, !dbg [[NESTED_ENTRY_DL:![0-9]+]]
89 ; CHECK: br i1 {{.*}}, label %if.then, label %exit, !dbg [[NESTED_ENTRY_DL]]
91 ; CHECK: br i1 {{.*}}, label %if.then.else, label %Flow2, !dbg [[NESTED_IFTHEN_DL:![0-9]+]]
93 ; CHECK: br i1 {{.*}}, label %if.then.then, label %Flow3, !dbg [[NESTED_IFTHEN_DL]]
94 ; CHECK: if.then.then:
95 ; CHECK: br label %Flow3, !dbg [[NESTED_IFTHENTHEN_DL:![0-9]+]]
96 ; CHECK: if.then.else:
97 ; CHECK: br label %Flow2, !dbg [[NESTED_IFTHENELSE_DL:![0-9]+]]
99 ; CHECK: br i1 {{.*}}, label %if.else.else, label %Flow, !dbg [[NESTED_IFELSE_DL:![0-9]+]]
101 ; CHECK: br i1 {{.*}}, label %if.else.then, label %Flow1, !dbg [[NESTED_IFELSE_DL]]
102 ; CHECK: if.else.then:
103 ; CHECK: br label %Flow1, !dbg [[NESTED_IFELSETHEN_DL:![0-9]+]]
104 ; CHECK: if.else.else:
105 ; CHECK: br label %Flow, !dbg [[NESTED_IFELSEELSE_DL:![0-9]+]]
107 ; CHECK: br label %Flow4, !dbg [[NESTED_IFELSE_DL]]
109 ; CHECK: br label %exit, !dbg [[NESTED_IFTHEN_DL]]
113 br i1 %a, label %if.then, label %if.else, !dbg !29
116 br i1 %b, label %if.then.then, label %if.then.else, !dbg !30
119 store i32 0, ptr addrspace(1) %out, !dbg !31
120 br label %exit, !dbg !32
123 store i32 1, ptr addrspace(1) %out, !dbg !33
124 br label %exit, !dbg !34
127 br i1 %b, label %if.else.then, label %if.else.else, !dbg !35
130 store i32 2, ptr addrspace(1) %out, !dbg !36
131 br label %exit, !dbg !37
134 store i32 3, ptr addrspace(1) %out, !dbg !38
135 br label %exit, !dbg !39
141 declare i1 @loop_condition()
144 !llvm.module.flags = !{!4, !5}
146 ; CHECK: [[ITE_ENTRY_DL]] = !DILocation(line: 2
147 ; CHECK: [[ITE_IFTHEN_DL]] = !DILocation(line: 4
148 ; CHECK: [[ITE_IFELSE_DL]] = !DILocation(line: 6
149 ; CHECK: [[WHILE_ENTRY_DL]] = !DILocation(line: 2
150 ; CHECK: [[WHILE_HEADER_DL]] = !DILocation(line: 4
151 ; CHECK: [[WHILE_BODY_DL]] = !DILocation(line: 6
152 ; CHECK: [[WHILEME_ENTRY_DL]] = !DILocation(line: 2
153 ; CHECK: [[WHILEME_HEADER_DL]] = !DILocation(line: 4
154 ; CHECK: [[WHILEME_EXITING_DL]] = !DILocation(line: 6
155 ; CHECK: [[NESTED_ENTRY_DL]] = !DILocation(line: 2
156 ; CHECK: [[NESTED_IFTHEN_DL]] = !DILocation(line: 3
157 ; CHECK: [[NESTED_IFTHENTHEN_DL]] = !DILocation(line: 5
158 ; CHECK: [[NESTED_IFTHENELSE_DL]] = !DILocation(line: 7
159 ; CHECK: [[NESTED_IFELSE_DL]] = !DILocation(line: 8
160 ; CHECK: [[NESTED_IFELSETHEN_DL]] = !DILocation(line: 10
161 ; CHECK: [[NESTED_IFELSEELSE_DL]] = !DILocation(line: 12
164 !1 = !DIFile(filename: "dummy.ll", directory: "/some/random/directory")
165 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !0)
166 !4 = !{i32 2, !"Dwarf Version", i32 5}
167 !5 = !{i32 2, !"Debug Info Version", i32 3}
168 !6 = !DISubroutineType(types: !0)
169 !7 = distinct !DISubprogram(name: "dummy", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !2, retainedNodes: !0)
170 !8 = !DILocation(line: 2, scope: !7)
171 !9 = !DILocation(line: 3, scope: !7)
172 !10 = !DILocation(line: 4, scope: !7)
173 !11 = !DILocation(line: 5, scope: !7)
174 !12 = !DILocation(line: 6, scope: !7)
175 !13 = !DILocation(line: 7, scope: !7)
176 !14 = distinct !DISubprogram(name: "dummy", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !2, retainedNodes: !0)
177 !15 = !DILocation(line: 2, scope: !14)
178 !16 = !DILocation(line: 3, scope: !14)
179 !17 = !DILocation(line: 4, scope: !14)
180 !18 = !DILocation(line: 5, scope: !14)
181 !19 = !DILocation(line: 6, scope: !14)
182 !20 = !DILocation(line: 7, scope: !14)
183 !21 = distinct !DISubprogram(name: "dummy", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !2, retainedNodes: !0)
184 !22 = !DILocation(line: 2, scope: !21)
185 !23 = !DILocation(line: 3, scope: !21)
186 !24 = !DILocation(line: 4, scope: !21)
187 !25 = !DILocation(line: 5, scope: !21)
188 !26 = !DILocation(line: 6, scope: !21)
189 !27 = !DILocation(line: 7, scope: !21)
190 !28 = distinct !DISubprogram(name: "dummy", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !2, retainedNodes: !0)
191 !29 = !DILocation(line: 2, scope: !28)
192 !30 = !DILocation(line: 3, scope: !28)
193 !31 = !DILocation(line: 4, scope: !28)
194 !32 = !DILocation(line: 5, scope: !28)
195 !33 = !DILocation(line: 6, scope: !28)
196 !34 = !DILocation(line: 7, scope: !28)
197 !35 = !DILocation(line: 8, scope: !28)
198 !36 = !DILocation(line: 9, scope: !28)
199 !37 = !DILocation(line: 10, scope: !28)
200 !38 = !DILocation(line: 11, scope: !28)
201 !39 = !DILocation(line: 12, scope: !28)
202 !40 = !DILocation(line: 13, scope: !28)