From 0fc154af3d91cfbc7b8c109b88f0f06e8ccc4bba Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 24 Sep 2007 03:35:37 +0000 Subject: [PATCH] When emitting .set directives, make sure the EH and Debug labels can't conflict. llvm-svn: 42257 --- lib/CodeGen/DwarfWriter.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp index ed4de7d662b..e9cb69214f4 100644 --- a/lib/CodeGen/DwarfWriter.cpp +++ b/lib/CodeGen/DwarfWriter.cpp @@ -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) {}