[llvm-commits] [llvm] r120760 - in /llvm/trunk: include/llvm/MC/MCContext.h include/llvm/MC/MCDwarf.h lib/MC/MCAsmStreamer.cpp lib/MC/MCDwarf.cpp

Devang Patel dpatel at apple.com
Fri Dec 3 10:24:14 PST 2010


On Dec 2, 2010, at 4:36 PM, Rafael EspĂ­ndola wrote:

>> It may not be an option to skip .debug_line if there are file reference in already emitted debug info. So, for now, emit dummy line table entry to make older linker and assemblers happy. This is not a new behavior, original AsmPrinter emitted similar line table entries.
> 
> This should only be done if the target is know to have a broken linker.

I am not sure how to get target info here. I'd appreciate if you could step in make this kosher, I am relatively new to this area of code.

Note, we are doing this exercise, because when we replaced .debug_line emission code in .s file  in DwarfDebug.cpp with MCDwarf.cpp it changed output such that it broke supported target triple tools. Moving to MCDwarf.cpp is a right decision,  however we need to backward compatible for now.

-
Devang

> 
>> Modified:
>>    llvm/trunk/include/llvm/MC/MCContext.h
>>    llvm/trunk/include/llvm/MC/MCDwarf.h
>>    llvm/trunk/lib/MC/MCAsmStreamer.cpp
>>    llvm/trunk/lib/MC/MCDwarf.cpp
>> 
>> Modified: llvm/trunk/include/llvm/MC/MCContext.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=120760&r1=120759&r2=120760&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/MC/MCContext.h (original)
>> +++ llvm/trunk/include/llvm/MC/MCContext.h Thu Dec  2 18:10:48 2010
>> @@ -180,9 +180,6 @@
>>     bool hasDwarfFiles() const {
>>       return !MCDwarfFiles.empty();
>>     }
>> -    bool hasDwarfLines() const {
>> -      return !MCLineSectionOrder.empty();
>> -    }
>> 
>>     const std::vector<MCDwarfFile *> &getMCDwarfFiles() {
>>       return MCDwarfFiles;
>> 
>> Modified: llvm/trunk/include/llvm/MC/MCDwarf.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCDwarf.h?rev=120760&r1=120759&r2=120760&view=diff
>> ==============================================================================
>> --- llvm/trunk/include/llvm/MC/MCDwarf.h (original)
>> +++ llvm/trunk/include/llvm/MC/MCDwarf.h Thu Dec  2 18:10:48 2010
>> @@ -209,7 +209,8 @@
>>     // This emits the Dwarf file and the line tables.
>>     //
>>     static void Emit(MCStreamer *MCOS, const MCSection *DwarfLineSection,
>> -                     MCSectionData *DLS, int PointerSize);
>> +                     MCSectionData *DLS, int PointerSize,
>> +                     const MCSection *TextSection = NULL);
>>   };
>> 
>>   class MCDwarfLineAddr {
>> 
>> Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=120760&r1=120759&r2=120760&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
>> +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Thu Dec  2 18:10:48 2010
>> @@ -885,9 +885,9 @@
>> 
>>  void MCAsmStreamer::Finish() {
>>   // Dump out the dwarf file & directory tables and line tables.
>> -  if (getContext().hasDwarfFiles() && getContext().hasDwarfLines() && TLOF) {
>> +  if (getContext().hasDwarfFiles() && TLOF) {
>>     MCDwarfFileTable::Emit(this, TLOF->getDwarfLineSection(), NULL,
>> -                           PointerSize);
>> +                           PointerSize, TLOF->getTextSection());
>>   }
>>  }
>> 
>> 
>> Modified: llvm/trunk/lib/MC/MCDwarf.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=120760&r1=120759&r2=120760&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/MC/MCDwarf.cpp (original)
>> +++ llvm/trunk/lib/MC/MCDwarf.cpp Thu Dec  2 18:10:48 2010
>> @@ -241,7 +241,8 @@
>>  void MCDwarfFileTable::Emit(MCStreamer *MCOS,
>>                             const MCSection *DwarfLineSection,
>>                             MCSectionData *DLS,
>> -                            int PointerSize) {
>> +                            int PointerSize,
>> +                            const MCSection *TextSection) {
>>   // Switch to the section where the table will be emitted into.
>>   MCOS->SwitchSection(DwarfLineSection);
>> 
>> @@ -339,6 +340,23 @@
>>     delete Line;
>>   }
>> 
>> +  if (TextSection && MCLineSectionOrder.begin() == MCLineSectionOrder.end()) {
>> +    // Emit dummy entry if line table is empty.
>> +
>> +    MCOS->SwitchSection(TextSection);
>> +    MCSymbol *SectionEnd = MCOS->getContext().CreateTempSymbol();
>> +    // Set the value of the symbol, as we are at the end of the section.
>> +    MCOS->EmitLabel(SectionEnd);
>> +
>> +    // Switch back the the dwarf line section.
>> +    MCOS->SwitchSection(DwarfLineSection);
>> +
>> +    // emit the sequence to set the address
>> +    EmitDwarfSetAddress(MCOS, SectionEnd, PointerSize);
>> +    // emit the sequence for the LineDelta (from 1) and a zero address delta.
>> +    MCDwarfLineAddr::Emit(MCOS, INT64_MAX, 0);
>> +  }
>> +
>>   // This is the end of the section, so set the value of the symbol at the end
>>   // of this section (that was used in a previous expression).
>>   MCOS->EmitLabel(LineEndSym);
>> 
>> 
>> _______________________________________________
>> 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