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
// 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()) {
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.
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.
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.
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.
Call->replaceAllUsesWith(Constant::getNullValue(Call->getType()));
else {
Call->replaceAllUsesWith(New);
- std::string Name = Call->getName();
- Call->setName("");
- New->setName(Name);
+ New->takeName(Call);
}
}
// 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
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
} 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();
// 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()) {
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
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