[llvm-commits] CVS: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp DeadArgumentElimination.cpp ExtractFunction.cpp GlobalOpt.cpp PruneEH.cpp RaiseAllocations.cpp

Chris Lattner sabre at nondot.org
Sat Feb 10 17:08:51 PST 2007



Changes in directory llvm/lib/Transforms/IPO:

ArgumentPromotion.cpp updated: 1.35 -> 1.36
DeadArgumentElimination.cpp updated: 1.38 -> 1.39
ExtractFunction.cpp updated: 1.19 -> 1.20
GlobalOpt.cpp updated: 1.95 -> 1.96
PruneEH.cpp updated: 1.29 -> 1.30
RaiseAllocations.cpp updated: 1.38 -> 1.39
---
Log message:

simplify name juggling through the use of Value::takeName.


---
Diffs of the changes:  (+23 -34)

 ArgumentPromotion.cpp       |    6 ++----
 DeadArgumentElimination.cpp |   22 ++++++++--------------
 ExtractFunction.cpp         |    5 ++---
 GlobalOpt.cpp               |   14 ++++++--------
 PruneEH.cpp                 |    6 +++---
 RaiseAllocations.cpp        |    4 ++--
 6 files changed, 23 insertions(+), 34 deletions(-)


Index: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
diff -u llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.35 llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.36
--- llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.35	Mon Feb  5 17:32:05 2007
+++ llvm/lib/Transforms/IPO/ArgumentPromotion.cpp	Sat Feb 10 19:08:35 2007
@@ -455,9 +455,7 @@
 
     if (!Call->use_empty()) {
       Call->replaceAllUsesWith(New);
-      std::string Name = Call->getName();
-      Call->setName("");
-      New->setName(Name);
+      New->takeName(Call);
     }
 
     // Finally, remove the old call from the program, reducing the use-count of
@@ -479,7 +477,7 @@
       // If this is an unmodified argument, move the name and users over to the
       // new version.
       I->replaceAllUsesWith(I2);
-      I2->setName(I->getName());
+      I2->takeName(I);
       AA.replaceWithNewValue(I, I2);
       ++I2;
     } else if (I->use_empty()) {


Index: llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
diff -u llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.38 llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.39
--- llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:1.38	Wed Feb  7 13:31:33 2007
+++ llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp	Sat Feb 10 19:08:35 2007
@@ -150,10 +150,10 @@
   unsigned NumArgs = Params.size();
   
   // Create the new function body and insert it into the module...
-  std::string Name = Fn.getName(); Fn.setName("");
-  Function *NF = new Function(NFTy, Fn.getLinkage(), Name);
+  Function *NF = new Function(NFTy, Fn.getLinkage());
   NF->setCallingConv(Fn.getCallingConv());
   Fn.getParent()->getFunctionList().insert(&Fn, NF);
+  NF->takeName(&Fn);
   
   // Loop over all of the callers of the function, transforming the call sites
   // to pass in a smaller number of arguments into the new function.
@@ -182,11 +182,7 @@
     if (!Call->use_empty())
       Call->replaceAllUsesWith(Constant::getNullValue(Call->getType()));
     
-    if (Call->hasName()) {
-      std::string Name = Call->getName();
-      Call->setName("");
-      New->setName(Name);
-    }
+    New->takeName(Call);
     
     // Finally, remove the old call from the program, reducing the use-count of
     // F.
@@ -206,7 +202,7 @@
        I2 = NF->arg_begin(); I != E; ++I, ++I2) {
     // Move the name and users over to the new version.
     I->replaceAllUsesWith(I2);
-    I2->setName(I->getName());
+    I2->takeName(I);
   }
   
   // Finally, nuke the old function.
@@ -509,10 +505,10 @@
   FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
 
   // Create the new function body and insert it into the module...
-  std::string Name = F->getName(); F->setName("");
-  Function *NF = new Function(NFTy, F->getLinkage(), Name);
+  Function *NF = new Function(NFTy, F->getLinkage());
   NF->setCallingConv(F->getCallingConv());
   F->getParent()->getFunctionList().insert(F, NF);
+  NF->takeName(F);
 
   // Loop over all of the callers of the function, transforming the call sites
   // to pass in a smaller number of arguments into the new function.
@@ -554,9 +550,7 @@
         Call->replaceAllUsesWith(Constant::getNullValue(Call->getType()));
       else {
         Call->replaceAllUsesWith(New);
-        std::string Name = Call->getName();
-        Call->setName("");
-        New->setName(Name);
+        New->takeName(Call);
       }
     }
 
@@ -581,7 +575,7 @@
       // If this is a live argument, move the name and users over to the new
       // version.
       I->replaceAllUsesWith(I2);
