<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Fri, Mar 24, 2017 at 2:38 PM Zhizhou Yang <<a href="mailto:zhizhouy@google.com">zhizhouy@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Thanks! May I ask do I create a cc file, generate the elf file and put them into Input directory?</div></blockquote><div><br>Nah - looks like you've got it mostly right (you've got the IR file, you run it through llc and FileCheck the output). <br><br>It's an extra step - rather than FileChecking the output of llc, run the output of llc through llvm-dwarfdump, then FileCheck that.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The test I added is to check the behavior of addString to DW_AT_producer, like as a unit test. So do I no longer keep that?</div></div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg">On Fri, Mar 24, 2017 at 2:09 PM, David Blaikie <span dir="ltr" class="gmail_msg"><<a href="mailto:dblaikie@gmail.com" class="gmail_msg" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Rather than testing the generated assembly, DWARF tests usually use llvm-dwarfdump to test the DWARF. Check other tests in LLVM's test/DebugInfo/...</div><div class="m_-7984295333052684723HOEnZb gmail_msg"><div class="m_-7984295333052684723h5 gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Fri, Mar 24, 2017 at 1:55 PM Zhizhou Yang via Phabricator <<a href="mailto:reviews@reviews.llvm.org" class="gmail_msg" target="_blank">reviews@reviews.llvm.org</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">zhizhouy updated this revision to Diff 93002.<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
zhizhouy marked an inline comment as done.<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
zhizhouy added a comment.<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
Fixed StringRef related problem.<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
Added a testcase for it.<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
<a href="https://reviews.llvm.org/D31315" rel="noreferrer" class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg" target="_blank">https://reviews.llvm.org/D31315</a><br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
Files:<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
test/CodeGen/X86/dwarf-producer-with-flags.ll<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
Index: test/CodeGen/X86/dwarf-producer-with-flags.ll<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
===================================================================<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
--- /dev/null<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+++ test/CodeGen/X86/dwarf-producer-with-flags.ll<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
@@ -0,0 +1,28 @@<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+; RUN: llc -o - %s | FileCheck %s<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+; CHECK: .Linfo_string0:<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+; CHECK-NEXT: .asciz "clang -g -grecord-gcc-switches -S -llvm-emit -o test.ll"<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+; CHECK: .Linfo_string0 # DW_AT_producer<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+target triple = "x86_64-unknown-linux-gnu"<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+define i32 @main() !dbg !6 {<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+entry:<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+ %retval = alloca i32, align 4<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+ store i32 0, i32* %retval, align 4<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+ ret i32 0, !dbg !10<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+}<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+!<a href="http://llvm.dbg.cu" rel="noreferrer" class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg" target="_blank">llvm.dbg.cu</a> = !{!0}<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+!llvm.module.flags = !{!3, !4}<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+!llvm.ident = !{!5}<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, flags: "-g -grecord-gcc-switches -S -llvm-emit -o test.ll", runtimeVersion: 0, emissionKind: FullDebug, enums: !2)<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+!1 = !DIFile(filename: "foo.c", directory: "d")<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+!2 = !{}<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+!3 = !{i32 2, !"Dwarf Version", i32 4}<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+!4 = !{i32 2, !"Debug Info Version", i32 3}<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+!5 = !{!"clang"}<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+!6 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 4, type: !7, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+!7 = !DISubroutineType(types: !8)<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+!8 = !{!9}<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+!10 = !DILocation(line: 5, column: 3, scope: !6)<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
===================================================================<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
@@ -423,7 +423,14 @@<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
Asm->OutStreamer->getContext().setMCLineTableCompilationDir(<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
NewCU.getUniqueID(), CompilationDir);<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
- NewCU.addString(Die, dwarf::DW_AT_producer, DIUnit->getProducer());<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+ StringRef Producer = DIUnit->getProducer();<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+ StringRef Flags = DIUnit->getFlags();<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+ if (!Flags.empty()) {<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+ std::string ProducerWithFlags = Producer.str() + " " + Flags.str();<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+ NewCU.addString(Die, dwarf::DW_AT_producer, ProducerWithFlags);<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+ } else<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+ NewCU.addString(Die, dwarf::DW_AT_producer, Producer);<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
+<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
NewCU.addUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data2,<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
DIUnit->getSourceLanguage());<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
NewCU.addString(Die, dwarf::DW_AT_name, FN);<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
<br class="m_-7984295333052684723m_-7115805108502011045gmail_msg gmail_msg">
</blockquote></div>
</div></div></blockquote></div><br class="gmail_msg"></div>
</blockquote></div></div>