aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r--lib/Transforms/Utils/BasicBlockUtils.cpp2
-rw-r--r--lib/Transforms/Utils/BreakCriticalEdges.cpp6
-rw-r--r--lib/Transforms/Utils/CloneFunction.cpp10
-rw-r--r--lib/Transforms/Utils/CloneModule.cpp4
-rw-r--r--lib/Transforms/Utils/CodeExtractor.cpp62
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp34
-rw-r--r--lib/Transforms/Utils/LCSSA.cpp8
-rw-r--r--lib/Transforms/Utils/Local.cpp4
-rw-r--r--lib/Transforms/Utils/LoopSimplify.cpp14
-rw-r--r--lib/Transforms/Utils/LowerAllocations.cpp4
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp64
-rw-r--r--lib/Transforms/Utils/LowerSwitch.cpp16
-rw-r--r--lib/Transforms/Utils/PromoteMemoryToRegister.cpp6
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp60
-rw-r--r--lib/Transforms/Utils/UnifyFunctionExitNodes.cpp24
15 files changed, 159 insertions, 159 deletions
diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp
index 0dc38a2b84..895e44a4f7 100644
--- a/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -98,7 +98,7 @@ void llvm::RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum) {
RetVal = Constant::getNullValue(BB->getParent()->getReturnType());
// Create the return...
- NewTI = new ReturnInst(RetVal);
+ NewTI = ReturnInst::Create(RetVal);
}
break;
diff --git a/lib/Transforms/Utils/BreakCriticalEdges.cpp b/lib/Transforms/Utils/BreakCriticalEdges.cpp
index 78801db4cd..1a41d95a03 100644
--- a/lib/Transforms/Utils/BreakCriticalEdges.cpp
+++ b/lib/Transforms/Utils/BreakCriticalEdges.cpp
@@ -122,10 +122,10 @@ bool llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P,
BasicBlock *DestBB = TI->getSuccessor(SuccNum);
// Create a new basic block, linking it into the CFG.
- BasicBlock *NewBB = new BasicBlock(TIBB->getName() + "." +
- DestBB->getName() + "_crit_edge");
+ BasicBlock *NewBB = BasicBlock::Create(TIBB->getName() + "." +
+ DestBB->getName() + "_crit_edge");
// Create our unconditional branch...
- new BranchInst(DestBB, NewBB);
+ BranchInst::Create(DestBB, NewBB);
// Branch to the new block, breaking the edge.
TI->setSuccessor(SuccNum, NewBB);
diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp
index 7387144b5e..ba9b57d4f5 100644
--- a/lib/Transforms/Utils/CloneFunction.cpp
+++ b/lib/Transforms/Utils/CloneFunction.cpp
@@ -31,7 +31,7 @@ BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB,
DenseMap<const Value*, Value*> &ValueMap,
const char *NameSuffix, Function *F,
ClonedCodeInfo *CodeInfo) {
- BasicBlock *NewBB = new BasicBlock("", F);
+ BasicBlock *NewBB = BasicBlock::Create("", F);
if (BB->hasName()) NewBB->setName(BB->getName()+NameSuffix);
NewBB->setUnwindDest(const_cast<BasicBlock*>(BB->getUnwindDest()));
@@ -144,7 +144,7 @@ Function *llvm::CloneFunction(const Function *F,
ArgTypes, F->getFunctionType()->isVarArg());
// Create the new function...
- Function *NewF = new Function(FTy, F->getLinkage(), F->getName());
+ Function *NewF = Function::Create(FTy, F->getLinkage(), F->getName());
// Loop over the arguments, copying the names of the mapped arguments over...
Function::arg_iterator DestI = NewF->arg_begin();
@@ -208,7 +208,7 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB,
// Nope, clone it now.
BasicBlock *NewBB;
- BBEntry = NewBB = new BasicBlock();
+ BBEntry = NewBB = BasicBlock::Create();
if (BB->hasName()) NewBB->setName(BB->getName()+NameSuffix);
bool hasCalls = false, hasDynamicAllocas = false, hasStaticAllocas = false;
@@ -253,7 +253,7 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB,
// Constant fold to uncond branch!
if (Cond) {
BasicBlock *Dest = BI->getSuccessor(!Cond->getZExtValue());
- ValueMap[OldTI] = new BranchInst(Dest, NewBB);
+ ValueMap[OldTI] = BranchInst::Create(Dest, NewBB);
ToClone.push_back(Dest);
TerminatorDone = true;
}
@@ -265,7 +265,7 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB,
Cond = dyn_cast_or_null<ConstantInt>(ValueMap[SI->getCondition()]);
if (Cond) { // Constant fold to uncond branch!
BasicBlock *Dest = SI->getSuccessor(SI->findCaseValue(Cond));
- ValueMap[OldTI] = new BranchInst(Dest, NewBB);
+ ValueMap[OldTI] = BranchInst::Create(Dest, NewBB);
ToClone.push_back(Dest);
TerminatorDone = true;
}
diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp
index f0ee1e2ae0..e75f915cb9 100644
--- a/lib/Transforms/Utils/CloneModule.cpp
+++ b/lib/Transforms/Utils/CloneModule.cpp
@@ -63,8 +63,8 @@ Module *llvm::CloneModule(const Module *M,
// Loop over the functions in the module, making external functions as before
for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) {
Function *NF =
- new Function(cast<FunctionType>(I->getType()->getElementType()),
- GlobalValue::ExternalLinkage, I->getName(), New);
+ Function::Create(cast<FunctionType>(I->getType()->getElementType()),
+ GlobalValue::ExternalLinkage, I->getName(), New);
NF->setCallingConv(I->getCallingConv());
NF->setParamAttrs(I->getParamAttrs());
if (I->hasCollector())
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp
index 1be1c729c0..54341196fb 100644
--- a/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/lib/Transforms/Utils/CodeExtractor.cpp
@@ -161,8 +161,8 @@ void CodeExtractor::severSplitPHINodes(BasicBlock *&Header) {
PHINode *PN = cast<PHINode>(AfterPHIs);
// Create a new PHI node in the new region, which has an incoming value
// from OldPred of PN.
- PHINode *NewPN = new PHINode(PN->getType(), PN->getName()+".ce",
- NewBB->begin());
+ PHINode *NewPN = PHINode::Create(PN->getType(), PN->getName()+".ce",
+ NewBB->begin());
NewPN->addIncoming(PN, OldPred);
// Loop over all of the incoming value in PN, moving them to NewPN if they
@@ -280,10 +280,10 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
const FunctionType *funcType = FunctionType::get(RetTy, paramTy, false);
// Create the new function
- Function *newFunction = new Function(funcType,
- GlobalValue::InternalLinkage,
- oldFunction->getName() + "_" +
- header->getName(), M);
+ Function *newFunction = Function::Create(funcType,
+ GlobalValue::InternalLinkage,
+ oldFunction->getName() + "_" +
+ header->getName(), M);
newFunction->getBasicBlockList().push_back(newRootNode);
// Create an iterator to name all of the arguments we inserted.
@@ -299,8 +299,8 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
Idx[1] = ConstantInt::get(Type::Int32Ty, i);
std::string GEPname = "gep_" + inputs[i]->getName();
TerminatorInst *TI = newFunction->begin()->getTerminator();
- GetElementPtrInst *GEP = new GetElementPtrInst(AI, Idx, Idx+2,
- GEPname, TI);
+ GetElementPtrInst *GEP = GetElementPtrInst::Create(AI, Idx, Idx+2,
+ GEPname, TI);
RewriteVal = new LoadInst(GEP, "load" + GEPname, TI);
} else
RewriteVal = AI++;
@@ -386,8 +386,8 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
Idx[0] = Constant::getNullValue(Type::Int32Ty);
Idx[1] = ConstantInt::get(Type::Int32Ty, i);
GetElementPtrInst *GEP =
- new GetElementPtrInst(Struct, Idx, Idx + 2,
- "gep_" + StructValues[i]->getName());
+ GetElementPtrInst::Create(Struct, Idx, Idx + 2,
+ "gep_" + StructValues[i]->getName());
codeReplacer->getInstList().push_back(GEP);
StoreInst *SI = new StoreInst(StructValues[i], GEP);
codeReplacer->getInstList().push_back(SI);
@@ -395,8 +395,8 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
}
// Emit the call to the function
- CallInst *call = new CallInst(newFunction, params.begin(), params.end(),
- NumExitBlocks > 1 ? "targetBlock" : "");
+ CallInst *call = CallInst::Create(newFunction, params.begin(), params.end(),
+ NumExitBlocks > 1 ? "targetBlock" : "");
codeReplacer->getInstList().push_back(call);
Function::arg_iterator OutputArgBegin = newFunction->arg_begin();
@@ -412,8 +412,8 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
Idx[0] = Constant::getNullValue(Type::Int32Ty);
Idx[1] = ConstantInt::get(Type::Int32Ty, FirstOut + i);
GetElementPtrInst *GEP
- = new GetElementPtrInst(Struct, Idx, Idx + 2,
- "gep_reload_" + outputs[i]->getName());
+ = GetElementPtrInst::Create(Struct, Idx, Idx + 2,
+ "gep_reload_" + outputs[i]->getName());
codeReplacer->getInstList().push_back(GEP);
Output = GEP;
} else {
@@ -431,8 +431,8 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
// Now we can emit a switch statement using the call as a value.
SwitchInst *TheSwitch =
- new SwitchInst(ConstantInt::getNullValue(Type::Int16Ty),
- codeReplacer, 0, codeReplacer);
+ SwitchInst::Create(ConstantInt::getNullValue(Type::Int16Ty),
+ codeReplacer, 0, codeReplacer);
// Since there may be multiple exits from the original region, make the new
// function return an unsigned, switch on that number. This loop iterates
@@ -453,8 +453,8 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
if (!NewTarget) {
// If we don't already have an exit stub for this non-extracted
// destination, create one now!
- NewTarget = new BasicBlock(OldTarget->getName() + ".exitStub",
- newFunction);
+ NewTarget = BasicBlock::Create(OldTarget->getName() + ".exitStub",
+ newFunction);
unsigned SuccNum = switchVal++;
Value *brVal = 0;
@@ -469,7 +469,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
break;
}
- ReturnInst *NTRet = new ReturnInst(brVal, NewTarget);
+ ReturnInst *NTRet = ReturnInst::Create(brVal, NewTarget);
// Update the switch instruction.
TheSwitch->addCase(ConstantInt::get(Type::Int16Ty, SuccNum),
@@ -513,9 +513,9 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
Idx[0] = Constant::getNullValue(Type::Int32Ty);
Idx[1] = ConstantInt::get(Type::Int32Ty,FirstOut+out);
GetElementPtrInst *GEP =
- new GetElementPtrInst(OAI, Idx, Idx + 2,
- "gep_" + outputs[out]->getName(),
- NTRet);
+ GetElementPtrInst::Create(OAI, Idx, Idx + 2,
+ "gep_" + outputs[out]->getName(),
+ NTRet);
new StoreInst(outputs[out], GEP, NTRet);
} else {
new StoreInst(outputs[out], OAI, NTRet);
@@ -541,14 +541,14 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
// Check if the function should return a value
if (OldFnRetTy == Type::VoidTy) {
- new ReturnInst(0, TheSwitch); // Return void
+ ReturnInst::Create(0, TheSwitch); // Return void
} else if (OldFnRetTy == TheSwitch->getCondition()->getType()) {
// return what we have
- new ReturnInst(TheSwitch->getCondition(), TheSwitch);
+ ReturnInst::Create(TheSwitch->getCondition(), TheSwitch);
} else {
// Otherwise we must have code extracted an unwind or something, just
// return whatever we want.
- new ReturnInst(Constant::getNullValue(OldFnRetTy), TheSwitch);
+ ReturnInst::Create(Constant::getNullValue(OldFnRetTy), TheSwitch);
}
TheSwitch->getParent()->getInstList().erase(TheSwitch);
@@ -556,12 +556,12 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
case 1:
// Only a single destination, change the switch into an unconditional
// branch.
- new BranchInst(TheSwitch->getSuccessor(1), TheSwitch);
+ BranchInst::Create(TheSwitch->getSuccessor(1), TheSwitch);
TheSwitch->getParent()->getInstList().erase(TheSwitch);
break;
case 2:
- new BranchInst(TheSwitch->getSuccessor(1), TheSwitch->getSuccessor(2),
- call, TheSwitch);
+ BranchInst::Create(TheSwitch->getSuccessor(1), TheSwitch->getSuccessor(2),
+ call, TheSwitch);
TheSwitch->getParent()->getInstList().erase(TheSwitch);
break;
default:
@@ -641,12 +641,12 @@ ExtractCodeRegion(const std::vector<BasicBlock*> &code) {
Function *oldFunction = header->getParent();
// This takes place of the original loop
- BasicBlock *codeReplacer = new BasicBlock("codeRepl", oldFunction, header);
+ BasicBlock *codeReplacer = BasicBlock::Create("codeRepl", oldFunction, header);
// The new function needs a root node because other nodes can branch to the
// head of the region, but the entry node of a function cannot have preds.
- BasicBlock *newFuncRoot = new BasicBlock("newFuncRoot");
- newFuncRoot->getInstList().push_back(new BranchInst(header));
+ BasicBlock *newFuncRoot = BasicBlock::Create("newFuncRoot");
+ newFuncRoot->getInstList().push_back(BranchInst::Create(header));
// Find inputs to, outputs from the code region.
findInputsOutputs(inputs, outputs);
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index 74295cecaa..2e34984564 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -84,9 +84,9 @@ static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock,
// of the old basic block.
SmallVector<Value*, 8> InvokeArgs(CI->op_begin()+1, CI->op_end());
InvokeInst *II =
- new InvokeInst(CI->getCalledValue(), Split, InvokeDest,
- InvokeArgs.begin(), InvokeArgs.end(),
- CI->getName(), BB->getTerminator());
+ InvokeInst::Create(CI->getCalledValue(), Split, InvokeDest,
+ InvokeArgs.begin(), InvokeArgs.end(),
+ CI->getName(), BB->getTerminator());
II->setCallingConv(CI->getCallingConv());
II->setParamAttrs(CI->getParamAttrs());
@@ -116,7 +116,7 @@ static void HandleInlinedInvoke(InvokeInst *II, BasicBlock *FirstNewBlock,
// invoke site. Once this happens, we know that the unwind would cause
// a control transfer to the invoke exception destination, so we can
// transform it into a direct branch to the exception destination.
- new BranchInst(InvokeDest, UI);
+ BranchInst::Create(InvokeDest, UI);
// Delete the unwind instruction!
UI->getParent()->getInstList().pop_back();
@@ -275,7 +275,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
DestCast, SrcCast, Size, ConstantInt::get(Type::Int32Ty, 1)
};
CallInst *TheMemCpy =
- new CallInst(MemCpyFn, CallArgs, CallArgs+4, "", TheCall);
+ CallInst::Create(MemCpyFn, CallArgs, CallArgs+4, "", TheCall);
// If we have a call graph, update it.
if (CG) {
@@ -366,14 +366,14 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
}
// Insert the llvm.stacksave.
- CallInst *SavedPtr = new CallInst(StackSave, "savedstack",
- FirstNewBlock->begin());
+ CallInst *SavedPtr = CallInst::Create(StackSave, "savedstack",
+ FirstNewBlock->begin());
if (CG) CallerNode->addCalledFunction(SavedPtr, StackSaveCGN);
// Insert a call to llvm.stackrestore before any return instructions in the
// inlined function.
for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
- CallInst *CI = new CallInst(StackRestore, SavedPtr, "", Returns[i]);
+ CallInst *CI = CallInst::Create(StackRestore, SavedPtr, "", Returns[i]);
if (CG) CallerNode->addCalledFunction(CI, StackRestoreCGN);
}
@@ -386,7 +386,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
for (Function::iterator BB = FirstNewBlock, E = Caller->end();
BB != E; ++BB)
if (UnwindInst *UI = dyn_cast<UnwindInst>(BB->getTerminator())) {
- new CallInst(StackRestore, SavedPtr, "", UI);
+ CallInst::Create(StackRestore, SavedPtr, "", UI);
++NumStackRestores;
}
}
@@ -428,7 +428,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
BB != E; ++BB) {
TerminatorInst *Term = BB->getTerminator();
if (isa<UnwindInst>(Term)) {
- new BranchInst(UnwindBB, Term);
+ BranchInst::Create(UnwindBB, Term);
BB->getInstList().erase(Term);
}
}
@@ -452,7 +452,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
// If the call site was an invoke instruction, add a branch to the normal
// destination.
if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall))
- new BranchInst(II->getNormalDest(), TheCall);
+ BranchInst::Create(II->getNormalDest(), TheCall);
// If the return instruction returned a value, replace uses of the call with
// uses of the returned value.
@@ -489,7 +489,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
if (InvokeInst *II = dyn_cast<InvokeInst>(TheCall)) {
// Add an unconditional branch to make this look like the CallInst case...
- BranchInst *NewBr = new BranchInst(II->getNormalDest(), TheCall);
+ BranchInst *NewBr = BranchInst::Create(II->getNormalDest(), TheCall);
// Split the basic block. This guarantees that no PHI nodes will have to be
// updated due to new incoming edges, and make the invoke case more
@@ -535,9 +535,9 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
// match corresponding return value operand number.
Instruction *InsertPt = AfterCallBB->begin();
for (unsigned i = 0; i < NumRetVals; ++i) {
- PHINode *PHI = new PHINode(STy->getElementType(i),
- TheCall->getName() + "." + utostr(i),
- InsertPt);
+ PHINode *PHI = PHINode::Create(STy->getElementType(i),
+ TheCall->getName() + "." + utostr(i),
+ InsertPt);
PHIs.push_back(PHI);
}
// TheCall results are used by GetResult instructions.
@@ -547,7 +547,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
GR->eraseFromParent();
}
} else {
- PHINode *PHI = new PHINode(RTy, TheCall->getName(), AfterCallBB->begin());
+ PHINode *PHI = PHINode::Create(RTy, TheCall->getName(), AfterCallBB->begin());
PHIs.push_back(PHI);
// Anything that used the result of the function call should now use the
// PHI node as their operand.
@@ -578,7 +578,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
// Add a branch to the merge points and remove retrun instructions.
for (unsigned i = 0, e = Returns.size(); i != e; ++i) {
ReturnInst *RI = Returns[i];
- new BranchInst(AfterCallBB, RI);
+ BranchInst::Create(AfterCallBB, RI);
RI->eraseFromParent();
}
} else if (!Returns.empty()) {
diff --git a/lib/Transforms/Utils/LCSSA.cpp b/lib/Transforms/Utils/LCSSA.cpp
index 567b23e6ff..a9d1dc40cf 100644
--- a/lib/Transforms/Utils/LCSSA.cpp
+++ b/lib/Transforms/Utils/LCSSA.cpp
@@ -155,8 +155,8 @@ void LCSSA::ProcessInstruction(Instruction *Instr,
DomTreeNode *ExitBBNode = DT->getNode(BB);
Value *&Phi = Phis[ExitBBNode];
if (!Phi && DT->dominates(InstrNode, ExitBBNode)) {
- PHINode *PN = new PHINode(Instr->getType(), Instr->getName()+".lcssa",
- BB->begin());
+ PHINode *PN = PHINode::Create(Instr->getType(), Instr->getName()+".lcssa",
+ BB->begin());
PN->reserveOperandSpace(std::distance(pred_begin(BB), pred_end(BB)));
// Remember that this phi makes the value alive in this block.
@@ -259,8 +259,8 @@ Value *LCSSA::GetValueForBlock(DomTreeNode *BB, Instruction *OrigInst,
// Otherwise, the idom is the loop, so we need to insert a PHI node. Do so
// now, then get values to fill in the incoming values for the PHI.
- PHINode *PN = new PHINode(OrigInst->getType(), OrigInst->getName()+".lcssa",
- BBN->begin());
+ PHINode *PN = PHINode::Create(OrigInst->getType(), OrigInst->getName()+".lcssa",
+ BBN->begin());
PN->reserveOperandSpace(std::distance(pred_begin(BBN), pred_end(BBN)));
V = PN;
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp
index 0d852bb864..0f7d02c888 100644
--- a/lib/Transforms/Utils/Local.cpp
+++ b/lib/Transforms/Utils/Local.cpp
@@ -134,7 +134,7 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB) {
// now.
if (TheOnlyDest) {
// Insert the new branch..
- new BranchInst(TheOnlyDest, SI);
+ BranchInst::Create(TheOnlyDest, SI);
BasicBlock *BB = SI->getParent();
// Remove entries from PHI nodes which we no longer branch to...
@@ -156,7 +156,7 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB) {
Value *Cond = new ICmpInst(ICmpInst::ICMP_EQ, SI->getCondition(),
SI->getSuccessorValue(1), "cond", SI);
// Insert the new branch...
- new BranchInst(SI->getSuccessor(1), SI->getSuccessor(0), Cond, SI);
+ BranchInst::Create(SI->getSuccessor(1), SI->getSuccessor(0), Cond, SI);
// Delete the old switch...
SI->getParent()->getInstList().erase(SI);
diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp
index 16cb30ca9c..e6f5e7c39c 100644
--- a/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/lib/Transforms/Utils/LoopSimplify.cpp
@@ -270,10 +270,10 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB,
const std::vector<BasicBlock*> &Preds) {
// Create new basic block, insert right before the original block...
- BasicBlock *NewBB = new BasicBlock(BB->getName()+Suffix, BB->getParent(), BB);
+ BasicBlock *NewBB = BasicBlock::Create(BB->getName()+Suffix, BB->getParent(), BB);
// The preheader first gets an unconditional branch to the loop header...
- BranchInst *BI = new BranchInst(BB, NewBB);
+ BranchInst *BI = BranchInst::Create(BB, NewBB);
// For every PHI node in the block, insert a PHI node into NewBB where the
// incoming values from the out of loop edges are moved to NewBB. We have two
@@ -300,7 +300,7 @@ BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB,
// If the values coming into the block are not the same, we need a PHI.
if (InVal == 0) {
// Create the new PHI node, insert it into NewBB at the end of the block
- PHINode *NewPHI = new PHINode(PN->getType(), PN->getName()+".ph", BI);
+ PHINode *NewPHI = PHINode::Create(PN->getType(), PN->getName()+".ph", BI);
if (AA) AA->copyValue(PN, NewPHI);
// Move all of the edges from blocks outside the loop to the new PHI
@@ -623,8 +623,8 @@ void LoopSimplify::InsertUniqueBackedgeBlock(Loop *L) {
if (*I != Preheader) BackedgeBlocks.push_back(*I);
// Create and insert the new backedge block...
- BasicBlock *BEBlock = new BasicBlock(Header->getName()+".backedge", F);
- BranchInst *BETerminator = new BranchInst(Header, BEBlock);
+ BasicBlock *BEBlock = BasicBlock::Create(Header->getName()+".backedge", F);
+ BranchInst *BETerminator = BranchInst::Create(Header, BEBlock);
// Move the new backedge block to right after the last backedge block.
Function::iterator InsertPos = BackedgeBlocks.back(); ++InsertPos;
@@ -634,8 +634,8 @@ void LoopSimplify::InsertUniqueBackedgeBlock(Loop *L) {
// the backedge block which correspond to any PHI nodes in the header block.
for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) {
PHINode *PN = cast<PHINode>(I);
- PHINode *NewPN = new PHINode(PN->getType(), PN->getName()+".be",
- BETerminator);
+ PHINode *NewPN = PHINode::Create(PN->getType(), PN->getName()+".be",
+ BETerminator);
NewPN->reserveOperandSpace(BackedgeBlocks.size());
if (AA) AA->copyValue(PN, NewPN);
diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp
index 2f422609fe..8708f994fe 100644
--- a/lib/Transforms/Utils/LowerAllocations.cpp
+++ b/lib/Transforms/Utils/LowerAllocations.cpp
@@ -141,7 +141,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
}
// Create the call to Malloc.
- CallInst *MCall = new CallInst(MallocFunc, MallocArg, "", I);
+ CallInst *MCall = CallInst::Create(MallocFunc, MallocArg, "", I);
MCall->setTailCall();
// Create a cast instruction to convert to the right type...
@@ -162,7 +162,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
PointerType::getUnqual(Type::Int8Ty), "", I);
// Insert a call to the free function...
- (new CallInst(FreeFunc, PtrCast, "", I))->setTailCall();
+ CallInst::Create(FreeFunc, PtrCast, "", I)->setTailCall();
// Delete the old free instruction
I = --BBIL.erase(I);
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index 7f0ef85d75..7f85b10af4 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -211,15 +211,15 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) {
if (InvokeInst *II = dyn_cast<InvokeInst>(BB->getTerminator())) {
std::vector<Value*> CallArgs(II->op_begin()+3, II->op_end());
// Insert a normal call instruction...
- CallInst *NewCall = new CallInst(II->getCalledValue(),
- CallArgs.begin(), CallArgs.end(), "",II);
+ CallInst *NewCall = CallInst::Create(II->getCalledValue(),
+ CallArgs.begin(), CallArgs.end(), "",II);
NewCall->takeName(II);
NewCall->setCallingConv(II->getCallingConv());
NewCall->setParamAttrs(II->getParamAttrs());
II->replaceAllUsesWith(NewCall);
// Insert an unconditional branch to the normal destination.
- new BranchInst(II->getNormalDest(), II);
+ BranchInst::Create(II->getNormalDest(), II);
// Remove any PHI node entries from the exception destination.
II->getUnwindDest()->removePredecessor(BB);
@@ -233,12 +233,12 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) {
writeAbortMessage(UI);
// Insert a call to abort()
- (new CallInst(AbortFn, "", UI))->setTailCall();
+ CallInst::Create(AbortFn, "", UI)->setTailCall();
// Insert a return instruction. This really should be a "barrier", as it
// is unreachable.
- new ReturnInst(F.getReturnType() == Type::VoidTy ? 0 :
- Constant::getNullValue(F.getReturnType()), UI);
+ ReturnInst::Create(F.getReturnType() == Type::VoidTy ? 0 :
+ Constant::getNullValue(F.getReturnType()), UI);
// Remove the unwind instruction now.
BB->getInstList().erase(UI);
@@ -280,16 +280,16 @@ void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo,
// Insert a normal call instruction.
std::vector<Value*> CallArgs(II->op_begin()+3, II->op_end());
- CallInst *NewCall = new CallInst(II->getCalledValue(),
- CallArgs.begin(), CallArgs.end(), "",
- II);
+ CallInst *NewCall = CallInst::Create(II->getCalledValue(),
+ CallArgs.begin(), CallArgs.end(), "",
+ II);
NewCall->takeName(II);
NewCall->setCallingConv(II->getCallingConv());
NewCall->setParamAttrs(II->getParamAttrs());
II->replaceAllUsesWith(NewCall);
// Replace the invoke with an uncond branch.
- new BranchInst(II->getNormalDest(), NewCall->getParent());
+ BranchInst::Create(II->getNormalDest(), NewCall->getParent());
II->eraseFromParent();
}
@@ -463,8 +463,8 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
std::vector<Value*> Idx;
Idx.push_back(Constant::getNullValue(Type::Int32Ty));
Idx.push_back(ConstantInt::get(Type::Int32Ty, 1));
- OldJmpBufPtr = new GetElementPtrInst(JmpBuf, Idx.begin(), Idx.end(),
- "OldBuf", EntryBB->getTerminator());
+ OldJmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(),
+ "OldBuf", EntryBB->getTerminator());
// Copy the JBListHead to the alloca.
Value *OldBuf = new LoadInst(JBListHead, "oldjmpbufptr", true,
@@ -476,7 +476,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
// Create the catch block. The catch block is basically a big switch
// statement that goes to all of the invoke catch blocks.
- BasicBlock *CatchBB = new BasicBlock("setjmp.catch", &F);
+ BasicBlock *CatchBB = BasicBlock::Create("setjmp.catch", &F);
// Create an alloca which keeps track of which invoke is currently
// executing. For normal calls it contains zero.
@@ -488,12 +488,12 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
// Insert a load in the Catch block, and a switch on its value. By default,
// we go to a block that just does an unwind (which is the correct action
// for a standard call).
- BasicBlock *UnwindBB = new BasicBlock("unwindbb", &F);
+ BasicBlock *UnwindBB = BasicBlock::Create("unwindbb", &F);
Unwinds.push_back(new UnwindInst(UnwindBB));
Value *CatchLoad = new LoadInst(InvokeNum, "invoke.num", true, CatchBB);
- SwitchInst *CatchSwitch =
- new SwitchInst(CatchLoad, UnwindBB, Invokes.size(), CatchBB);
+ SwitchInst *CatchSwitch =
+ SwitchInst::Create(CatchLoad, UnwindBB, Invokes.size(), CatchBB);
// Now that things are set up, insert the setjmp call itself.
@@ -502,11 +502,11 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
"setjmp.cont");
Idx[1] = ConstantInt::get(Type::Int32Ty, 0);
- Value *JmpBufPtr = new GetElementPtrInst(JmpBuf, Idx.begin(), Idx.end(),
- "TheJmpBuf",
- EntryBB->getTerminator());
- Value *SJRet = new CallInst(SetJmpFn, JmpBufPtr, "sjret",
- EntryBB->getTerminator());
+ Value *JmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(),
+ "TheJmpBuf",
+ EntryBB->getTerminator());
+ Value *SJRet = CallInst::Create(SetJmpFn, JmpBufPtr, "sjret",
+ EntryBB->getTerminator());
// Compare the return value to zero.
Value *IsNormal = new ICmpInst(ICmpInst::ICMP_EQ, SJRet,
@@ -516,7 +516,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
EntryBB->getTerminator()->eraseFromParent();
// Put in a new condbranch in its place.
- new BranchInst(ContBlock, CatchBB, IsNormal, EntryBB);
+ BranchInst::Create(ContBlock, CatchBB, IsNormal, EntryBB);
// At this point, we are all set up, rewrite each invoke instruction.
for (unsigned i = 0, e = Invokes.size(); i != e; ++i)
@@ -528,9 +528,9 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
// Create three new blocks, the block to load the jmpbuf ptr and compare
// against null, the block to do the longjmp, and the error block for if it
// is null. Add them at the end of the function because they are not hot.
- BasicBlock *UnwindHandler = new BasicBlock("dounwind", &F);
- BasicBlock *UnwindBlock = new BasicBlock("unwind", &F);
- BasicBlock *TermBlock = new BasicBlock("unwinderror", &F);
+ BasicBlock *UnwindHandler = BasicBlock::Create("dounwind", &F);
+ BasicBlock *UnwindBlock = BasicBlock::Create("unwind", &F);
+ BasicBlock *TermBlock = BasicBlock::Create("unwinderror", &F);
// If this function contains an invoke, restore the old jumpbuf ptr.
Value *BufPtr;
@@ -546,17 +546,17 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
Value *NotNull = new ICmpInst(ICmpInst::ICMP_NE, BufPtr,
Constant::getNullValue(BufPtr->getType()),
"notnull", UnwindHandler);
- new BranchInst(UnwindBlock, TermBlock, NotNull, UnwindHandler);
+ BranchInst::Create(UnwindBlock, TermBlock, NotNull, UnwindHandler);
// Create the block to do the longjmp.
// Get a pointer to the jmpbuf and longjmp.
std::vector<Value*> Idx;
I