[PATCH] D31315: Record command lines in objects built by clang, LLVM part

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 24 14:42:39 PDT 2017


On Fri, Mar 24, 2017 at 2:38 PM Zhizhou Yang <zhizhouy at google.com> wrote:

> Thanks! May I ask do I create a cc file, generate the elf file and put
> them into Input directory?
>

Nah - looks like you've got it mostly right (you've got the IR file, you
run it through llc and FileCheck the output).

It's an extra step - rather than FileChecking the output of llc, run the
output of llc through llvm-dwarfdump, then FileCheck that.


>
> 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?
>
> On Fri, Mar 24, 2017 at 2:09 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
> Rather than testing the generated assembly, DWARF tests usually use
> llvm-dwarfdump to test the DWARF. Check other tests in LLVM's
> test/DebugInfo/...
>
> On Fri, Mar 24, 2017 at 1:55 PM Zhizhou Yang via Phabricator <
> reviews at reviews.llvm.org> wrote:
>
> zhizhouy updated this revision to Diff 93002.
> zhizhouy marked an inline comment as done.
> zhizhouy added a comment.
>
> Fixed StringRef related problem.
>
> Added a testcase for it.
>
>
> https://reviews.llvm.org/D31315
>
> Files:
>   lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>   test/CodeGen/X86/dwarf-producer-with-flags.ll
>
>
> Index: test/CodeGen/X86/dwarf-producer-with-flags.ll
> ===================================================================
> --- /dev/null
> +++ test/CodeGen/X86/dwarf-producer-with-flags.ll
> @@ -0,0 +1,28 @@
> +; RUN: llc -o - %s | FileCheck %s
> +; CHECK: .Linfo_string0:
> +; CHECK-NEXT: .asciz   "clang -g -grecord-gcc-switches -S -llvm-emit -o
> test.ll"
> +; CHECK: .Linfo_string0          # DW_AT_producer
> +target triple = "x86_64-unknown-linux-gnu"
> +
> +define i32 @main() !dbg !6 {
> +entry:
> +  %retval = alloca i32, align 4
> +  store i32 0, i32* %retval, align 4
> +  ret i32 0, !dbg !10
> +}
> +
> +!llvm.dbg.cu = !{!0}
> +!llvm.module.flags = !{!3, !4}
> +!llvm.ident = !{!5}
> +
> +!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)
> +!1 = !DIFile(filename: "foo.c", directory: "d")
> +!2 = !{}
> +!3 = !{i32 2, !"Dwarf Version", i32 4}
> +!4 = !{i32 2, !"Debug Info Version", i32 3}
> +!5 = !{!"clang"}
> +!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)
> +!7 = !DISubroutineType(types: !8)
> +!8 = !{!9}
> +!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
> +!10 = !DILocation(line: 5, column: 3, scope: !6)
> Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> ===================================================================
> --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> @@ -423,7 +423,14 @@
>      Asm->OutStreamer->getContext().setMCLineTableCompilationDir(
>          NewCU.getUniqueID(), CompilationDir);
>
> -  NewCU.addString(Die, dwarf::DW_AT_producer, DIUnit->getProducer());
> +  StringRef Producer = DIUnit->getProducer();
> +  StringRef Flags = DIUnit->getFlags();
> +  if (!Flags.empty()) {
> +    std::string ProducerWithFlags = Producer.str() + " " + Flags.str();
> +    NewCU.addString(Die, dwarf::DW_AT_producer, ProducerWithFlags);
> +  } else
> +    NewCU.addString(Die, dwarf::DW_AT_producer, Producer);
> +
>    NewCU.addUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
>                  DIUnit->getSourceLanguage());
>    NewCU.addString(Die, dwarf::DW_AT_name, FN);
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170324/91bdd080/attachment.html>


More information about the llvm-commits mailing list