summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDehao Chen <dehao@google.com>2015-11-11 18:08:18 +0000
committerDehao Chen <dehao@google.com>2015-11-11 18:08:18 +0000
commit72fdf444b770fe8a7d355d5fe4793db664334302 (patch)
treeb1c780d0331f718e2887f8992e07985b6627eb69 /llvm
parentd4870df9bf3ba1428eefda3a41d77ea684f278eb (diff)
downloadbcm5719-llvm-72fdf444b770fe8a7d355d5fe4793db664334302.tar.gz
bcm5719-llvm-72fdf444b770fe8a7d355d5fe4793db664334302.zip
Emit discriminator for inlined callsites.
Summary: Inlined callsites need to be emitted in debug info so that sample profile can be annotated to the correct inlined instance. Reviewers: dnovillo, dblaikie Subscribers: dblaikie, llvm-commits Differential Revision: http://reviews.llvm.org/D14511 llvm-svn: 252768
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Support/Dwarf.h1
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp2
-rw-r--r--llvm/lib/Support/Dwarf.cpp1
-rw-r--r--llvm/test/DebugInfo/Generic/discriminator.ll52
4 files changed, 56 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/Dwarf.h b/llvm/include/llvm/Support/Dwarf.h
index c3312fc80c5..5c79fc125e1 100644
--- a/llvm/include/llvm/Support/Dwarf.h
+++ b/llvm/include/llvm/Support/Dwarf.h
@@ -238,6 +238,7 @@ enum Attribute : uint16_t {
DW_AT_GNU_addr_base = 0x2133,
DW_AT_GNU_pubnames = 0x2134,
DW_AT_GNU_pubtypes = 0x2135,
+ DW_AT_GNU_discriminator = 0x2136,
// LLVM project extensions.
DW_AT_LLVM_include_path = 0x3e00,
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 687d6ae7441..21bdb0d0c25 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -439,6 +439,8 @@ DIE *DwarfCompileUnit::constructInlinedScopeDIE(LexicalScope *Scope) {
addUInt(*ScopeDIE, dwarf::DW_AT_call_file, None,
getOrCreateSourceID(IA->getFilename(), IA->getDirectory()));
addUInt(*ScopeDIE, dwarf::DW_AT_call_line, None, IA->getLine());
+ if (IA->getDiscriminator())
+ addUInt(*ScopeDIE, dwarf::DW_AT_GNU_discriminator, None, IA->getDiscriminator());
// Add name to the name table, we do this here because we're guaranteed
// to have concrete versions of our DW_TAG_inlined_subprogram nodes.
diff --git a/llvm/lib/Support/Dwarf.cpp b/llvm/lib/Support/Dwarf.cpp
index 13a41557a8d..a6d12725ed0 100644
--- a/llvm/lib/Support/Dwarf.cpp
+++ b/llvm/lib/Support/Dwarf.cpp
@@ -201,6 +201,7 @@ const char *llvm::dwarf::AttributeString(unsigned Attribute) {
case DW_AT_GNU_addr_base: return "DW_AT_GNU_addr_base";
case DW_AT_GNU_pubnames: return "DW_AT_GNU_pubnames";
case DW_AT_GNU_pubtypes: return "DW_AT_GNU_pubtypes";
+ case DW_AT_GNU_discriminator: return "DW_AT_GNU_discriminator";
}
return nullptr;
}
diff --git a/llvm/test/DebugInfo/Generic/discriminator.ll b/llvm/test/DebugInfo/Generic/discriminator.ll
new file mode 100644
index 00000000000..6d0cc5626a6
--- /dev/null
+++ b/llvm/test/DebugInfo/Generic/discriminator.ll
@@ -0,0 +1,52 @@
+; REQUIRES: object-emission
+
+; RUN: %llc_dwarf < %s -filetype=obj | llvm-dwarfdump -debug-dump=info - | FileCheck %s
+
+; Given the following source, ensure that the discriminator is emitted for
+; the inlined callsite.
+
+;void xyz();
+;static void __attribute__((always_inline)) bar() { xyz(); }
+;void foo() {
+; bar(); bar();
+;}
+
+;CHECK: DW_TAG_inlined_subroutine
+;CHECK-NOT: DW_AT_GNU_discriminator
+;CHECK: DW_TAG_inlined_subroutine
+;CHECK-NOT: {{DW_TAG|NULL}}
+;CHECK: DW_AT_GNU_discriminator{{.*}}0x01
+
+; Function Attrs: uwtable
+define void @_Z3foov() #0 !dbg !4 {
+ tail call void @_Z3xyzv(), !dbg !11
+ tail call void @_Z3xyzv(), !dbg !13
+ ret void, !dbg !16
+}
+
+declare void @_Z3xyzv() #1
+
+attributes #0 = { uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!8, !9}
+!llvm.ident = !{!10}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 252497)", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3)
+!1 = !DIFile(filename: "a.cc", directory: "/tmp")
+!2 = !{}
+!3 = !{!4, !7}
+!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, variables: !2)
+!5 = !DISubroutineType(types: !6)
+!6 = !{null}
+!7 = distinct !DISubprogram(name: "bar", linkageName: "_ZL3barv", scope: !1, file: !1, line: 2, type: !5, isLocal: true, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, variables: !2)
+!8 = !{i32 2, !"Dwarf Version", i32 4}
+!9 = !{i32 2, !"Debug Info Version", i32 3}
+!10 = !{!"clang version 3.8.0 (trunk 252497)"}
+!11 = !DILocation(line: 2, column: 52, scope: !7, inlinedAt: !12)
+!12 = distinct !DILocation(line: 4, column: 3, scope: !4)
+!13 = !DILocation(line: 2, column: 52, scope: !7, inlinedAt: !14)
+!14 = distinct !DILocation(line: 4, column: 10, scope: !15)
+!15 = !DILexicalBlockFile(scope: !4, file: !1, discriminator: 1)
+!16 = !DILocation(line: 5, column: 1, scope: !4)
OpenPOWER on IntegriCloud