diff options
author | Chris Lattner <sabre@nondot.org> | 2007-02-11 01:08:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-02-11 01:08:35 +0000 |
commit | 046800a7125cd497613efc0e1ea15cb595666585 (patch) | |
tree | d786e1415ddb69b8a0d8f8b8f71856081f10aea4 /lib | |
parent | f41916e75dc9c622fa81b91eb6a5e0a36fa13754 (diff) | |
download | llvm-046800a7125cd497613efc0e1ea15cb595666585.tar.gz llvm-046800a7125cd497613efc0e1ea15cb595666585.tar.bz2 llvm-046800a7125cd497613efc0e1ea15cb595666585.tar.xz |
simplify name juggling through the use of Value::takeName.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34175 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/IPO/ArgumentPromotion.cpp | 6 | ||||
-rw-r--r-- | lib/Transforms/IPO/DeadArgumentElimination.cpp | 22 | ||||
-rw-r--r-- | lib/Transforms/IPO/ExtractFunction.cpp | 5 | ||||
-rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 14 | ||||
-rw-r--r-- | lib/Transforms/IPO/PruneEH.cpp | 6 | ||||
-rw-r--r-- | lib/Transforms/IPO/RaiseAllocations.cpp | 4 |
6 files changed, 23 insertions, 34 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index 3c57649f4e..4c1b2c3f28 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -455,9 +455,7 @@ Function *ArgPromotion::DoPromotion(Function *F, 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 @@ Function *ArgPromotion::DoPromotion(Function *F, // 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()) { diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index b39b2508d0..5963c9e800 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -150,10 +150,10 @@ bool DAE::DeleteDeadVarargs(Function &Fn) { 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 @@ bool DAE::DeleteDeadVarargs(Function &Fn) { 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 @@ bool DAE::DeleteDeadVarargs(Function &Fn) { 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 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) { 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 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) { 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 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) { // 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 diff --git a/lib/Transforms/IPO/ExtractFunction.cpp b/lib/Transforms/IPO/ExtractFunction.cpp index ae1eb22478..afaf38d280 100644 --- a/lib/Transforms/IPO/ExtractFunction.cpp +++ b/lib/Transforms/IPO/ExtractFunction.cpp @@ -90,16 +90,15 @@ namespace { 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 diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 5be5ace315..f5b12712f3 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -1189,14 +1189,13 @@ static void ShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) { } 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 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL, // 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()) { diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp index d6043a1df5..271a8fa0d0 100644 --- a/lib/Transforms/IPO/PruneEH.cpp +++ b/lib/Transforms/IPO/PruneEH.cpp @@ -144,12 +144,12 @@ bool PruneEH::SimplifyFunction(Function *F) { 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 diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp index b689de7083..aeb4173841 100644 --- a/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/lib/Transforms/IPO/RaiseAllocations.cpp @@ -164,8 +164,8 @@ bool RaiseAllocations::runOnModule(Module &M) { 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 |