llvm.org GIT mirror llvm / 00f5926
treat invoke like call Summary: InvokeInst should be treated like CallInst and assigned a separate discriminator. This is particularly import when an Invoke is converted to a Call during compilation and so can invalidate sample profile data collected wtih different link time optimizations Reviewers: twoh, Kader, danielcdh, wmi Reviewed By: wmi Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D56491 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351251 91177308-0d34-0410-b5e6-96231b3b80d8 David Callahan 7 months ago
2 changed file(s) with 139 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
231231 for (BasicBlock &B : F) {
232232 LocationSet CallLocations;
233233 for (auto &I : B.getInstList()) {
234 CallInst *Current = dyn_cast(&I);
235234 // We bypass intrinsic calls for the following two reasons:
236235 // 1) We want to avoid a non-deterministic assigment of
237236 // discriminators.
238237 // 2) We want to minimize the number of base discriminators used.
239 if (!Current || isa(&I))
240 continue;
241
242 DILocation *CurrentDIL = Current->getDebugLoc();
238 if (!isa(I) && (!isa(I) || isa(I)))
239 continue;
240
241 DILocation *CurrentDIL = I.getDebugLoc();
243242 if (!CurrentDIL)
244243 continue;
245244 Location L =
254253 << CurrentDIL->getLine() << ":" << CurrentDIL->getColumn()
255254 << ":" << Discriminator << " " << I << "\n");
256255 } else {
257 Current->setDebugLoc(NewDIL.getValue());
256 I.setDebugLoc(NewDIL.getValue());
258257 Changed = true;
259258 }
260259 }
0 ; RUN: opt < %s -add-discriminators -S | FileCheck %s
1 ; ModuleID = 'invoke.bc'
2 source_filename = "invoke.cpp"
3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-apple-macosx10.14.0"
5
6 ; Function Attrs: ssp uwtable
7 define void @_Z3foov() #0 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) !dbg !8 {
8 entry:
9 %exn.slot = alloca i8*
10 %ehselector.slot = alloca i32
11 ; CHECK: call void @_Z12bar_noexceptv({{.*}} !dbg ![[CALL1:[0-9]+]]
12 call void @_Z12bar_noexceptv() #4, !dbg !11
13 ; CHECK: call void @_Z12bar_noexceptv({{.*}} !dbg ![[CALL2:[0-9]+]]
14 call void @_Z12bar_noexceptv() #4, !dbg !13
15 invoke void @_Z3barv()
16 ; CHECK: unwind label {{.*}} !dbg ![[INVOKE:[0-9]+]]
17 to label %invoke.cont unwind label %lpad, !dbg !14
18
19 invoke.cont: ; preds = %entry
20 br label %try.cont, !dbg !15
21
22 lpad: ; preds = %entry
23 %0 = landingpad { i8*, i32 }
24 catch i8* null, !dbg !16
25 %1 = extractvalue { i8*, i32 } %0, 0, !dbg !16
26 store i8* %1, i8** %exn.slot, align 8, !dbg !16
27 %2 = extractvalue { i8*, i32 } %0, 1, !dbg !16
28 store i32 %2, i32* %ehselector.slot, align 4, !dbg !16
29 br label %catch, !dbg !16
30
31 catch: ; preds = %lpad
32 %exn = load i8*, i8** %exn.slot, align 8, !dbg !15
33 %3 = call i8* @__cxa_begin_catch(i8* %exn) #4, !dbg !15
34 invoke void @__cxa_rethrow() #5
35 to label %unreachable unwind label %lpad1, !dbg !17
36
37 lpad1: ; preds = %catch
38 %4 = landingpad { i8*, i32 }
39 cleanup, !dbg !19
40 %5 = extractvalue { i8*, i32 } %4, 0, !dbg !19
41 store i8* %5, i8** %exn.slot, align 8, !dbg !19
42 %6 = extractvalue { i8*, i32 } %4, 1, !dbg !19
43 store i32 %6, i32* %ehselector.slot, align 4, !dbg !19
44 invoke void @__cxa_end_catch()
45 to label %invoke.cont2 unwind label %terminate.lpad, !dbg !20
46
47 invoke.cont2: ; preds = %lpad1
48 br label %eh.resume, !dbg !20
49
50 try.cont: ; preds = %invoke.cont
51 ret void, !dbg !21
52
53 eh.resume: ; preds = %invoke.cont2
54 %exn3 = load i8*, i8** %exn.slot, align 8, !dbg !20
55 %sel = load i32, i32* %ehselector.slot, align 4, !dbg !20
56 %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn3, 0, !dbg !20
57 %lpad.val4 = insertvalue { i8*, i32 } %lpad.val, i32 %sel, 1, !dbg !20
58 resume { i8*, i32 } %lpad.val4, !dbg !20
59
60 terminate.lpad: ; preds = %lpad1
61 %7 = landingpad { i8*, i32 }
62 catch i8* null, !dbg !20
63 %8 = extractvalue { i8*, i32 } %7, 0, !dbg !20
64 call void @__clang_call_terminate(i8* %8) #6, !dbg !20
65 unreachable, !dbg !20
66
67 unreachable: ; preds = %catch
68 unreachable
69 }
70
71 ; Function Attrs: nounwind
72 declare void @_Z12bar_noexceptv() #1
73
74 declare void @_Z3barv() #2
75
76 declare i32 @__gxx_personality_v0(...)
77
78 declare i8* @__cxa_begin_catch(i8*)
79
80 declare void @__cxa_rethrow()
81
82 declare void @__cxa_end_catch()
83
84 ; Function Attrs: noinline noreturn nounwind
85 define linkonce_odr hidden void @__clang_call_terminate(i8*) #3 {
86 %2 = call i8* @__cxa_begin_catch(i8* %0) #4
87 call void @_ZSt9terminatev() #6
88 unreachable
89 }
90
91 declare void @_ZSt9terminatev()
92
93 attributes #0 = { ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
94 attributes #1 = { nounwind "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-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
95 attributes #2 = { "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-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
96 attributes #3 = { noinline noreturn nounwind }
97 attributes #4 = { nounwind }
98 attributes #5 = { noreturn }
99 attributes #6 = { noreturn nounwind }
100
101 !llvm.dbg.cu = !{!0}
102 !llvm.module.flags = !{!3, !4, !5, !6}
103 !llvm.ident = !{!7}
104
105 ; CHECK: ![[CALL1]] = !DILocation(line: 7, column: 5, scope: ![[SCOPE1:[0-9]+]])
106 ; CHECK: ![[SCOPE1]] = distinct !DILexicalBlock(scope: !8, file: !1, line: 6, column: 7)
107 ; CHECK: ![[CALL2]] = !DILocation(line: 7, column: 21, scope: ![[SCOPE2:[0-9]+]])
108 ; CHECK: ![[SCOPE2]] = !DILexicalBlockFile(scope: ![[SCOPE1]], file: !1, discriminator: 2)
109 ; CHECK: ![[INVOKE]] = !DILocation(line: 7, column: 37, scope: ![[SCOPE3:[0-9]+]])
110 ; CHECK: ![[SCOPE3]] = !DILexicalBlockFile(scope: ![[SCOPE1]], file: !1, discriminator: 4)
111
112 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 8.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: GNU)
113 !1 = !DIFile(filename: "invoke.cpp", directory: "examples")
114 !2 = !{}
115 !3 = !{i32 2, !"Dwarf Version", i32 4}
116 !4 = !{i32 2, !"Debug Info Version", i32 3}
117 !5 = !{i32 1, !"wchar_size", i32 4}
118 !6 = !{i32 7, !"PIC Level", i32 2}
119 !7 = !{!"clang version 8.0.0"}
120 !8 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 5, type: !9, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
121 !9 = !DISubroutineType(types: !10)
122 !10 = !{null}
123 !11 = !DILocation(line: 7, column: 5, scope: !12)
124 !12 = distinct !DILexicalBlock(scope: !8, file: !1, line: 6, column: 7)
125 !13 = !DILocation(line: 7, column: 21, scope: !12)
126 !14 = !DILocation(line: 7, column: 37, scope: !12)
127 !15 = !DILocation(line: 8, column: 3, scope: !12)
128 !16 = !DILocation(line: 12, column: 1, scope: !12)
129 !17 = !DILocation(line: 10, column: 5, scope: !18)
130 !18 = distinct !DILexicalBlock(scope: !8, file: !1, line: 9, column: 15)
131 !19 = !DILocation(line: 12, column: 1, scope: !18)
132 !20 = !DILocation(line: 11, column: 3, scope: !18)
133 !21 = !DILocation(line: 12, column: 1, scope: !8)