1 ; RUN: llvm-dis %s.bc -o - | FileCheck %s
2 ; ModuleID = 'DILocation-implicit-code.cpp'
3 source_filename = "DILocation-implicit-code.cpp"
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 %struct.A = type { i8 }
9 $_ZN1AC2Ev = comdat any
11 $_ZN1A3fooEi = comdat any
13 @_ZTIi = external dso_local constant i8*
15 ; Function Attrs: noinline optnone uwtable
16 define dso_local void @_Z5test1v() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) !dbg !7 {
18 %retval = alloca %struct.A, align 1
19 %a = alloca %struct.A, align 1
20 %exn.slot = alloca i8*
21 %ehselector.slot = alloca i32
22 %undef.agg.tmp = alloca %struct.A, align 1
23 %e = alloca i32, align 4
24 %undef.agg.tmp3 = alloca %struct.A, align 1
25 call void @_ZN1AC2Ev(%struct.A* %a), !dbg !9
26 invoke void @_ZN1A3fooEi(%struct.A* %a, i32 0)
27 to label %invoke.cont unwind label %lpad, !dbg !10
29 invoke.cont: ; preds = %entry
30 br label %return, !dbg !11
32 lpad: ; preds = %entry
33 %0 = landingpad { i8*, i32 }
34 catch i8* bitcast (i8** @_ZTIi to i8*), !dbg !12
35 %1 = extractvalue { i8*, i32 } %0, 0, !dbg !12
36 store i8* %1, i8** %exn.slot, align 8, !dbg !12
37 %2 = extractvalue { i8*, i32 } %0, 1, !dbg !12
38 store i32 %2, i32* %ehselector.slot, align 4, !dbg !12
39 br label %catch.dispatch, !dbg !12
41 catch.dispatch: ; preds = %lpad
42 %sel = load i32, i32* %ehselector.slot, align 4, !dbg !13
43 %3 = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #4, !dbg !13
44 %matches = icmp eq i32 %sel, %3, !dbg !13
45 br i1 %matches, label %catch, label %eh.resume, !dbg !13
47 catch: ; preds = %catch.dispatch
48 %exn = load i8*, i8** %exn.slot, align 8, !dbg !13
49 %4 = call i8* @__cxa_begin_catch(i8* %exn) #4, !dbg !13
50 %5 = bitcast i8* %4 to i32*, !dbg !13
51 %6 = load i32, i32* %5, align 4, !dbg !13
52 store i32 %6, i32* %e, align 4, !dbg !13
53 %7 = load i32, i32* %e, align 4, !dbg !14
54 invoke void @_ZN1A3fooEi(%struct.A* %a, i32 %7)
55 to label %invoke.cont2 unwind label %lpad1, !dbg !15
57 invoke.cont2: ; preds = %catch
58 call void @__cxa_end_catch() #4, !dbg !16
61 lpad1: ; preds = %catch
62 %8 = landingpad { i8*, i32 }
64 %9 = extractvalue { i8*, i32 } %8, 0, !dbg !12
65 store i8* %9, i8** %exn.slot, align 8, !dbg !12
66 %10 = extractvalue { i8*, i32 } %8, 1, !dbg !12
67 store i32 %10, i32* %ehselector.slot, align 4, !dbg !12
68 call void @__cxa_end_catch() #4, !dbg !16
69 br label %eh.resume, !dbg !16
71 try.cont: ; No predecessors!
72 call void @llvm.trap(), !dbg !16
75 return: ; preds = %invoke.cont2, %invoke.cont
78 eh.resume: ; preds = %lpad1, %catch.dispatch
79 %exn4 = load i8*, i8** %exn.slot, align 8, !dbg !13
80 %sel5 = load i32, i32* %ehselector.slot, align 4, !dbg !13
81 %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn4, 0, !dbg !13
82 %lpad.val6 = insertvalue { i8*, i32 } %lpad.val, i32 %sel5, 1, !dbg !13
83 resume { i8*, i32 } %lpad.val6, !dbg !13
86 ; Function Attrs: noinline nounwind optnone uwtable
87 define linkonce_odr dso_local void @_ZN1AC2Ev(%struct.A* %this) unnamed_addr #1 comdat align 2 !dbg !17 {
89 %this.addr = alloca %struct.A*, align 8
90 store %struct.A* %this, %struct.A** %this.addr, align 8
91 %this1 = load %struct.A*, %struct.A** %this.addr, align 8
95 ; Function Attrs: noinline optnone uwtable
96 define linkonce_odr dso_local void @_ZN1A3fooEi(%struct.A* %this, i32 %i) #0 comdat align 2 !dbg !19 {
98 %retval = alloca %struct.A, align 1
99 %this.addr = alloca %struct.A*, align 8
100 %i.addr = alloca i32, align 4
101 store %struct.A* %this, %struct.A** %this.addr, align 8
102 store i32 %i, i32* %i.addr, align 4
103 %this1 = load %struct.A*, %struct.A** %this.addr, align 8
104 %0 = load i32, i32* %i.addr, align 4, !dbg !20
105 %cmp = icmp eq i32 %0, 0, !dbg !21
106 br i1 %cmp, label %if.then, label %if.end, !dbg !20
108 if.then: ; preds = %entry
109 %exception = call i8* @__cxa_allocate_exception(i64 4) #4, !dbg !22
110 %1 = bitcast i8* %exception to i32*, !dbg !22
111 store i32 1, i32* %1, align 16, !dbg !22
112 call void @__cxa_throw(i8* %exception, i8* bitcast (i8** @_ZTIi to i8*), i8* null) #5, !dbg !22
113 unreachable, !dbg !22
115 if.end: ; preds = %entry
119 declare dso_local i32 @__gxx_personality_v0(...)
121 ; Function Attrs: nounwind readnone
122 declare i32 @llvm.eh.typeid.for(i8*) #2
124 declare dso_local i8* @__cxa_begin_catch(i8*)
126 declare dso_local void @__cxa_end_catch()
128 ; Function Attrs: noreturn nounwind
129 declare void @llvm.trap() #3
131 ; Function Attrs: noinline optnone uwtable
132 define dso_local void @_Z5test2v() #0 !dbg !24 {
134 %a = alloca %struct.A, align 1
135 %b = alloca %struct.A, align 1
136 %undef.agg.tmp = alloca %struct.A, align 1
137 call void @_ZN1AC2Ev(%struct.A* %a), !dbg !25
138 call void @_ZN1A3fooEi(%struct.A* %a, i32 1), !dbg !26
142 declare dso_local i8* @__cxa_allocate_exception(i64)
144 declare dso_local void @__cxa_throw(i8*, i8*, i8*)
146 attributes #0 = { noinline optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
147 attributes #1 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
148 attributes #2 = { nounwind readnone }
149 attributes #3 = { noreturn nounwind }
150 attributes #4 = { nounwind }
151 attributes #5 = { noreturn }
154 !llvm.module.flags = !{!3, !4, !5}
157 ; CHECK: !DILocation(line: 20, column: 1, scope: !{{[0-9]+}}, isImplicitCode: true)
158 ; CHECK: !DILocation(line: 17, column: 5, scope: !{{[0-9]+}}, isImplicitCode: true)
159 ; CHECK: !DILocation(line: 19, column: 5, scope: !{{[0-9]+}}, isImplicitCode: true)
160 ; CHECK: !DILocation(line: 3, column: 10, scope: !{{[0-9]+}}, isImplicitCode: true)
161 ; CHECK: !DILocation(line: 25, column: 1, scope: !{{[0-9]+}}, isImplicitCode: true)
163 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0 (trunk 342445)", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, nameTableKind: None)
164 !1 = !DIFile(filename: "DILocation-implicit-code.cpp", directory: "/tmp")
166 !3 = !{i32 2, !"Dwarf Version", i32 4}
167 !4 = !{i32 2, !"Debug Info Version", i32 3}
168 !5 = !{i32 1, !"wchar_size", i32 4}
169 !6 = !{!"clang version 8.0.0 (trunk 342445)"}
170 !7 = distinct !DISubprogram(name: "test1", scope: !1, file: !1, line: 13, type: !8, isLocal: false, isDefinition: true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
171 !8 = !DISubroutineType(types: !2)
172 !9 = !DILocation(line: 14, column: 7, scope: !7)
173 !10 = !DILocation(line: 16, column: 18, scope: !7)
174 !11 = !DILocation(line: 16, column: 9, scope: !7)
175 !12 = !DILocation(line: 20, column: 1, scope: !7, isImplicitCode: true)
176 !13 = !DILocation(line: 17, column: 5, scope: !7, isImplicitCode: true)
177 !14 = !DILocation(line: 18, column: 22, scope: !7)
178 !15 = !DILocation(line: 18, column: 18, scope: !7)
179 !16 = !DILocation(line: 19, column: 5, scope: !7, isImplicitCode: true)
180 !17 = distinct !DISubprogram(name: "A", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
181 !18 = !DILocation(line: 3, column: 10, scope: !17, isImplicitCode: true)
182 !19 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !8, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
183 !20 = !DILocation(line: 5, column: 13, scope: !19)
184 !21 = !DILocation(line: 5, column: 15, scope: !19)
185 !22 = !DILocation(line: 6, column: 13, scope: !19)
186 !23 = !DILocation(line: 9, column: 9, scope: !19)
187 !24 = distinct !DISubprogram(name: "test2", scope: !1, file: !1, line: 22, type: !8, isLocal: false, isDefinition: true, scopeLine: 22, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
188 !25 = !DILocation(line: 23, column: 7, scope: !24)
189 !26 = !DILocation(line: 24, column: 13, scope: !24)
190 !27 = !DILocation(line: 25, column: 1, scope: !24, isImplicitCode: true)