<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 9, 2015 at 1:29 PM, Dehao Chen via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">danielcdh updated this revision to Diff 39745.<br>
danielcdh added a comment.<br>
<br>
Simplify the testcase.<br>
<span class=""><br>
<br>
<a href="http://reviews.llvm.org/D14511" rel="noreferrer" target="_blank">http://reviews.llvm.org/D14511</a><br>
<br>
Files:<br>
  include/llvm/Support/Dwarf.h<br>
  lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
  lib/Support/Dwarf.cpp<br>
  test/DebugInfo/Generic/discriminator.ll<br>
<br>
</span>Index: test/DebugInfo/Generic/discriminator.ll<br>
===================================================================<br>
--- /dev/null<br>
+++ test/DebugInfo/Generic/discriminator.ll<br>
@@ -0,0 +1,49 @@<br>
+; REQUIRES: object-emission<br>
+<br>
+; RUN: %llc_dwarf < %s -filetype=obj | llvm-dwarfdump -debug-dump=info - | FileCheck %s<br>
+<br>
+; Given the following source, ensure that the discriminator is emitted for<br>
+; the inlined callsite.<br>
+<br>
+;void xyz();<br>
+;static void bar() __attribute__((always_inline));<br></blockquote><div><br></div><div>Doesn't need a separate declaration, just<br><br>static __attribute__((always_inline)) void bar() { xyz(); }<br><br>should suffice, I think?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+;static void bar() { xyz(); }<br>
+;void foo() {<br>
+;  bar(); bar();<br>
+;}<br>
+<br>
+; CHECK: DW_AT_GNU_discriminator<br>
+<br>
+; Function Attrs: uwtable<br>
+define void @_Z3foov() #0 !dbg !4 {<br>
+  tail call void @_Z3xyzv(), !dbg !11<br>
+  tail call void @_Z3xyzv(), !dbg !13<br>
+  ret void, !dbg !16<br>
+}<br>
+<br>
+declare void @_Z3xyzv() #1<br>
+<br>
+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" }<br>
+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" }<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
+!llvm.module.flags = !{!8, !9}<br>
+!llvm.ident = !{!10}<br>
+<br>
+!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)<br>
+!1 = !DIFile(filename: "a.cc", directory: "/tmp")<br>
+!2 = !{}<br>
+!3 = !{!4, !7}<br>
+!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 4, type: !5, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, variables: !2)<br>
+!5 = !DISubroutineType(types: !6)<br>
+!6 = !{null}<br>
+!7 = distinct !DISubprogram(name: "bar", linkageName: "_ZL3barv", scope: !1, file: !1, line: 3, type: !5, isLocal: true, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, variables: !2)<br>
+!8 = !{i32 2, !"Dwarf Version", i32 4}<br>
+!9 = !{i32 2, !"Debug Info Version", i32 3}<br>
+!10 = !{!"clang version 3.8.0 (trunk 252497)"}<br>
+!11 = !DILocation(line: 3, column: 21, scope: !7, inlinedAt: !12)<br>
+!12 = distinct !DILocation(line: 5, column: 3, scope: !4)<br>
+!13 = !DILocation(line: 3, column: 21, scope: !7, inlinedAt: !14)<br>
+!14 = distinct !DILocation(line: 5, column: 10, scope: !15)<br>
+!15 = !DILexicalBlockFile(scope: !4, file: !1, discriminator: 1)<br>
+!16 = !DILocation(line: 6, column: 1, scope: !4)<br>
Index: lib/Support/Dwarf.cpp<br>
===================================================================<br>
--- lib/Support/Dwarf.cpp<br>
+++ lib/Support/Dwarf.cpp<br>
@@ -201,6 +201,7 @@<br>
   case DW_AT_GNU_addr_base:              return "DW_AT_GNU_addr_base";<br>
   case DW_AT_GNU_pubnames:               return "DW_AT_GNU_pubnames";<br>
   case DW_AT_GNU_pubtypes:               return "DW_AT_GNU_pubtypes";<br>
+  case DW_AT_GNU_discriminator:          return "DW_AT_GNU_discriminator";<br>
   }<br>
   return nullptr;<br>
 }<br>
Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
===================================================================<br>
--- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
+++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
@@ -439,6 +439,9 @@<br>
   addUInt(*ScopeDIE, dwarf::DW_AT_call_file, None,<br>
           getOrCreateSourceID(IA->getFilename(), IA->getDirectory()));<br>
   addUInt(*ScopeDIE, dwarf::DW_AT_call_line, None, IA->getLine());<br>
+  if (IA->getDiscriminator()) {<br>
+    addUInt(*ScopeDIE, dwarf::DW_AT_GNU_discriminator, None, IA->getDiscriminator());<br>
+  }<br>
<br>
   // Add name to the name table, we do this here because we're guaranteed<br>
   // to have concrete versions of our DW_TAG_inlined_subprogram nodes.<br>
Index: include/llvm/Support/Dwarf.h<br>
===================================================================<br>
--- include/llvm/Support/Dwarf.h<br>
+++ include/llvm/Support/Dwarf.h<br>
@@ -238,6 +238,7 @@<br>
   DW_AT_GNU_addr_base = 0x2133,<br>
   DW_AT_GNU_pubnames = 0x2134,<br>
   DW_AT_GNU_pubtypes = 0x2135,<br>
+  DW_AT_GNU_discriminator = 0x2136,<br>
<br>
   // LLVM project extensions.<br>
   DW_AT_LLVM_include_path = 0x3e00,<br>
<br>
<br>
<br>_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
<br></blockquote></div><br></div></div>