Pass in the std::string parameter instead of returning it by value.
authorBill Wendling <isanbard@gmail.com>
Fri, 10 Apr 2009 00:12:49 +0000 (00:12 +0000)
committerBill Wendling <isanbard@gmail.com>
Fri, 10 Apr 2009 00:12:49 +0000 (00:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68747 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/AsmPrinter.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/DwarfWriter.cpp
lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp

index 66d254e2541f84e77c1be6d5d4182184d391ab1c..c1d86a219067b56e7435234c078798dd8636339a 100644 (file)
@@ -153,7 +153,8 @@ namespace llvm {
     /// getGlobalLinkName - Returns the asm/link name of of the specified
     /// global variable.  Should be overridden by each target asm printer to
     /// generate the appropriate value.
-    virtual const std::string getGlobalLinkName(const GlobalVariable *GV) const;
+    virtual const std::string &getGlobalLinkName(const GlobalVariable *GV,
+                                                 std::string &LinkName) const;
 
     /// EmitExternalGlobal - Emit the external reference to a global variable.
     /// Should be overridden if an indirect reference should be used.
@@ -162,7 +163,8 @@ namespace llvm {
     /// getCurrentFunctionEHName - Called to return (and cache) the
     /// CurrentFnEHName.
     /// 
-    std::string getCurrentFunctionEHName(const MachineFunction *MF) const;
+    const std::string &getCurrentFunctionEHName(const MachineFunction *MF,
+                                                std::string &FuncEHName) const;
 
   protected:
     /// getAnalysisUsage - Record analysis usage.
index c9fd1ac60acbc060224e64c50181428944e962ff..d19e9afaf028235504d3e1781f178662a8c4db0c 100644 (file)
@@ -186,11 +186,8 @@ bool AsmPrinter::doFinalization(Module &M) {
       SwitchToDataSection("");
 
     for (std::set<const GlobalValue*>::iterator i = ExtWeakSymbols.begin(),
-         e = ExtWeakSymbols.end(); i != e; ++i) {
-      const GlobalValue *GV = *i;
-      std::string Name = Mang->getValueName(GV);
-      O << TAI->getWeakRefDirective() << Name << '\n';
-    }
+         e = ExtWeakSymbols.end(); i != e; ++i)
+      O << TAI->getWeakRefDirective() << Mang->getValueName(*i) << '\n';
   }
 
   if (TAI->getSetDirective()) {
@@ -236,14 +233,16 @@ bool AsmPrinter::doFinalization(Module &M) {
   return false;
 }
 
-std::string
-AsmPrinter::getCurrentFunctionEHName(const MachineFunction *MF) const {
+const std::string &
+AsmPrinter::getCurrentFunctionEHName(const MachineFunction *MF,
+                                     std::string &Name) const {
   assert(MF && "No machine function?");
-  std::string Name = MF->getFunction()->getName();
+  Name = MF->getFunction()->getName();
   if (Name.empty())
     Name = Mang->getValueName(MF->getFunction());
-  return Mang->makeNameProper(TAI->getEHGlobalPrefix() +
+  Name = Mang->makeNameProper(TAI->getEHGlobalPrefix() +
                               Name + ".eh", TAI->getGlobalPrefix());
+  return Name;
 }
 
 void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
@@ -536,9 +535,8 @@ void AsmPrinter::EmitXXStructorList(Constant *List) {
 /// getGlobalLinkName - Returns the asm/link name of of the specified
 /// global variable.  Should be overridden by each target asm printer to
 /// generate the appropriate value.
-const std::string AsmPrinter::getGlobalLinkName(const GlobalVariable *GV) const{
-  std::string LinkName;
-  
+const std::string &AsmPrinter::getGlobalLinkName(const GlobalVariable *GV,
+                                                 std::string &LinkName) const {
   if (isa<Function>(GV)) {
     LinkName += TAI->getFunctionAddrPrefix();
     LinkName += Mang->getValueName(GV);
@@ -555,7 +553,8 @@ const std::string AsmPrinter::getGlobalLinkName(const GlobalVariable *GV) const{
 /// EmitExternalGlobal - Emit the external reference to a global variable.
 /// Should be overridden if an indirect reference should be used.
 void AsmPrinter::EmitExternalGlobal(const GlobalVariable *GV) {
-  O << getGlobalLinkName(GV);
+  std::string GLN;
+  O << getGlobalLinkName(GV, GLN);
 }
 
 
index 508d4022dbaa80dc380b0f5c264cec93f352016b..d59609b371ef67ea1ad4ef4a4d1d86a8479a12b2 100644 (file)
@@ -2888,8 +2888,9 @@ private:
     // Add address.
     DIEBlock *Block = new DIEBlock();
     AddUInt(Block, 0, DW_FORM_data1, DW_OP_addr);
+    std::string GLN;
     AddObjectLabel(Block, 0, DW_FORM_udata,
-                   Asm->getGlobalLinkName(DI_GV.getGlobal()));
+                   Asm->getGlobalLinkName(DI_GV.getGlobal(), GLN));
     AddBlock(VariableDie, DW_AT_location, 0, Block);
 
     // Add to map.
@@ -4009,10 +4010,12 @@ class DwarfException : public Dwarf  {
 
       PrintRelDirective();
 
-      if (GV)
-        O << Asm->getGlobalLinkName(GV);
-      else
+      if (GV) {
+        std::string GLN;
+        O << Asm->getGlobalLinkName(GV, GLN);
+      } else {
         O << "0";
+      }
 
       Asm->EOL("TypeInfo");
     }
@@ -4120,14 +4123,15 @@ public:
       EmitExceptionTable();
 
       // Save EH frame information
-      EHFrames.
-        push_back(FunctionEHFrameInfo(getAsm()->getCurrentFunctionEHName(MF),
-                                      SubprogramCount,
-                                      MMI->getPersonalityIndex(),
-                                      MF->getFrameInfo()->hasCalls(),
-                                      !MMI->getLandingPads().empty(),
-                                      MMI->getFrameMoves(),
-                                      MF->getFunction()));
+      std::string Name;
+      EHFrames.push_back(
+        FunctionEHFrameInfo(getAsm()->getCurrentFunctionEHName(MF, Name),
+                            SubprogramCount,
+                            MMI->getPersonalityIndex(),
+                            MF->getFrameInfo()->hasCalls(),
+                            !MMI->getLandingPads().empty(),
+                            MMI->getFrameMoves(),
+                            MF->getFunction()));
     }
 
     if (TimePassesIsEnabled) 
index 827c4f92b56dacc9ff977f473be29a3c9e4ec8eb..5b68062ab1048d04115231934745849205b91e12 100644 (file)
@@ -423,7 +423,8 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
 /// EmitExternalGlobal - In this case we need to use the indirect symbol.
 ///
 void PPCAsmPrinter::EmitExternalGlobal(const GlobalVariable *GV) {
-  std::string Name = getGlobalLinkName(GV);
+  std::string Name;
+  getGlobalLinkName(GV, Name);
   if (TM.getRelocationModel() != Reloc::Static) {
     if (GV->hasHiddenVisibility())
       HiddenGVStubs.insert(Name);