From bfa79b8be9ad759a6c7c2499787eb6b069629618 Mon Sep 17 00:00:00 2001 From: Sanjiv Gupta Date: Sat, 15 Aug 2009 14:36:48 +0000 Subject: [PATCH] Revert a few changes that were done in 78603. PIC16DebugInfo currently rely on NameStr of composite type descriptors to uniquely identify debug info for two aggregate type decls with same name. This implementation will change when we have MDNodes based debug info implemenatation in place git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79097 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/PIC16/PIC16DebugInfo.cpp | 27 ++++++++++++++------------- lib/Target/PIC16/PIC16DebugInfo.h | 2 +- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/Target/PIC16/PIC16DebugInfo.cpp b/lib/Target/PIC16/PIC16DebugInfo.cpp index 52a13ba8f06..460be589927 100644 --- a/lib/Target/PIC16/PIC16DebugInfo.cpp +++ b/lib/Target/PIC16/PIC16DebugInfo.cpp @@ -119,7 +119,9 @@ void PIC16DbgInfo::PopulateStructOrUnionTypeInfo (DIType Ty, // UniqueSuffix is .number where number is obtained from // llvm.dbg.composite. // FIXME: This will break when composite type is not represented by - // llvm.dbg.composite* global variable. This is not supported. + // llvm.dbg.composite* global variable. Since we need to revisit + // PIC16DebugInfo implementation anyways after the MDNodes based + // framework is done, let us continue with the way it is. std::string UniqueSuffix = "." + Ty.getGV()->getNameStr().substr(18); TagName += UniqueSuffix; unsigned short size = CTy.getSizeInBits()/8; @@ -293,7 +295,7 @@ void PIC16DbgInfo::EndModule(Module &M) { /// composite type. /// void PIC16DbgInfo::EmitCompositeTypeElements (DICompositeType CTy, - unsigned SuffixNo) { + std::string SuffixNo) { unsigned long Value = 0; DIArray Elements = CTy.getTypeArray(); for (unsigned i = 0, N = Elements.getNumElements(); i < N; i++) { @@ -308,8 +310,7 @@ void PIC16DbgInfo::EmitCompositeTypeElements (DICompositeType CTy, DITy.getName(ElementName); unsigned short ElementSize = DITy.getSizeInBits()/8; // Get mangleddd name for this structure/union element. - SmallString<128> MangMemName(ElementName.begin(), ElementName.end()); - MangMemName.append_uint_32(SuffixNo); + std::string MangMemName = ElementName + SuffixNo; PopulateDebugInfo(DITy, TypeNo, HasAux, ElementAux, TagName); short Class = 0; if( CTy.getTag() == dwarf::DW_TAG_union_type) @@ -330,9 +331,8 @@ void PIC16DbgInfo::EmitCompositeTypeElements (DICompositeType CTy, void PIC16DbgInfo::EmitCompositeTypeDecls(Module &M) { DebugInfoFinder DbgFinder; DbgFinder.processModule(M); - unsigned SuffixNo = 0; - for (DebugInfoFinder::iterator I = DbgFinder.global_variable_begin(), - E = DbgFinder.global_variable_end(); I != E; ++I) { + for (DebugInfoFinder::iterator I = DbgFinder.type_begin(), + E = DbgFinder.type_end(); I != E; ++I) { DICompositeType CTy(*I); if (CTy.isNull()) continue; @@ -340,8 +340,11 @@ void PIC16DbgInfo::EmitCompositeTypeDecls(Module &M) { CTy.getTag() == dwarf::DW_TAG_structure_type ) { std::string Name; CTy.getName(Name); - SmallString<128> MangledCTyName(Name.begin(), Name.end()); - MangledCTyName.append_uint_32(++SuffixNo); + // Get the number after llvm.dbg.composite and make UniqueSuffix from + // it. + std::string DIVar = CTy.getGV()->getNameStr(); + std::string UniqueSuffix = "." + DIVar.substr(18); + std::string MangledCTyName = Name + UniqueSuffix; unsigned short size = CTy.getSizeInBits()/8; int Aux[PIC16Dbg::AuxSize] = {0}; // 7th and 8th byte represent size of structure/union. @@ -357,12 +360,10 @@ void PIC16DbgInfo::EmitCompositeTypeDecls(Module &M) { EmitAuxEntry(MangledCTyName.c_str(), Aux, PIC16Dbg::AuxSize); // Emit members. - EmitCompositeTypeElements (CTy, SuffixNo); + EmitCompositeTypeElements (CTy, UniqueSuffix); // Emit mangled Symbol for end of structure/union. - SmallString<128> EOSSymbol(Name.begin(), Name.end()); - EOSSymbol += ".eos"; - EOSSymbol.append_uint_32(SuffixNo); + std::string EOSSymbol = ".eos" + UniqueSuffix; EmitSymbol(EOSSymbol.c_str(), PIC16Dbg::C_EOS); EmitAuxEntry(EOSSymbol.c_str(), Aux, PIC16Dbg::AuxSize, MangledCTyName.c_str()); diff --git a/lib/Target/PIC16/PIC16DebugInfo.h b/lib/Target/PIC16/PIC16DebugInfo.h index 9e6d848f04c..a46c06c1eab 100644 --- a/lib/Target/PIC16/PIC16DebugInfo.h +++ b/lib/Target/PIC16/PIC16DebugInfo.h @@ -145,7 +145,7 @@ namespace llvm { short getStorageClass(DIGlobalVariable DIGV); void EmitFunctBeginDI(const Function *F); void EmitCompositeTypeDecls(Module &M); - void EmitCompositeTypeElements (DICompositeType CTy, unsigned Suffix); + void EmitCompositeTypeElements (DICompositeType CTy, std::string Suffix); void EmitFunctEndDI(const Function *F, unsigned Line); void EmitAuxEntry(const std::string VarName, int Aux[], int num = PIC16Dbg::AuxSize, std::string TagName = "");