It may not be an option to skip .debug_line if there are file reference in already...
authorDevang Patel <dpatel@apple.com>
Fri, 3 Dec 2010 00:10:48 +0000 (00:10 +0000)
committerDevang Patel <dpatel@apple.com>
Fri, 3 Dec 2010 00:10:48 +0000 (00:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120760 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCContext.h
include/llvm/MC/MCDwarf.h
lib/MC/MCAsmStreamer.cpp
lib/MC/MCDwarf.cpp

index 575bc3b29719ac7e3d992f3614d3c152658c04a4..7968e1e27d9ef3eb0dca79bde773fd4c5ed8093a 100644 (file)
@@ -180,9 +180,6 @@ namespace llvm {
     bool hasDwarfFiles() const {
       return !MCDwarfFiles.empty();
     }
-    bool hasDwarfLines() const {
-      return !MCLineSectionOrder.empty();
-    }
 
     const std::vector<MCDwarfFile *> &getMCDwarfFiles() {
       return MCDwarfFiles;
index 52371f697923726dcfe9fa5dde0f30208274df2d..0c0a22eb8abf36b3fdfaabbf6de8c700fdc2c614 100644 (file)
@@ -209,7 +209,8 @@ namespace llvm {
     // 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 {
index 30a3105bd798af0422fac636347312f41dd15350..49bcc936f7ab682c8b4e3b211607156d4c136bd9 100644 (file)
@@ -885,9 +885,9 @@ void MCAsmStreamer::EmitRawText(StringRef String) {
 
 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());
   }
 }
 
index 0daf2959e33cfbc71ddff3faf8eb742310af4761..5fe73e2810abdefb04e8c82a39c5b2972fec5bd9 100644 (file)
@@ -241,7 +241,8 @@ static inline void EmitDwarfLineTable(MCStreamer *MCOS,
 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 @@ void MCDwarfFileTable::Emit(MCStreamer *MCOS,
     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);