When emitting .set directives, make sure the EH and Debug labels can't conflict.
authorChris Lattner <sabre@nondot.org>
Mon, 24 Sep 2007 03:35:37 +0000 (03:35 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 24 Sep 2007 03:35:37 +0000 (03:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42257 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/DwarfWriter.cpp

index ed4de7d662b0c81121d3f9e2ab02406fab9ddf37..e9cb69214f41dc30bb701bc7fdb9b6b9a6c063e1 100644 (file)
@@ -798,9 +798,14 @@ protected:
   /// 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 @@ protected:
   , MF(NULL)
   , MMI(NULL)
   , SubprogramCount(0)
+  , Flavor(flavor)
   , SetCounter(1)
   {
   }
@@ -839,11 +845,17 @@ public:
     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 @@ public:
                       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 @@ public:
       O << "\n";
 
       PrintRelDirective(IsSmall);
-        
-      PrintLabelName("set", SetCounter);
-      
+      PrintLabelName("set", SetCounter, Flavor);
       ++SetCounter;
     } else {
       PrintRelDirective(IsSmall);
@@ -915,7 +925,7 @@ public:
     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 @@ public:
 
       PrintRelDirective(IsSmall);
         
-      PrintLabelName("set", SetCounter);
+      PrintLabelName("set", SetCounter, Flavor);
       ++SetCounter;
     } else {
       PrintRelDirective(IsSmall, true);
@@ -2565,7 +2575,7 @@ public:
   // 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 @@ public:
   // Main entry points.
   //
   DwarfException(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
-  : Dwarf(OS, A, T)
+  : Dwarf(OS, A, T, "eh")
   , shouldEmit(false)
   {}