Skip to content

Commit 23da210

Browse files
committed
[PseudoProbe] Do not force the calliste debug loc to inlined probes from __nodebug__ functions.
For pseudo probes we would like to keep their original dwarf discriminator (either a zero or null) until the first FS-discriminator pass. The inliner is a violation of that, given that it assigns inlinee instructions with no debug info with the that of the callsite. This is being disabled in this patch. Reviewed By: wenlei Differential Revision: https://reviews.llvm.org/D151568
1 parent 7c91d82 commit 23da210

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

llvm/lib/Transforms/Utils/InlineFunction.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,12 @@ static void fixupLineNumbers(Function *Fn, Function::iterator FI,
16361636
if (allocaWouldBeStaticInEntry(AI))
16371637
continue;
16381638

1639+
// Do not force a debug loc for pseudo probes, since they do not need to
1640+
// be debuggable, and also they are expected to have a zero/null dwarf
1641+
// discriminator at this point which could be violated otherwise.
1642+
if (isa<PseudoProbeInst>(BI))
1643+
continue;
1644+
16391645
BI->setDebugLoc(TheCallDL);
16401646
}
16411647

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
; RUN: opt < %s -passes='pseudo-probe,cgscc(inline)' -S | FileCheck %s
2+
3+
4+
; CHECK-LABEL: @caller(
5+
6+
; This instruction did not have a !dbg metadata in the callee but get a !dbg after inlined.
7+
; CHECK: store i32 1, {{.*}}, !dbg ![[#]]
8+
9+
; This pseudo probe came from callee without a !dbg metadata.
10+
; CHECK-NOT: call void @llvm.pseudoprobe({{.*}}), !dbg ![[#]]
11+
; CHECK: call void @llvm.pseudoprobe({{.*}})
12+
13+
14+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
15+
target triple = "x86_64-unknown-linux-gnu"
16+
17+
@a = common global i32 0, align 4
18+
@b = common global i32 0, align 4
19+
20+
; Function Attrs: nounwind uwtable
21+
define void @callee() #0 {
22+
entry:
23+
store i32 1, ptr @a, align 4
24+
ret void
25+
}
26+
27+
; Function Attrs: nounwind uwtable
28+
define void @caller() #0 !dbg !4 {
29+
entry:
30+
tail call void @callee(), !dbg !12
31+
ret void, !dbg !12
32+
}
33+
34+
attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
35+
36+
!llvm.dbg.cu = !{!0}
37+
!llvm.module.flags = !{!8, !9}
38+
!llvm.ident = !{!10}
39+
40+
!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 (210174)", isOptimized: true, emissionKind: LineTablesOnly, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
41+
!1 = !DIFile(filename: "test.c", directory: "/code/llvm/build0")
42+
!2 = !{}
43+
!4 = distinct !DISubprogram(name: "caller", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !0, scopeLine: 4, file: !1, scope: !5, type: !6, retainedNodes: !2)
44+
!5 = !DIFile(filename: "test.c", directory: "/code/llvm/build0")
45+
!6 = !DISubroutineType(types: !2)
46+
!7 = distinct !DISubprogram(name: "callee2", line: 2, isLocal: true, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !0, scopeLine: 2, file: !1, scope: !5, type: !6, retainedNodes: !2)
47+
!8 = !{i32 2, !"Dwarf Version", i32 4}
48+
!9 = !{i32 2, !"Debug Info Version", i32 3}
49+
!10 = !{!"clang version 3.5.0 (210174)"}
50+
!11 = !DILocation(line: 2, scope: !7)
51+
!12 = !DILocation(line: 4, scope: !4)

0 commit comments

Comments
 (0)