[llvm-commits] [llvm] r42257 - /llvm/trunk/lib/CodeGen/DwarfWriter.cpp

Chris Lattner sabre at nondot.org
Sun Sep 23 20:35:38 PDT 2007


Author: lattner
Date: Sun Sep 23 22:35:37 2007
New Revision: 42257

URL: http://llvm.org/viewvc/llvm-project?rev=42257&view=rev
Log:
When emitting .set directives, make sure the EH and Debug labels can't conflict.

Modified:
    llvm/trunk/lib/CodeGen/DwarfWriter.cpp

Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfWriter.cpp?rev=42257&r1=42256&r2=42257&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/DwarfWriter.cpp Sun Sep 23 22:35:37 2007
@@ -798,9 +798,14 @@
   /// SubprogramCount - The running count of functions being compiled.
   ///
   unsigned SubprogramCount;
+  
+  /// Flavor - A unique string indicating what dwarf producer this is, used to
+  /// unique labels.
+  const char * const Flavor;
 
   unsigned SetCounter;
-  Dwarf(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
+  Dwarf(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T,
+        const char *flavor)
   : O(OS)
   , Asm(A)
   , TAI(T)
@@ -810,6 +815,7 @@
   , MF(NULL)
   , MMI(NULL)
   , SubprogramCount(0)
+  , Flavor(flavor)
   , SetCounter(1)
   {
   }
@@ -839,11 +845,17 @@
     PrintLabelName(Label.Tag, Label.Number);
   }
   void PrintLabelName(const char *Tag, unsigned Number) const {
-    
     O << TAI->getPrivateGlobalPrefix() << Tag;
     if (Number) O << Number;
   }
   
+  void PrintLabelName(const char *Tag, unsigned Number,
+                      const char *Suffix) const {
+    O << TAI->getPrivateGlobalPrefix() << Tag;
+    if (Number) O << Number;
+    O << Suffix;
+  }
+  
   /// EmitLabel - Emit location label for internal use by Dwarf.
   ///
   void EmitLabel(DWLabel Label) const {
@@ -888,7 +900,7 @@
                       bool IsSmall = false) {
     if (TAI->needsSet()) {
       O << "\t.set\t";
-      PrintLabelName("set", SetCounter);
+      PrintLabelName("set", SetCounter, Flavor);
       O << ",";
       PrintLabelName(TagHi, NumberHi);
       O << "-";
@@ -896,9 +908,7 @@
       O << "\n";
 
       PrintRelDirective(IsSmall);
-        
-      PrintLabelName("set", SetCounter);
-      
+      PrintLabelName("set", SetCounter, Flavor);
       ++SetCounter;
     } else {
       PrintRelDirective(IsSmall);
@@ -915,7 +925,7 @@
     bool printAbsolute = false;
     if (TAI->needsSet()) {
       O << "\t.set\t";
-      PrintLabelName("set", SetCounter);
+      PrintLabelName("set", SetCounter, Flavor);
       O << ",";
       PrintLabelName(Label, LabelNumber);
 
@@ -932,7 +942,7 @@
 
       PrintRelDirective(IsSmall);
         
-      PrintLabelName("set", SetCounter);
+      PrintLabelName("set", SetCounter, Flavor);
       ++SetCounter;
     } else {
       PrintRelDirective(IsSmall, true);
@@ -2565,7 +2575,7 @@
   // Main entry points.
   //
   DwarfDebug(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
-  : Dwarf(OS, A, T)
+  : Dwarf(OS, A, T, "dbg")
   , CompileUnits()
   , AbbreviationsSet(InitAbbreviationsSetSize)
   , Abbreviations()
@@ -3268,7 +3278,7 @@
   // Main entry points.
   //
   DwarfException(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
-  : Dwarf(OS, A, T)
+  : Dwarf(OS, A, T, "eh")
   , shouldEmit(false)
   {}
   





More information about the llvm-commits mailing list