-      I2->setName(I->getName());
+      I2->takeName(I);
       ++I2;
     } else {
       // If this argument is dead, replace any uses of it with null constants


Index: llvm/lib/Transforms/IPO/ExtractFunction.cpp
diff -u llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.19 llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.20
--- llvm/lib/Transforms/IPO/ExtractFunction.cpp:1.19	Mon Feb  5 17:32:05 2007
+++ llvm/lib/Transforms/IPO/ExtractFunction.cpp	Sat Feb 10 19:08:35 2007
@@ -90,16 +90,15 @@
       for (Module::iterator I = M.begin(); ; ++I) {
         if (&*I != Named) {
           Function *New = new Function(I->getFunctionType(),
-                                       GlobalValue::ExternalLinkage,
-                                       I->getName());
+                                       GlobalValue::ExternalLinkage);
           New->setCallingConv(I->getCallingConv());
-          I->setName("");  // Remove Old name
 
           // If it's not the named function, delete the body of the function
           I->dropAllReferences();
 
           M.getFunctionList().push_back(New);
           NewFunctions.push_back(New);
+          New->takeName(I);
         }
 
         if (&*I == Last) break;  // Stop after processing the last function


Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.95 llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.96
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.95	Mon Feb  5 17:32:05 2007
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp	Sat Feb 10 19:08:35 2007
@@ -1189,14 +1189,13 @@
     } else if (!UI->use_empty()) {
       // Change the load into a load of bool then a select.
       LoadInst *LI = cast<LoadInst>(UI);
-
-      std::string Name = LI->getName(); LI->setName("");
-      LoadInst *NLI = new LoadInst(NewGV, Name+".b", LI);
+      LoadInst *NLI = new LoadInst(NewGV, LI->getName()+".b", LI);
       Value *NSI;
       if (IsOneZero)
-        NSI = new ZExtInst(NLI, LI->getType(), Name, LI);
+        NSI = new ZExtInst(NLI, LI->getType(), "", LI);
       else
-        NSI = new SelectInst(NLI, OtherVal, InitVal, Name, LI);
+        NSI = new SelectInst(NLI, OtherVal, InitVal, "", LI);
+      NSI->takeName(LI);
       LI->replaceAllUsesWith(NSI);
     }
     UI->eraseFromParent();
@@ -1519,10 +1518,9 @@
   
   // Create the new global and insert it next to the existing list.
   GlobalVariable *NGV = new GlobalVariable(CA->getType(), GCL->isConstant(),
-                                           GCL->getLinkage(), CA,
-                                           GCL->getName());
-  GCL->setName("");
+                                           GCL->getLinkage(), CA);
   GCL->getParent()->getGlobalList().insert(GCL, NGV);
+  NGV->takeName(GCL);
   
   // Nuke the old list, replacing any uses with the new one.
   if (!GCL->use_empty()) {


Index: llvm/lib/Transforms/IPO/PruneEH.cpp
diff -u llvm/lib/Transforms/IPO/PruneEH.cpp:1.29 llvm/lib/Transforms/IPO/PruneEH.cpp:1.30
--- llvm/lib/Transforms/IPO/PruneEH.cpp:1.29	Mon Feb  5 17:32:05 2007
+++ llvm/lib/Transforms/IPO/PruneEH.cpp	Sat Feb 10 19:08:35 2007
@@ -144,12 +144,12 @@
     if (InvokeInst *II = dyn_cast<InvokeInst>(BB->getTerminator()))
       if (Function *F = II->getCalledFunction())
         if (DoesNotUnwind.count(CG[F])) {
-          // Insert a call instruction before the invoke...
-          std::string Name = II->getName();  II->setName("");
+          // Insert a call instruction before the invoke.
           CallInst *Call = new CallInst(II->getCalledValue(),
                                         std::vector<Value*>(II->op_begin()+3,
                                                             II->op_end()),
-                                        Name, II);
+                                        "", II);
+          Call->takeName(II);
           Call->setCallingConv(II->getCallingConv());
 
           // Anything that used the value produced by the invoke instruction


Index: llvm/lib/Transforms/IPO/RaiseAllocations.cpp
diff -u llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.38 llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.39
--- llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.38	Mon Feb  5 17:32:05 2007
+++ llvm/lib/Transforms/IPO/RaiseAllocations.cpp	Sat Feb 10 19:08:35 2007
@@ -164,8 +164,8 @@
               CastInst::createIntegerCast(Source, Type::Int32Ty, false/*ZExt*/,
                                           "MallocAmtCast", I);
 
-          std::string Name(I->getName()); I->setName("");
-          MallocInst *MI = new MallocInst(Type::Int8Ty, Source, Name, I);
+          MallocInst *MI = new MallocInst(Type::Int8Ty, Source, "", I);
+          MI->takeName(I);
           I->replaceAllUsesWith(MI);
 
           // If the old instruction was an invoke, add an unconditional branch






More information about the llvm-commits mailing list