[llvm-commits] [llvm] r172630 - in /llvm/trunk: include/llvm/MC/MCContext.h lib/MC/MCDwarf.cpp test/MC/MachO/gen-dwarf-producer.s tools/llvm-mc/llvm-mc.cpp

Kevin Enderby enderby at apple.com
Wed Jan 16 10:39:08 PST 2013


Comments in line below.

On Jan 16, 2013, at 10:34 AM, David Blaikie <dblaikie at gmail.com> wrote:

> On Wed, Jan 16, 2013 at 9:46 AM, Kevin Enderby <enderby at apple.com> wrote:
>> Author: enderby
>> Date: Wed Jan 16 11:46:23 2013
>> New Revision: 172630
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=172630&view=rev
>> Log:
>> We want the dwarf AT_producer for assembly source files to match clang's
>> AT_producer.  Which includes clang's version information so we can tell
>> which version of the compiler was used.
>> 
>> This is the first of two steps to allow us to do that.  This is the llvm-mc
>> change to provide a method to set the AT_producer string.  The second step,
>> coming soon to a clang near you, will have the clang driver pass the value
>> of getClangFullVersion() via an flag when invoking the integrated assembler
>> on assembly source files.
>> 
>> rdar://12955296
>> 
>> Added:
>>    llvm/trunk/test/MC/MachO/gen-dwarf-producer.s
>> Modified:
>>    llvm/trunk/include/llvm/MC/MCContext.h
>>    llvm/trunk/lib/MC/MCDwarf.cpp
>>    llvm/trunk/tools/llvm-mc/llvm-mc.cpp
>> 
>> Modified: llvm/trunk/include/llvm/MC/MCContext.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=172630&r1=172629&r2=172630&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/MC/MCContext.h (original)
>> +++ llvm/trunk/include/llvm/MC/MCContext.h Wed Jan 16 11:46:23 2013
>> @@ -129,6 +129,10 @@
>>     /// non-empty.
>>     StringRef DwarfDebugFlags;
>> 
>> +    /// The string to embed in as the dwarf AT_producer for the compile unit, if
>> +    /// non-empty.
>> +    StringRef DwarfDebugProducer;
>> +
>>     /// Honor temporary labels, this is useful for debugging semantic
>>     /// differences between temporary and non-temporary labels (primarily on
>>     /// Darwin).
>> @@ -346,6 +350,9 @@
>>     void setDwarfDebugFlags(StringRef S) { DwarfDebugFlags = S; }
>>     StringRef getDwarfDebugFlags() { return DwarfDebugFlags; }
>> 
>> +    void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
>> +    StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
>> +
>>     /// @}
>> 
>>     char *getSecureLogFile() { return SecureLogFile; }
>> 
>> Modified: llvm/trunk/lib/MC/MCDwarf.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=172630&r1=172629&r2=172630&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/MC/MCDwarf.cpp (original)
>> +++ llvm/trunk/lib/MC/MCDwarf.cpp Wed Jan 16 11:46:23 2013
>> @@ -638,9 +638,15 @@
>>   }
>> 
>>   // AT_producer, the version of the assembler tool.
>> -  MCOS->EmitBytes(StringRef("llvm-mc (based on LLVM "));
>> -  MCOS->EmitBytes(StringRef(PACKAGE_VERSION));
>> -  MCOS->EmitBytes(StringRef(")"));
>> +  StringRef DwarfDebugProducer = context.getDwarfDebugProducer();
>> +  if (!DwarfDebugProducer.empty()){
>> +    MCOS->EmitBytes(DwarfDebugProducer);
>> +  }
>> +  else {
>> +    MCOS->EmitBytes(StringRef("llvm-mc (based on LLVM "));
>> +    MCOS->EmitBytes(StringRef(PACKAGE_VERSION));
>> +    MCOS->EmitBytes(StringRef(")"));
>> +  }
>>   MCOS->EmitIntValue(0, 1); // NULL byte to terminate the string.
>> 
>>   // AT_language, a 4 byte value.  We use DW_LANG_Mips_Assembler as the dwarf2
>> 
>> Added: llvm/trunk/test/MC/MachO/gen-dwarf-producer.s
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/gen-dwarf-producer.s?rev=172630&view=auto
>> ==============================================================================
>> --- llvm/trunk/test/MC/MachO/gen-dwarf-producer.s (added)
>> +++ llvm/trunk/test/MC/MachO/gen-dwarf-producer.s Wed Jan 16 11:46:23 2013
>> @@ -0,0 +1,8 @@
>> +// RUN: env DEBUG_PRODUCER="my producer" llvm-mc -g -triple i386-apple-darwin10 %s -filetype=obj -o %t
>> +// RUN: llvm-dwarfdump %t | FileCheck %s
>> +
>> +.globl _bar
>> +_bar:
>> +       ret
>> +
>> +// CHECK:    DW_AT_producer [DW_FORM_string]   ("my producer")
>> 
>> Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=172630&r1=172629&r2=172630&view=diff
>> ==============================================================================
>> --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
>> +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Wed Jan 16 11:46:23 2013
>> @@ -236,6 +236,13 @@
>>   }
>> }
>> 
>> +static std::string DwarfDebugProducer;
>> +static void setDwarfDebugProducer(void) {
>> +  if(!getenv("DEBUG_PRODUCER"))
>> +    return;
>> +  DwarfDebugProducer += getenv("DEBUG_PRODUCER");
>> +}
>> +
>> static int AsLexInput(SourceMgr &SrcMgr, MCAsmInfo &MAI, tool_output_file *Out) {
>> 
>>   AsmLexer Lexer(MAI);
>> @@ -353,6 +360,8 @@
>>   TripleName = Triple::normalize(TripleName);
>>   setDwarfDebugFlags(argc, argv);
>> 
>> +  setDwarfDebugProducer();
>> +
>>   const char *ProgName = argv[0];
>>   const Target *TheTarget = GetTarget(ProgName);
>>   if (!TheTarget)
>> @@ -393,6 +402,8 @@
>>   Ctx.setGenDwarfForAssembly(GenDwarfForAssembly);
>>   if (!DwarfDebugFlags.empty())
>>     Ctx.setDwarfDebugFlags(StringRef(DwarfDebugFlags));
>> +  if (!DwarfDebugProducer.empty())
>> +    Ctx.setDwarfDebugProducer(StringRef(DwarfDebugProducer));
> 
> You shouldn't need this explicit StringRef() here, should you? (maybe
> cargo-culted in from the above which also doesn't need it, if I'm not
> mistaken)

I think you are correct.  And yes I got that from the line above.

> 
>>   if (!DebugCompilationDir.empty())
>>     Ctx.setCompilationDir(DebugCompilationDir);
>>   if (!MainFileName.empty())
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list