diff options
author | Bill Wendling <isanbard@gmail.com> | 2009-03-09 05:04:40 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2009-03-09 05:04:40 +0000 |
commit | ccbdc7ab82792ac5d7863ef086f11fb010d88073 (patch) | |
tree | 8fd761b3482c8df9272eac68f507776b394f2d32 /lib/CodeGen | |
parent | bce6091d95b7fd56d7c6760b0de54fb6c4300539 (diff) |
Pass in a std::string when getting the names of debugging things. This cuts down
on the number of times a std::string is created and copied.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66396 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfWriter.cpp | 57 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/FastISel.cpp | 10 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 5 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp | 20 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp | 3 |
5 files changed, 60 insertions, 35 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp index 9181216b5a..c5b24eff45 100644 --- a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp @@ -1622,7 +1622,8 @@ private: DIBasicType BTy) { // Get core information. - const std::string &Name = BTy.getName(); + std::string Name; + BTy.getName(Name); Buffer.setTag(DW_TAG_base_type); AddUInt(&Buffer, DW_AT_encoding, DW_FORM_data1, BTy.getEncoding()); // Add name if not anonymous or intermediate type. @@ -1637,13 +1638,16 @@ private: DIDerivedType DTy) { // Get core information. - const std::string &Name = DTy.getName(); + std::string Name; + DTy.getName(Name); uint64_t Size = DTy.getSizeInBits() >> 3; unsigned Tag = DTy.getTag(); + // FIXME - Workaround for templates. if (Tag == DW_TAG_inheritance) Tag = DW_TAG_reference_type; Buffer.setTag(Tag); + // Map to main type, void will not have a type. DIType FromTy = DTy.getTypeDerivedFrom(); AddType(DW_Unit, &Buffer, FromTy); @@ -1665,12 +1669,14 @@ private: /// ConstructTypeDIE - Construct type DIE from DICompositeType. void ConstructTypeDIE(CompileUnit *DW_Unit, DIE &Buffer, DICompositeType CTy) { - // Get core information. - const std::string &Name = CTy.getName(); + std::string Name; + CTy.getName(Name); + uint64_t Size = CTy.getSizeInBits() >> 3; unsigned Tag = CTy.getTag(); Buffer.setTag(Tag); + switch (Tag) { case DW_TAG_vector_type: case DW_TAG_array_type: @@ -1806,7 +1812,8 @@ private: DIE *ConstructEnumTypeDIE(CompileUnit *DW_Unit, DIEnumerator *ETy) { DIE *Enumerator = new DIE(DW_TAG_enumerator); - const std::string &Name = ETy->getName(); + std::string Name; + ETy->getName(Name); AddString(Enumerator, DW_AT_name, DW_FORM_string, Name); int64_t Value = ETy->getEnumValue(); AddSInt(Enumerator, DW_AT_const_value, DW_FORM_sdata, Value); @@ -1817,9 +1824,11 @@ private: DIE *CreateGlobalVariableDIE(CompileUnit *DW_Unit, const DIGlobalVariable &GV) { DIE *GVDie = new DIE(DW_TAG_variable); - const std::string &Name = GV.getDisplayName(); + std::string Name; + GV.getDisplayName(Name); AddString(GVDie, DW_AT_name, DW_FORM_string, Name); - const std::string &LinkageName = GV.getLinkageName(); + std::string LinkageName; + GV.getLinkageName(LinkageName); if (!LinkageName.empty()) AddString(GVDie, DW_AT_MIPS_linkage_name, DW_FORM_string, LinkageName); AddType(DW_Unit, GVDie, GV.getType()); @@ -1832,7 +1841,8 @@ private: /// CreateMemberDIE - Create new member DIE. DIE *CreateMemberDIE(CompileUnit *DW_Unit, const DIDerivedType &DT) { DIE *MemberDie = new DIE(DT.getTag()); - const std::string &Name = DT.getName(); + std::string Name; + DT.getName(Name); if (!Name.empty()) AddString(MemberDie, DW_AT_name, DW_FORM_string, Name); @@ -1876,9 +1886,11 @@ private: const DISubprogram &SP, bool IsConstructor = false) { DIE *SPDie = new DIE(DW_TAG_subprogram); - const std::string &Name = SP.getName(); + std::string Name; + SP.getName(Name); AddString(SPDie, DW_AT_name, DW_FORM_string, Name); - const std::string &LinkageName = SP.getLinkageName(); + std::string LinkageName; + SP.getLinkageName(LinkageName); if (!LinkageName.empty()) AddString(SPDie, DW_AT_MIPS_linkage_name, DW_FORM_string, LinkageName); @@ -1945,7 +1957,8 @@ private: // Define variable debug information entry. DIE *VariableDie = new DIE(Tag); - const std::string &Name = VD.getName(); + std::string Name; + VD.getName(Name); AddString(VariableDie, DW_AT_name, DW_FORM_string, Name); // Add source line info if available. @@ -2769,21 +2782,23 @@ private: void ConstructCompileUnit(GlobalVariable *GV) { DICompileUnit DIUnit(GV); - unsigned ID = getOrCreateSourceID(DIUnit.getDirectory(), - DIUnit.getFilename()); + std::string Dir, FN, Prod; + unsigned ID = getOrCreateSourceID(DIUnit.getDirectory(Dir), + DIUnit.getFilename(FN)); DIE *Die = new DIE(DW_TAG_compile_unit); AddSectionOffset(Die, DW_AT_stmt_list, DW_FORM_data4, DWLabel("section_line", 0), DWLabel("section_line", 0), false); - AddString(Die, DW_AT_producer, DW_FORM_string, DIUnit.getProducer()); + AddString(Die, DW_AT_producer, DW_FORM_string, DIUnit.getProducer(Prod)); AddUInt(Die, DW_AT_language, DW_FORM_data1, DIUnit.getLanguage()); - AddString(Die, DW_AT_name, DW_FORM_string, DIUnit.getFilename()); - if (!DIUnit.getDirectory().empty()) - AddString(Die, DW_AT_comp_dir, DW_FORM_string, DIUnit.getDirectory()); + AddString(Die, DW_AT_name, DW_FORM_string, FN); + if (!Dir.empty()) + AddString(Die, DW_AT_comp_dir, DW_FORM_string, Dir); if (DIUnit.isOptimized()) AddUInt(Die, DW_AT_APPLE_optimized, DW_FORM_flag, 1); - const std::string &Flags = DIUnit.getFlags(); + std::string Flags; + DIUnit.getFlags(Flags); if (!Flags.empty()) AddString(Die, DW_AT_APPLE_flags, DW_FORM_string, Flags); unsigned RVer = DIUnit.getRunTimeVersion(); @@ -2843,7 +2858,8 @@ private: // Add to context owner. DW_Unit->getDie()->AddChild(VariableDie); // Expose as global. FIXME - need to check external flag. - DW_Unit->AddGlobal(DI_GV.getName(), VariableDie); + std::string Name; + DW_Unit->AddGlobal(DI_GV.getName(Name), VariableDie); return true; } @@ -2895,7 +2911,8 @@ private: // Add to context owner. Unit->getDie()->AddChild(SubprogramDie); // Expose as global. - Unit->AddGlobal(SP.getName(), SubprogramDie); + std::string Name; + Unit->AddGlobal(SP.getName(Name), SubprogramDie); return true; } diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index a0ed4755f9..229376d293 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -319,8 +319,9 @@ bool FastISel::SelectCall(User *I) { DbgStopPointInst *SPI = cast<DbgStopPointInst>(I); if (DW && DW->ValidDebugInfo(SPI->getContext())) { DICompileUnit CU(cast<GlobalVariable>(SPI->getContext())); - unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(), - CU.getFilename()); + std::string Dir, FN; + unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(Dir), + CU.getFilename(FN)); unsigned Line = SPI->getLine(); unsigned Col = SPI->getColumn(); unsigned ID = DW->RecordSourceLine(Line, Col, SrcFile); @@ -361,8 +362,9 @@ bool FastISel::SelectCall(User *I) { // (most?) gdb expects. DISubprogram Subprogram(cast<GlobalVariable>(SP)); DICompileUnit CompileUnit = Subprogram.getCompileUnit(); - unsigned SrcFile = DW->getOrCreateSourceID(CompileUnit.getDirectory(), - CompileUnit.getFilename()); + std::string Dir, FN; + unsigned SrcFile = DW->getOrCreateSourceID(CompileUnit.getDirectory(Dir), + CompileUnit.getFilename(FN)); // Record the source line but does not create a label for the normal // function start. It will be emitted at asm emission time. However, diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index 0854aad9b6..8c074e75eb 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -1287,8 +1287,9 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) { GlobalVariable *CU_GV = cast<GlobalVariable>(DSP->getCompileUnit()); if (DW && (useDEBUG_LOC || useLABEL) && !CU_GV->isDeclaration()) { DICompileUnit CU(cast<GlobalVariable>(DSP->getCompileUnit())); - unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(), - CU.getFilename()); + std::string Dir, FN; + unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(Dir), + CU.getFilename(FN)); unsigned Line = DSP->getLine(); unsigned Col = DSP->getColumn(); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp index b3a06ea9d7..0dbc35b224 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp @@ -335,8 +335,9 @@ void FunctionLoweringInfo::set(Function &fn, MachineFunction &mf, if (DW && DW->ValidDebugInfo(SPI->getContext())) { DICompileUnit CU(cast<GlobalVariable>(SPI->getContext())); - unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(), - CU.getFilename()); + std::string Dir, FN; + unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(Dir), + CU.getFilename(FN)); unsigned idx = MF->getOrCreateDebugLocID(SrcFile, SPI->getLine(), SPI->getColumn()); @@ -354,8 +355,9 @@ void FunctionLoweringInfo::set(Function &fn, MachineFunction &mf, if (DW->ValidDebugInfo(SP)) { DISubprogram Subprogram(cast<GlobalVariable>(SP)); DICompileUnit CU(Subprogram.getCompileUnit()); - unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(), - CU.getFilename()); + std::string Dir, FN; + unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(Dir), + CU.getFilename(FN)); unsigned Line = Subprogram.getLineNumber(); DL = DebugLoc::get(MF->getOrCreateDebugLocID(SrcFile, Line, 0)); } @@ -3902,8 +3904,9 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) { SPI.getColumn(), SPI.getContext())); DICompileUnit CU(cast<GlobalVariable>(SPI.getContext())); - unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(), - CU.getFilename()); + std::string Dir, FN; + unsigned SrcFile = DW->getOrCreateSourceID(CU.getDirectory(Dir), + CU.getFilename(FN)); unsigned idx = MF.getOrCreateDebugLocID(SrcFile, SPI.getLine(), SPI.getColumn()); setCurDebugLoc(DebugLoc::get(idx)); @@ -3947,8 +3950,9 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) { MachineFunction &MF = DAG.getMachineFunction(); DISubprogram Subprogram(cast<GlobalVariable>(SP)); DICompileUnit CompileUnit = Subprogram.getCompileUnit(); - unsigned SrcFile = DW->getOrCreateSourceID(CompileUnit.getDirectory(), - CompileUnit.getFilename()); + std::string Dir, FN; + unsigned SrcFile = DW->getOrCreateSourceID(CompileUnit.getDirectory(Dir), + CompileUnit.getFilename(FN)); // Record the source line but does not create a label for the normal // function start. It will be emitted at asm emission time. However, diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp index 004cb247b1..0392338762 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp @@ -179,7 +179,8 @@ std::string DOTGraphTraits<SelectionDAG*>::getNodeLabel(const SDNode *Node, } } else if (const DbgStopPointSDNode *D = dyn_cast<DbgStopPointSDNode>(Node)) { DICompileUnit CU(cast<GlobalVariable>(D->getCompileUnit())); - Op += ": " + CU.getFilename(); + std::string FN; + Op += ": " + CU.getFilename(FN); Op += ":" + utostr(D->getLine()); if (D->getColumn() != 0) Op += ":" + utostr(D->getColumn()); |