Remove what looks like dead code in the production of debug lines.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 12 Nov 2010 18:41:26 +0000 (18:41 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 12 Nov 2010 18:41:26 +0000 (18:41 +0000)
We only produce debug line information if we have seen a line directive, so
this code is dead. Also, if we want to be bug by bug compatible with
gas and sometimes produce "empty" .debug_line sections, this will
match the content produced by gas.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118914 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCDwarf.cpp

index d481ecf89bc73df02d4b63c7987b3916d5bde6f8..c646529645bcb7ac6f5c544a69318b2b810a22f5 100644 (file)
@@ -135,7 +135,7 @@ static inline void EmitDwarfSetAddress(MCObjectStreamer *MCOS,
 // This emits the Dwarf line table for the specified section from the entries
 // in the LineSection.
 //
-static inline bool EmitDwarfLineTable(MCObjectStreamer *MCOS,
+static inline void EmitDwarfLineTable(MCObjectStreamer *MCOS,
                                       const MCSection *Section,
                                       MCLineSection *LineSection,
                                       const MCSection *DwarfLineSection) {
@@ -144,7 +144,6 @@ static inline bool EmitDwarfLineTable(MCObjectStreamer *MCOS,
   unsigned Column = 0;
   unsigned Flags = DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0;
   unsigned Isa = 0;
-  bool EmittedLineTable = false;
   MCSymbol *LastLabel = NULL;
   MCSectionData &DLS =
     MCOS->getAssembler().getOrCreateSectionData(*DwarfLineSection);
@@ -202,7 +201,6 @@ static inline bool EmitDwarfLineTable(MCObjectStreamer *MCOS,
 
     LastLine = it->getLine();
     LastLabel = Label;
-    EmittedLineTable = true;
   }
 
   // Emit a DW_LNE_end_sequence for the end of the section.
@@ -226,8 +224,6 @@ static inline bool EmitDwarfLineTable(MCObjectStreamer *MCOS,
                                                  0);
   // Create a Dwarf Line fragment for the LineDelta and AddrDelta.
   new MCDwarfLineAddrFragment(INT64_MAX, *AddrDelta, &DLS);
-
-  return EmittedLineTable;
 }
 
 //
@@ -315,56 +311,17 @@ void MCDwarfFileTable::Emit(MCObjectStreamer *MCOS,
   MCOS->EmitLabel(ProEndSym);
 
   // Put out the line tables.
-  bool EmittedLineTable = false;
   DenseMap<const MCSection *, MCLineSection *> &MCLineSections =
     MCOS->getContext().getMCLineSections();
   for (DenseMap<const MCSection *, MCLineSection *>::iterator it =
        MCLineSections.begin(), ie = MCLineSections.end(); it != ie; ++it) {
-    EmittedLineTable = EmitDwarfLineTable(MCOS, it->first, it->second,
-                                          DwarfLineSection);
+    EmitDwarfLineTable(MCOS, it->first, it->second, DwarfLineSection);
 
     // Now delete the MCLineSections that were created in MCLineEntry::Make()
     // and used to emit the line table.
     delete it->second;
   }
 
-  // If there are no line tables emited then we emit:
-  // The following DW_LNE_set_address sequence to set the address to zero and
-  // the DW_LNE_end_sequence.
-  if (EmittedLineTable == false) {
-    if (MCOS->getAssembler().getBackend().getPointerSize() == 8) {
-      // This is the DW_LNE_set_address sequence for 64-bit code.
-      MCOS->EmitIntValue(0, 1);
-      MCOS->EmitIntValue(9, 1);
-      MCOS->EmitIntValue(2, 1);
-      MCOS->EmitIntValue(0, 1);
-      MCOS->EmitIntValue(0, 1);
-      MCOS->EmitIntValue(0, 1);
-      MCOS->EmitIntValue(0, 1);
-      MCOS->EmitIntValue(0, 1);
-      MCOS->EmitIntValue(0, 1);
-      MCOS->EmitIntValue(0, 1);
-      MCOS->EmitIntValue(0, 1);
-    }
-    else {
-      // This is the DW_LNE_set_address sequence for 32-bit code.
-      MCOS->EmitIntValue(0, 1);
-      MCOS->EmitIntValue(5, 1);
-      MCOS->EmitIntValue(2, 1);
-      MCOS->EmitIntValue(0, 1);
-      MCOS->EmitIntValue(0, 1);
-      MCOS->EmitIntValue(0, 1);
-      MCOS->EmitIntValue(0, 1);
-    }
-
-    // Lastly emit the DW_LNE_end_sequence which consists of 3 bytes '00 01 01'
-    // (00 is the code for extended opcodes, followed by a ULEB128 length of the
-    // extended opcode (01), and the DW_LNE_end_sequence (01).
-    MCOS->EmitIntValue(0, 1); // DW_LNS_extended_op
-    MCOS->EmitIntValue(1, 1); // ULEB128 length of the extended opcode
-    MCOS->EmitIntValue(1, 1); // DW_LNE_end_sequence
-  }
-
   // 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);