summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2008-04-06 20:25:17 +0000
committerGabor Greif <ggreif@gmail.com>2008-04-06 20:25:17 +0000
commit051a950000e21935165db56695e35bade668193b (patch)
tree76db4bc690c153a1cfbd2989849c3b1d95500390 /lib/Transforms/IPO
parentd963ab1f58adb6daa028533ff3285841d7e45f80 (diff)
downloadllvm-051a950000e21935165db56695e35bade668193b.tar.gz
llvm-051a950000e21935165db56695e35bade668193b.tar.bz2
llvm-051a950000e21935165db56695e35bade668193b.tar.xz
API changes for class Use size reduction, wave 1.
Specifically, introduction of XXX::Create methods for Users that have a potentially variable number of Uses. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49277 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp24
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp18
-rw-r--r--lib/Transforms/IPO/ExtractGV.cpp4
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp35
-rw-r--r--lib/Transforms/IPO/IndMemRemoval.cpp20
-rw-r--r--lib/Transforms/IPO/LowerSetJmp.cpp42
-rw-r--r--lib/Transforms/IPO/PruneEH.cpp6
-rw-r--r--lib/Transforms/IPO/RaiseAllocations.cpp4
-rw-r--r--lib/Transforms/IPO/SimplifyLibCalls.cpp82
-rw-r--r--lib/Transforms/IPO/StructRetPromotion.cpp16
10 files changed, 125 insertions, 126 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp
index 230bafd6f0..fe0d6d98f2 100644
--- a/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -469,7 +469,7 @@ Function *ArgPromotion::DoPromotion(Function *F,
FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
// Create the new function body and insert it into the module...
- Function *NF = new Function(NFTy, F->getLinkage(), F->getName());
+ Function *NF = Function::Create(NFTy, F->getLinkage(), F->getName());
NF->setCallingConv(F->getCallingConv());
// Recompute the parameter attributes list based on the new arguments for
@@ -518,9 +518,9 @@ Function *ArgPromotion::DoPromotion(Function *F,
Value *Idxs[2] = { ConstantInt::get(Type::Int32Ty, 0), 0 };
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
Idxs[1] = ConstantInt::get(Type::Int32Ty, i);
- Value *Idx = new GetElementPtrInst(*AI, Idxs, Idxs+2,
- (*AI)->getName()+"."+utostr(i),
- Call);
+ Value *Idx = GetElementPtrInst::Create(*AI, Idxs, Idxs+2,
+ (*AI)->getName()+"."+utostr(i),
+ Call);
// TODO: Tell AA about the new values?
Args.push_back(new LoadInst(Idx, Idx->getName()+".val", Call));
}
@@ -532,8 +532,8 @@ Function *ArgPromotion::DoPromotion(Function *F,
Value *V = *AI;
LoadInst *OrigLoad = OriginalLoads[*SI];
if (!SI->empty()) {
- V = new GetElementPtrInst(V, SI->begin(), SI->end(),
- V->getName()+".idx", Call);
+ V = GetElementPtrInst::Create(V, SI->begin(), SI->end(),
+ V->getName()+".idx", Call);
AA.copyValue(OrigLoad->getOperand(0), V);
}
Args.push_back(new LoadInst(V, V->getName()+".val", Call));
@@ -553,13 +553,13 @@ Function *ArgPromotion::DoPromotion(Function *F,
Instruction *New;
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
- New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(),
- Args.begin(), Args.end(), "", Call);
+ New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
+ Args.begin(), Args.end(), "", Call);
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
cast<InvokeInst>(New)->setParamAttrs(PAListPtr::get(ParamAttrsVec.begin(),
ParamAttrsVec.end()));
} else {
- New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
+ New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
cast<CallInst>(New)->setParamAttrs(PAListPtr::get(ParamAttrsVec.begin(),
ParamAttrsVec.end()));
@@ -616,9 +616,9 @@ Function *ArgPromotion::DoPromotion(Function *F,
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
Idxs[1] = ConstantInt::get(Type::Int32Ty, i);
- Value *Idx = new GetElementPtrInst(TheAlloca, Idxs, Idxs+2,
- TheAlloca->getName()+"."+utostr(i),
- InsertPt);
+ Value *Idx = GetElementPtrInst::Create(TheAlloca, Idxs, Idxs+2,
+ TheAlloca->getName()+"."+utostr(i),
+ InsertPt);
I2->setName(I->getName()+"."+utostr(i));
new StoreInst(I2++, Idx, InsertPt);
}
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 8299dbc0d8..6cd128b7c4 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -157,7 +157,7 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
unsigned NumArgs = Params.size();
// Create the new function body and insert it into the module...
- Function *NF = new Function(NFTy, Fn.getLinkage());
+ Function *NF = Function::Create(NFTy, Fn.getLinkage());
NF->setCallingConv(Fn.getCallingConv());
NF->setParamAttrs(Fn.getParamAttrs());
if (Fn.hasCollector())
@@ -187,12 +187,12 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
Instruction *New;
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
- New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(),
- Args.begin(), Args.end(), "", Call);
+ New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
+ Args.begin(), Args.end(), "", Call);
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
cast<InvokeInst>(New)->setParamAttrs(PAL);
} else {
- New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
+ New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
cast<CallInst>(New)->setParamAttrs(PAL);
if (cast<CallInst>(Call)->isTailCall())
@@ -550,7 +550,7 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
// Create the new function body and insert it into the module...
- Function *NF = new Function(NFTy, F->getLinkage());
+ Function *NF = Function::Create(NFTy, F->getLinkage());
NF->setCallingConv(F->getCallingConv());
NF->setParamAttrs(NewPAL);
if (F->hasCollector())
@@ -602,12 +602,12 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
Instruction *New;
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
- New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(),
- Args.begin(), Args.end(), "", Call);
+ New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
+ Args.begin(), Args.end(), "", Call);
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
cast<InvokeInst>(New)->setParamAttrs(NewCallPAL);
} else {
- New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
+ New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
cast<CallInst>(New)->setParamAttrs(NewCallPAL);
if (cast<CallInst>(Call)->isTailCall())
@@ -660,7 +660,7 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
if (F->getReturnType() != NF->getReturnType())
for (Function::iterator BB = NF->begin(), E = NF->end(); BB != E; ++BB)
if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator())) {
- new ReturnInst(0, RI);
+ ReturnInst::Create(0, RI);
BB->getInstList().erase(RI);
}
diff --git a/lib/Transforms/IPO/ExtractGV.cpp b/lib/Transforms/IPO/ExtractGV.cpp
index 882097cae5..46232b880b 100644
--- a/lib/Transforms/IPO/ExtractGV.cpp
+++ b/lib/Transforms/IPO/ExtractGV.cpp
@@ -121,8 +121,8 @@ namespace {
for (Module::iterator I = M.begin(); ; ++I) {
if (std::find(Named.begin(), Named.end(), &*I) == Named.end()) {
- Function *New = new Function(I->getFunctionType(),
- GlobalValue::ExternalLinkage);
+ Function *New = Function::Create(I->getFunctionType(),
+ GlobalValue::ExternalLinkage);
New->setCallingConv(I->getCallingConv());
New->setParamAttrs(I->getParamAttrs());
if (I->hasCollector())
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index e5427766bf..50c5eccbd8 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -546,8 +546,8 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV) {
Idxs.push_back(NullInt);
for (unsigned i = 3, e = GEPI->getNumOperands(); i != e; ++i)
Idxs.push_back(GEPI->getOperand(i));
- NewPtr = new GetElementPtrInst(NewPtr, Idxs.begin(), Idxs.end(),
- GEPI->getName()+"."+utostr(Val), GEPI);
+ NewPtr = GetElementPtrInst::Create(NewPtr, Idxs.begin(), Idxs.end(),
+ GEPI->getName()+"."+utostr(Val), GEPI);
}
}
GEP->replaceAllUsesWith(NewPtr);
@@ -789,8 +789,8 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
MI->getAlignment(), MI->getName(), MI);
Value* Indices[2];
Indices[0] = Indices[1] = Constant::getNullValue(Type::Int32Ty);
- Value *NewGEP = new GetElementPtrInst(NewMI, Indices, Indices + 2,
- NewMI->getName()+".el0", MI);
+ Value *NewGEP = GetElementPtrInst::Create(NewMI, Indices, Indices + 2,
+ NewMI->getName()+".el0", MI);
MI->replaceAllUsesWith(NewGEP);
MI->eraseFromParent();
MI = NewMI;
@@ -1054,8 +1054,8 @@ static void RewriteHeapSROALoadUser(LoadInst *Load, Instruction *LoadUser,
GEPIdx.push_back(GEPI->getOperand(1));
GEPIdx.append(GEPI->op_begin()+3, GEPI->op_end());
- Value *NGEPI = new GetElementPtrInst(NewPtr, GEPIdx.begin(), GEPIdx.end(),
- GEPI->getName(), GEPI);
+ Value *NGEPI = GetElementPtrInst::Create(NewPtr, GEPIdx.begin(), GEPIdx.end(),
+ GEPI->getName(), GEPI);
GEPI->replaceAllUsesWith(NGEPI);
GEPI->eraseFromParent();
return;
@@ -1070,8 +1070,8 @@ static void RewriteHeapSROALoadUser(LoadInst *Load, Instruction *LoadUser,
for (unsigned i = 0, e = FieldGlobals.size(); i != e; ++i) {
Value *LoadV = GetHeapSROALoad(Load, i, FieldGlobals, InsertedLoadsForPtr);
- PHINode *FieldPN = new PHINode(LoadV->getType(),
- PN->getName()+"."+utostr(i), PN);
+ PHINode *FieldPN = PHINode::Create(LoadV->getType(),
+ PN->getName()+"."+utostr(i), PN);
// Fill in the predecessor values.
for (unsigned pred = 0, e = PN->getNumIncomingValues(); pred != e; ++pred) {
// Each predecessor either uses the load or the original malloc.
@@ -1173,13 +1173,13 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI){
// Create the block to check the first condition. Put all these blocks at the
// end of the function as they are unlikely to be executed.
- BasicBlock *NullPtrBlock = new BasicBlock("malloc_ret_null",
- OrigBB->getParent());
+ BasicBlock *NullPtrBlock = BasicBlock::Create("malloc_ret_null",
+ OrigBB->getParent());
// Remove the uncond branch from OrigBB to ContBB, turning it into a cond
// branch on RunningOr.
OrigBB->getTerminator()->eraseFromParent();
- new BranchInst(NullPtrBlock, ContBB, RunningOr, OrigBB);
+ BranchInst::Create(NullPtrBlock, ContBB, RunningOr, OrigBB);
// Within the NullPtrBlock, we need to emit a comparison and branch for each
// pointer, because some may be null while others are not.
@@ -1188,21 +1188,20 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI){
Value *Cmp = new ICmpInst(ICmpInst::ICMP_NE, GVVal,
Constant::getNullValue(GVVal->getType()),
"tmp", NullPtrBlock);
- BasicBlock *FreeBlock = new BasicBlock("free_it", OrigBB->getParent());
- BasicBlock *NextBlock = new BasicBlock("next", OrigBB->getParent());
- new BranchInst(FreeBlock, NextBlock, Cmp, NullPtrBlock);
+ BasicBlock *FreeBlock = BasicBlock::Create("free_it", OrigBB->getParent());
+ BasicBlock *NextBlock = BasicBlock::Create("next", OrigBB->getParent());
+ BranchInst::Create(FreeBlock, NextBlock, Cmp, NullPtrBlock);
// Fill in FreeBlock.
new FreeInst(GVVal, FreeBlock);
new StoreInst(Constant::getNullValue(GVVal->getType()), FieldGlobals[i],
FreeBlock);
- new BranchInst(NextBlock, FreeBlock);
+ BranchInst::Create(NextBlock, FreeBlock);
NullPtrBlock = NextBlock;
}
- new BranchInst(ContBB, NullPtrBlock);
-
+ BranchInst::Create(ContBB, NullPtrBlock);
// MI is no longer needed, remove it.
MI->eraseFromParent();
@@ -1411,7 +1410,7 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
if (IsOneZero)
NSI = new ZExtInst(NLI, LI->getType(), "", LI);
else
- NSI = new SelectInst(NLI, OtherVal, InitVal, "", LI);
+ NSI = SelectInst::Create(NLI, OtherVal, InitVal, "", LI);
NSI->takeName(LI);
LI->replaceAllUsesWith(NSI);
}
diff --git a/lib/Transforms/IPO/IndMemRemoval.cpp b/lib/Transforms/IPO/IndMemRemoval.cpp
index 502c293da1..2f9c34d5cf 100644
--- a/lib/Transforms/IPO/IndMemRemoval.cpp
+++ b/lib/Transforms/IPO/IndMemRemoval.cpp
@@ -52,11 +52,11 @@ bool IndMemRemPass::runOnModule(Module &M) {
if (Function* F = M.getFunction("free")) {
assert(F->isDeclaration() && "free not external?");
if (!F->use_empty()) {
- Function* FN = new Function(F->getFunctionType(),
- GlobalValue::LinkOnceLinkage,
- "free_llvm_bounce", &M);
- BasicBlock* bb = new BasicBlock("entry",FN);
- Instruction* R = new ReturnInst(bb);
+ Function* FN = Function::Create(F->getFunctionType(),
+ GlobalValue::LinkOnceLinkage,
+ "free_llvm_bounce", &M);
+ BasicBlock* bb = BasicBlock::Create("entry",FN);
+ Instruction* R = ReturnInst::Create(bb);
new FreeInst(FN->arg_begin(), R);
++NumBounce;
NumBounceSites += F->getNumUses();
@@ -67,14 +67,14 @@ bool IndMemRemPass::runOnModule(Module &M) {
if (Function* F = M.getFunction("malloc")) {
assert(F->isDeclaration() && "malloc not external?");
if (!F->use_empty()) {
- Function* FN = new Function(F->getFunctionType(),
- GlobalValue::LinkOnceLinkage,
- "malloc_llvm_bounce", &M);
- BasicBlock* bb = new BasicBlock("entry",FN);
+ Function* FN = Function::Create(F->getFunctionType(),
+ GlobalValue::LinkOnceLinkage,
+ "malloc_llvm_bounce", &M);
+ BasicBlock* bb = BasicBlock::Create("entry",FN);
Instruction* c = CastInst::createIntegerCast(
FN->arg_begin(), Type::Int32Ty, false, "c", bb);
Instruction* a = new MallocInst(Type::Int8Ty, c, "m", bb);
- new ReturnInst(a, bb);
+ ReturnInst::Create(a, bb);
++NumBounce;
NumBounceSites += F->getNumUses();
F->replaceAllUsesWith(FN);
diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp
index d4b8454e37..2db8257b84 100644
--- a/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/lib/Transforms/IPO/LowerSetJmp.cpp
@@ -268,7 +268,7 @@ void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
SmallVector<Value *, 2> Args;
Args.push_back(CI);
Args.push_back(Inst->getOperand(2));
- new CallInst(ThrowLongJmp, Args.begin(), Args.end(), "", Inst);
+ CallInst::Create(ThrowLongJmp, Args.begin(), Args.end(), "", Inst);
SwitchValuePair& SVP = SwitchValMap[Inst->getParent()->getParent()];
@@ -276,7 +276,7 @@ void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
// we should branch to the basic block that determines if this longjmp
// is applicable here. Otherwise, issue an unwind.
if (SVP.first)
- new BranchInst(SVP.first->getParent(), Inst);
+ BranchInst::Create(SVP.first->getParent(), Inst);
else
new UnwindInst(Inst);
@@ -311,7 +311,7 @@ AllocaInst* LowerSetJmp::GetSetJmpMap(Function* Func)
// Fill in the alloca and call to initialize the SJ map.
const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst);
- new CallInst(InitSJMap, Map, "", Inst);
+ CallInst::Create(InitSJMap, Map, "", Inst);
return SJMap[Func] = Map;
}
@@ -324,7 +324,7 @@ BasicBlock* LowerSetJmp::GetRethrowBB(Function* Func)
// The basic block we're going to jump to if we need to rethrow the
// exception.
- BasicBlock* Rethrow = new BasicBlock("RethrowExcept", Func);
+ BasicBlock* Rethrow = BasicBlock::Create("RethrowExcept", Func);
// Fill in the "Rethrow" BB with a call to rethrow the exception. This
// is the last instruction in the BB since at this point the runtime
@@ -340,7 +340,7 @@ LowerSetJmp::SwitchValuePair LowerSetJmp::GetSJSwitch(Function* Func,
{
if (SwitchValMap[Func].first) return SwitchValMap[Func];
- BasicBlock* LongJmpPre = new BasicBlock("LongJmpBlkPre", Func);
+ BasicBlock* LongJmpPre = BasicBlock::Create("LongJmpBlkPre", Func);
BasicBlock::InstListType& LongJmpPreIL = LongJmpPre->getInstList();
// Keep track of the preliminary basic block for some of the other
@@ -348,24 +348,24 @@ LowerSetJmp::SwitchValuePair LowerSetJmp::GetSJSwitch(Function* Func,
PrelimBBMap[Func] = LongJmpPre;
// Grab the exception.
- CallInst* Cond = new CallInst(IsLJException, "IsLJExcept");
+ CallInst* Cond = CallInst::Create(IsLJException, "IsLJExcept");
LongJmpPreIL.push_back(Cond);
// The "decision basic block" gets the number associated with the
// setjmp call returning to switch on and the value returned by
// longjmp.
- BasicBlock* DecisionBB = new BasicBlock("LJDecisionBB", Func);
+ BasicBlock* DecisionBB = BasicBlock::Create("LJDecisionBB", Func);
BasicBlock::InstListType& DecisionBBIL = DecisionBB->getInstList();
- new BranchInst(DecisionBB, Rethrow, Cond, LongJmpPre);
+ BranchInst::Create(DecisionBB, Rethrow, Cond, LongJmpPre);
// Fill in the "decision" basic block.
- CallInst* LJVal = new CallInst(GetLJValue, "LJVal");
+ CallInst* LJVal = CallInst::Create(GetLJValue, "LJVal");
DecisionBBIL.push_back(LJVal);
- CallInst* SJNum = new CallInst(TryCatchLJ, GetSetJmpMap(Func), "SJNum");
+ CallInst* SJNum = CallInst::Create(TryCatchLJ, GetSetJmpMap(Func), "SJNum");
DecisionBBIL.push_back(SJNum);
- SwitchInst* SI = new SwitchInst(SJNum, Rethrow, 0, DecisionBB);
+ SwitchInst* SI = SwitchInst::Create(SJNum, Rethrow, 0, DecisionBB);
return SwitchValMap[Func] = SwitchValuePair(SI, LJVal);
}
@@ -386,7 +386,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst)
make_vector<Value*>(GetSetJmpMap(Func), BufPtr,
ConstantInt::get(Type::Int32Ty,
SetJmpIDMap[Func]++), 0);
- new CallInst(AddSJToMap, Args.begin(), Args.end(), "", Inst);
+ CallInst::Create(AddSJToMap, Args.begin(), Args.end(), "", Inst);
// We are guaranteed that there are no values live across basic blocks
// (because we are "not in SSA form" yet), but there can still be values live
@@ -428,7 +428,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst)
// This PHI node will be in the new block created from the
// splitBasicBlock call.
- PHINode* PHI = new PHINode(Type::Int32Ty, "SetJmpReturn", Inst);
+ PHINode* PHI = PHINode::Create(Type::Int32Ty, "SetJmpReturn", Inst);
// Coming from a call to setjmp, the return is 0.
PHI->addIncoming(ConstantInt::getNullValue(Type::Int32Ty), ABlock);
@@ -474,9 +474,9 @@ void LowerSetJmp::visitCallInst(CallInst& CI)
// Construct the new "invoke" instruction.
TerminatorInst* Term = OldBB->getTerminator();
std::vector<Value*> Params(CI.op_begin() + 1, CI.op_end());
- InvokeInst* II = new
- InvokeInst(CI.getCalledValue(), NewBB, PrelimBBMap[Func],
- Params.begin(), Params.end(), CI.getName(), Term);
+ InvokeInst* II =
+ InvokeInst::Create(CI.getCalledValue(), NewBB, PrelimBBMap[Func],
+ Params.begin(), Params.end(), CI.getName(), Term);
II->setCallingConv(CI.getCallingConv());
II->setParamAttrs(CI.getParamAttrs());
@@ -507,15 +507,15 @@ void LowerSetJmp::visitInvokeInst(InvokeInst& II)
BasicBlock* ExceptBB = II.getUnwindDest();
Function* Func = BB->getParent();
- BasicBlock* NewExceptBB = new BasicBlock("InvokeExcept", Func);
+ BasicBlock* NewExceptBB = BasicBlock::Create("InvokeExcept", Func);
BasicBlock::InstListType& InstList = NewExceptBB->getInstList();
// If this is a longjmp exception, then branch to the preliminary BB of
// the longjmp exception handling. Otherwise, go to the old exception.
- CallInst* IsLJExcept = new CallInst(IsLJException, "IsLJExcept");
+ CallInst* IsLJExcept = CallInst::Create(IsLJException, "IsLJExcept");
InstList.push_back(IsLJExcept);
- new BranchInst(PrelimBBMap[Func], ExceptBB, IsLJExcept, NewExceptBB);
+ BranchInst::Create(PrelimBBMap[Func], ExceptBB, IsLJExcept, NewExceptBB);
II.setUnwindDest(NewExceptBB);
++InvokesTransformed;
@@ -525,14 +525,14 @@ void LowerSetJmp::visitInvokeInst(InvokeInst& II)
// function.
void LowerSetJmp::visitReturnInst(ReturnInst &RI) {
Function* Func = RI.getParent()->getParent();
- new CallInst(DestroySJMap, GetSetJmpMap(Func), "", &RI);
+ CallInst::Create(DestroySJMap, GetSetJmpMap(Func), "", &RI);
}
// visitUnwindInst - We want to destroy the setjmp map upon exit from the
// function.
void LowerSetJmp::visitUnwindInst(UnwindInst &UI) {
Function* Func = UI.getParent()->getParent();
- new CallInst(DestroySJMap, GetSetJmpMap(Func), "", &UI);
+ CallInst::Create(DestroySJMap, GetSetJmpMap(Func), "", &UI);
}
ModulePass *llvm::createLowerSetJmpPass() {
diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp
index 46e11280b0..1b9aefc582 100644
--- a/lib/Transforms/IPO/PruneEH.cpp
+++ b/lib/Transforms/IPO/PruneEH.cpp
@@ -158,8 +158,8 @@ bool PruneEH::SimplifyFunction(Function *F) {
if (II->doesNotThrow()) {
SmallVector<Value*, 8> Args(II->op_begin()+3, II->op_end());
// Insert a call instruction before the invoke.
- CallInst *Call = new CallInst(II->getCalledValue(),
- Args.begin(), Args.end(), "", II);
+ CallInst *Call = CallInst::Create(II->getCalledValue(),
+ Args.begin(), Args.end(), "", II);
Call->takeName(II);
Call->setCallingConv(II->getCallingConv());
Call->setParamAttrs(II->getParamAttrs());
@@ -172,7 +172,7 @@ bool PruneEH::SimplifyFunction(Function *F) {
// Insert a branch to the normal destination right before the
// invoke.
- new BranchInst(II->getNormalDest(), II);
+ BranchInst::Create(II->getNormalDest(), II);
// Finally, delete the invoke instruction!
BB->getInstList().pop_back();
diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp
index e284009247..1f12fcf79d 100644
--- a/lib/Transforms/IPO/RaiseAllocations.cpp
+++ b/lib/Transforms/IPO/RaiseAllocations.cpp
@@ -175,7 +175,7 @@ bool RaiseAllocations::runOnModule(Module &M) {
// If the old instruction was an invoke, add an unconditional branch
// before the invoke, which will become the new terminator.
if (InvokeInst *II = dyn_cast<InvokeInst>(I))
- new BranchInst(II->getNormalDest(), I);
+ BranchInst::Create(II->getNormalDest(), I);
// Delete the old call site
MI->getParent()->getInstList().erase(I);
@@ -227,7 +227,7 @@ bool RaiseAllocations::runOnModule(Module &M) {
// If the old instruction was an invoke, add an unconditional branch
// before the invoke, which will become the new terminator.
if (InvokeInst *II = dyn_cast<InvokeInst>(I))
- new BranchInst(II->getNormalDest(), I);
+ BranchInst::Create(II->getNormalDest(), I);
// Delete the old call site
if (I->getType() != Type::VoidTy)
diff --git a/lib/Transforms/IPO/SimplifyLibCalls.cpp b/lib/Transforms/IPO/SimplifyLibCalls.cpp
index 945eb909e5..bbfd1d2da3 100644
--- a/lib/Transforms/IPO/SimplifyLibCalls.cpp
+++ b/lib/Transforms/IPO/SimplifyLibCalls.cpp
@@ -430,7 +430,7 @@ struct VISIBILITY_HIDDEN ExitInMainOptimization : public LibCallOptimization {
// Create a return instruction that we'll replace the call with.
// Note that the argument of the return is the argument of the call
// instruction.
- new ReturnInst(ci->getOperand(1), ci);
+ ReturnInst::Create(ci->getOperand(1), ci);
// Split the block at the call instruction which places it in a new
// basic block.
@@ -496,13 +496,13 @@ public:
// We need to find the end of the destination string. That's where the
// memory is to be moved to. We just generate a call to strlen.
- CallInst *DstLen = new CallInst(SLC.get_strlen(), Dst,
- Dst->getName()+".len", CI);
+ CallInst *DstLen = CallInst::Create(SLC.get_strlen(), Dst,
+ Dst->getName()+".len", CI);
// Now that we have the destination's length, we must index into the
// destination's pointer to get the actual memcpy destination (end of
// the string .. we're concatenating).
- Dst = new GetElementPtrInst(Dst, DstLen, Dst->getName()+".indexed", CI);
+ Dst = GetElementPtrInst::Create(Dst, DstLen, Dst->getName()+".indexed", CI);
// We have enough information to now generate the memcpy call to
// do the concatenation for us.
@@ -511,7 +511,7 @@ public:
ConstantInt::get(SLC.getIntPtrType(), SrcStr.size()+1), // copy nul byte.
ConstantInt::get(Type::Int32Ty, 1) // alignment
};
- new CallInst(SLC.get_memcpy(), Vals, Vals + 4, "", CI);
+ CallInst::Create(SLC.get_memcpy(), Vals, Vals + 4, "", CI);
return ReplaceCallWith(CI, Dst);
}
@@ -551,8 +551,8 @@ public:
CI->getOperand(2),
ConstantInt::get(SLC.getIntPtrType(), Str.size()+1)
};
- return ReplaceCallWith(CI, new CallInst(SLC.get_memchr(), Args, Args + 3,
- CI->getName(), CI));
+ return ReplaceCallWith(CI, CallInst::Create(SLC.get_memchr(), Args, Args + 3,
+ CI->getName(), CI));
}
// strchr can find the nul character.
@@ -575,9 +575,9 @@ public:
// strchr(s+n,c) -> gep(s+n+i,c)
// (if c is a constant integer and s is a constant string)
Value *Idx = ConstantInt::get(Type::Int64Ty, i);
- Value *GEP = new GetElementPtrInst(CI->getOperand(1), Idx,
- CI->getOperand(1)->getName() +
- ".strchr", CI);
+ Value *GEP = GetElementPtrInst::Create(CI->getOperand(1), Idx,
+ CI->getOperand(1)->getName() +
+ ".strchr", CI);
return ReplaceCallWith(CI, GEP);
}
} StrChrOptimizer;
@@ -754,7 +754,7 @@ public:
ConstantInt::get(SLC.getIntPtrType(), SrcStr.size()+1),
ConstantInt::get(Type::Int32Ty, 1) // alignment
};
- new CallInst(SLC.get_memcpy(), MemcpyOps, MemcpyOps + 4, "", CI);
+ CallInst::Create(SLC.get_memcpy(), MemcpyOps, MemcpyOps + 4, "", CI);
return ReplaceCallWith(CI, Dst);
}
@@ -900,8 +900,8 @@ struct VISIBILITY_HIDDEN memcmpOptimization : public LibCallOptimization {
Value *D1 = BinaryOperator::createSub(S1V1, S2V1,
CI->getName()+".d1", CI);
Constant *One = ConstantInt::get(Type::Int32Ty, 1);
- Value *G1 = new GetElementPtrInst(Op1Cast, One, "next1v", CI);
- Value *G2 = new GetElementPtrInst(Op2Cast, One, "next2v", CI);
+ Value *G1 = GetElementPtrInst::Create(Op1Cast, One, "next1v", CI);
+ Value *G2 = GetElementPtrInst::Create(Op2Cast, One, "next2v", CI);
Value *S1V2 = new LoadInst(G1, LHS->getName()+".val2", CI);
Value *S2V2 = new LoadInst(G2, RHS->getName()+".val2", CI);
Value *D2 = BinaryOperator::createSub(S1V2, S2V2,
@@ -946,7 +946,7 @@ public:
CI->getOperand(1), CI->getOperand(2), CI->getOperand(3),
ConstantInt::get(Type::Int32Ty, 1) // align = 1 always.
};
- new CallInst(SLC.get_memcpy(), MemcpyOps, MemcpyOps + 4, "", CI);
+ CallInst::Create(SLC.get_memcpy(), MemcpyOps, MemcpyOps + 4, "", CI);
// memcpy always returns the destination
return ReplaceCallWith(CI, CI->getOperand(1));
}
@@ -1162,8 +1162,8 @@ public:
Ty==Type::FloatTy ? APFloat(1.0f) : APFloat(1.0)));
} else if (Op2->isExactlyValue(0.5)) {
// pow(x,0.5) -> sqrt(x)
- CallInst* sqrt_inst = new CallInst(SLC.get_sqrt(), base,
- ci->getName()+".pow",ci);
+ CallInst* sqrt_inst = CallInst::Create(SLC.get_sqrt(), base,
+ ci->getName()+".pow",ci);
return ReplaceCallWith(ci, sqrt_inst);
} else if (Op2->isExactlyValue(1.0)) {
// pow(x,1.0) -> x
@@ -1220,7 +1220,7 @@ public:
if (FormatStr.size() == 1) {
// Turn this into a putchar call, even if it is a %.
Value *V = ConstantInt::get(Type::Int32Ty, FormatStr[0]);
- new CallInst(SLC.get_putchar(), V, "", CI);
+ CallInst::Create(SLC.get_putchar(), V, "", CI);
if (CI->use_empty()) return ReplaceCallWith(CI, 0);
return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1));
}
@@ -1240,7 +1240,7 @@ public:
CI->getParent()->getParent()->getParent());
// Cast GV to be a pointer to char.
GV = ConstantExpr::getBitCast(GV, PointerType::getUnqual(Type::Int8Ty));
- new CallInst(SLC.get_puts(), GV, "", CI);
+ CallInst::Create(SLC.get_puts(), GV, "", CI);
if (CI->use_empty()) return ReplaceCallWith(CI, 0);
// The return value from printf includes the \n we just removed, so +1.
@@ -1264,8 +1264,8 @@ public:
return false;
// printf("%s\n",str) -> puts(str)
- new CallInst(SLC.get_puts(), CastToCStr(CI->getOperand(2), CI),
- CI->getName(), CI);
+ CallInst::Create(SLC.get_puts(), CastToCStr(CI->getOperand(2), CI),
+ CI->getName(), CI);
return ReplaceCallWith(CI, 0);
case 'c': {
// printf("%c",c) -> putchar(c)
@@ -1279,7 +1279,7 @@ public:
V = CastInst::createZExtOrBitCast(V, Type::Int32Ty, CI->getName()+".int",
CI);
- new CallInst(SLC.get_putchar(), V, "", CI);
+ CallInst::Create(SLC.get_putchar(), V, "", CI);
return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1));
}
}
@@ -1331,7 +1331,7 @@ public:
ConstantInt::get(SLC.getIntPtrType(), 1),
CI->getOperand(1)
};
- new CallInst(SLC.get_fwrite(FILEty), FWriteArgs, FWriteArgs + 4, CI->getName(), CI);
+ CallInst::Create(SLC.get_fwrite(FILEty), FWriteArgs, FWriteArgs + 4, CI->getName(), CI);
return ReplaceCallWith(CI, ConstantInt::get(CI->getType(),
FormatStr.size()));
}
@@ -1351,7 +1351,7 @@ public:
SmallVector<Value *, 2> Args;
Args.push_back(C);
Args.push_back(CI->getOperand(1));
- new CallInst(SLC.get_fputc(FILETy), Args.begin(), Args.end(), "", CI);
+ CallInst::Create(SLC.get_fputc(FILETy), Args.begin(), Args.end(), "", CI);
return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1));
}
case 's': {
@@ -1366,8 +1366,8 @@ public:
SmallVector<Value *, 2> Args;
Args.push_back(CastToCStr(CI->getOperand(3), CI));
Args.push_back(CI->getOperand(1));
- new CallInst(SLC.get_fputs(FILETy), Args.begin(),
- Args.end(), CI->getName(), CI);
+ CallInst::Create(SLC.get_fputs(FILETy), Args.begin(),
+ Args.end(), CI->getName(), CI);
return ReplaceCallWith(CI, 0);
}
default:
@@ -1418,7 +1418,7 @@ public:
FormatStr.size()+1), // Copy the nul byte.
ConstantInt::get(Type::Int32Ty, 1)
};
- new CallInst(SLC.get_memcpy(), MemCpyArgs, MemCpyArgs + 4, "", CI);
+ CallInst::Create(SLC.get_memcpy(), MemCpyArgs, MemCpyArgs + 4, "", CI);
return ReplaceCallWith(CI, ConstantInt::get(CI->getType(),
FormatStr.size()));
}
@@ -1434,18 +1434,18 @@ public:
Value *V = CastInst::createTruncOrBitCast(CI->getOperand(3),
Type::Int8Ty, "char", CI);
new StoreInst(V, CI->getOperand(1), CI);
- Value *Ptr = new GetElementPtrInst(CI->getOperand(1),
- ConstantInt::get(Type::Int32Ty, 1),
- CI->getOperand(1)->getName()+".end",
- CI);
+ Value *Ptr = GetElementPtrInst::Create(CI->getOperand(1),
+ ConstantInt::get(Type::Int32Ty, 1),
+ CI->getOperand(1)->getName()+".end",
+ CI);
new StoreInst(ConstantInt::get(Type::Int8Ty,0), Ptr, CI);
return ReplaceCallWith(CI, ConstantInt::get(Type::Int32Ty, 1));
}
case 's': {
// sprintf(dest,"%s",str) -> llvm.memcpy(dest, str, strlen(str)+1, 1)
- Value *Len = new CallInst(SLC.get_strlen(),
- CastToCStr(CI->getOperand(3), CI),
- CI->getOperand(3)->getName()+".len", CI);
+ Value *Len = CallInst::Create(SLC.get_strlen(),
+ CastToCStr(CI->getOperand(3), CI),
+ CI->getOperand(3)->getName()+".len", CI);
Value *UnincLen = Len;
Len = BinaryOperator::createAdd(Len, ConstantInt::get(Len->getType(), 1),
Len->getName()+"1", CI);
@@ -1455,7 +1455,7 @@ public:
Len,
ConstantInt::get(Type::Int32Ty, 1)
};
- new CallInst(SLC.get_memcpy(), MemcpyArgs, MemcpyArgs + 4, "", CI);
+ CallInst::Create(SLC.get_memcpy(), MemcpyArgs, MemcpyArgs + 4, "", CI);
// The strlen result is the unincremented number of bytes in the string.
if (!CI->use_empty()) {
@@ -1507,7 +1507,7 @@ public:
ConstantInt::get(SLC.getIntPtrType(), 1),
CI->getOperand(2)
};
- new CallInst(SLC.get_fwrite(FILETy), FWriteParms, FWriteParms + 4, "", CI);
+ CallInst::Create(SLC.get_fwrite(FILETy), FWriteParms, FWriteParms + 4, "", CI);
return ReplaceCallWith(CI, 0); // Known to have no uses (see above).
}
} FPutsOptimizer;
@@ -1555,7 +1555,7 @@ public:
Args.push_back(new ZExtInst(Val, Type::Int32Ty, Val->getName()+".int", CI));
Args.push_back(CI->getOperand(4));
const Type *FILETy = CI->getOperand(4)->getType();
- new CallInst(SLC.get_fputc(FILETy), Args.begin(), Args.end(), "", CI);
+ CallInst::Create(SLC.get_fputc(FILETy), Args.begin(), Args.end(), "", CI);
return ReplaceCallWith(CI, ConstantInt::get(CI->getType(), 1));
}
return false;
@@ -1715,7 +1715,7 @@ public:
ArgType, NULL);
Value *V = CastInst::createIntegerCast(TheCall->getOperand(1), ArgType,
false/*ZExt*/, "tmp", TheCall);
- Value *V2 = new CallInst(F, V, "tmp", TheCall);
+ Value *V2 = CallInst::Create(F, V, "tmp", TheCall);
V2 = CastInst::createIntegerCast(V2, Type::Int32Ty, false/*ZExt*/,
"tmp", TheCall);
V2 = BinaryOperator::createAdd(V2, ConstantInt::get(Type::Int32Ty, 1),
@@ -1723,8 +1723,8 @@ public:
Value *Cond = new ICmpInst(ICmpInst::ICMP_EQ, V,
Constant::getNullValue(V->getType()), "tmp",
TheCall);
- V2 = new SelectInst(Cond, ConstantInt::get(Type::Int32Ty, 0), V2,
- TheCall->getName(), TheCall);
+ V2 = SelectInst::Create(Cond, ConstantInt::get(Type::Int32Ty, 0), V2,
+ TheCall->getName(), TheCall);
return ReplaceCallWith(TheCall, V2);
}
} FFSOptimizer;
@@ -1773,8 +1773,8 @@ struct UnaryDoubleFPOptimizer : public LibCallOptimization {
Constant *(SimplifyLibCalls::*FP)()){
if (FPExtInst *Cast = dyn_cast<FPExtInst>(CI->getOperand(1)))
if (Cast->getOperand(0)->getType() == Type::FloatTy) {
- Value *New = new CallInst((SLC.*FP)(), Cast->getOperand(0),
- CI->getName(), CI);
+ Value *New = CallInst::Create((SLC.*FP)(), Cast->getOperand(0),
+ CI->getName(), CI);
New = new FPExtInst(New, Type::DoubleTy, CI->getName(), CI);
CI->replaceAllUsesWith(New);
CI->eraseFromParent();
diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp
index 1e51cb96c9..80952b7c70 100644
--- a/lib/Transforms/IPO/StructRetPromotion.cpp
+++ b/lib/Transforms/IPO/StructRetPromotion.cpp
@@ -116,14 +116,14 @@ bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) {
SmallVector<Value*, 2> GEPIdx;
GEPIdx.push_back(ConstantInt::get(Type::Int32Ty, 0));
GEPIdx.push_back(ConstantInt::get(Type::Int32Ty, idx));
- Value *NGEPI = new GetElementPtrInst(TheAlloca, GEPIdx.begin(),
- GEPIdx.end(),
- "mrv.gep", I);
+ Value *NGEPI = GetElementPtrInst::Create(TheAlloca, GEPIdx.begin(),
+ GEPIdx.end(),
+ "mrv.gep", I);
Value *NV = new LoadInst(NGEPI, "mrv.ld", I);
RetVals.push_back(NV);
}
- ReturnInst *NR = new ReturnInst(&RetVals[0], RetVals.size(), I);
+ ReturnInst *NR = ReturnInst::Create(&RetVals[0], RetVals.size(), I);
I->replaceAllUsesWith(NR);
I->eraseFromParent();
}
@@ -222,7 +222,7 @@ Function *SRETPromotion::cloneFunctionBody(Function *F,
}
FunctionType *NFTy = FunctionType::get(STy, Params, FTy->isVarArg());
- Function *NF = new Function(NFTy, F->getLinkage(), F->getName());
+ Function *NF = Function::Create(NFTy, F->getLinkage(), F->getName());
NF->setCallingConv(F->getCallingConv());
NF->setParamAttrs(PAListPtr::get(ParamAttrsVec.begin(), ParamAttrsVec.end()));
F->getParent()->getFunctionList().insert(F, NF);
@@ -283,12 +283,12 @@ void SRETPromotion::updateCallSites(Function *F, Function *NF) {
// Build new call instruction.
Instruction *New;
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
- New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(),
- Args.begin(), Args.end(), "", Call);
+ New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
+ Args.begin(), Args.end(), "", Call);
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
cast<InvokeInst>(New)->setParamAttrs(NewPAL);
} else {
- New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
+ New = CallInst::Create(NF, Args.begin(), Args.end(), "", Call);
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
cast<CallInst>(New)->setParamAttrs(NewPAL);
if (cast<CallInst>(Call)->isTailCall())