diff options
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/ADCE.cpp | 6 | ||||
-rw-r--r-- | lib/Transforms/Scalar/GCSE.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/GVN.cpp | 8 | ||||
-rw-r--r-- | lib/Transforms/Scalar/GVNPRE.cpp | 32 | ||||
-rw-r--r-- | lib/Transforms/Scalar/IndVarSimplify.cpp | 10 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 108 | ||||
-rw-r--r-- | lib/Transforms/Scalar/LoopIndexSplit.cpp | 26 | ||||
-rw-r--r-- | lib/Transforms/Scalar/LoopRotation.cpp | 14 | ||||
-rw-r--r-- | lib/Transforms/Scalar/LoopStrengthReduce.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/LoopUnswitch.cpp | 20 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SCCP.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/ScalarReplAggregates.cpp | 38 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SimplifyCFG.cpp | 6 | ||||
-rw-r--r-- | lib/Transforms/Scalar/TailRecursionElimination.cpp | 12 |
14 files changed, 143 insertions, 143 deletions
diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index ed9d930..d909d02 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -163,7 +163,7 @@ bool ADCE::deleteDeadInstructionsInLiveBlock(BasicBlock *BB) { /// successors it goes to. This eliminate a use of the condition as well. /// TerminatorInst *ADCE::convertToUnconditionalBranch(TerminatorInst *TI) { - BranchInst *NB = new BranchInst(TI->getSuccessor(0), TI); + BranchInst *NB = BranchInst::Create(TI->getSuccessor(0), TI); BasicBlock *BB = TI->getParent(); // Remove entries from PHI nodes to avoid confusing ourself later... @@ -325,8 +325,8 @@ bool ADCE::doADCE() { // node as a special case. // if (!AliveBlocks.count(&Func->front())) { - BasicBlock *NewEntry = new BasicBlock(); - new BranchInst(&Func->front(), NewEntry); + BasicBlock *NewEntry = BasicBlock::Create(); + BranchInst::Create(&Func->front(), NewEntry); Func->getBasicBlockList().push_front(NewEntry); AliveBlocks.insert(NewEntry); // This block is always alive! LiveSet.insert(NewEntry->getTerminator()); // The branch is live diff --git a/lib/Transforms/Scalar/GCSE.cpp b/lib/Transforms/Scalar/GCSE.cpp index d062297..39a1b25 100644 --- a/lib/Transforms/Scalar/GCSE.cpp +++ b/lib/Transforms/Scalar/GCSE.cpp @@ -192,7 +192,7 @@ void GCSE::ReplaceInstructionWith(Instruction *I, Value *V) { if (InvokeInst *II = dyn_cast<InvokeInst>(I)) { // Removing an invoke instruction requires adding a branch to the normal // destination and removing PHI node entries in the exception destination. - new BranchInst(II->getNormalDest(), II); + BranchInst::Create(II->getNormalDest(), II); II->getUnwindDest()->removePredecessor(II->getParent()); } diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 12ce286..c966311 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -793,8 +793,8 @@ Value *GVN::GetValueForBlock(BasicBlock *BB, LoadInst* orig, // 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(orig->getType(), orig->getName()+".rle", - BB->begin()); + PHINode *PN = PHINode::Create(orig->getType(), orig->getName()+".rle", + BB->begin()); PN->reserveOperandSpace(std::distance(pred_begin(BB), pred_end(BB))); if (Phis.count(BB) == 0) @@ -1370,7 +1370,7 @@ bool GVN::processStore(StoreInst *SI, SmallVectorImpl<Instruction*> &toErase) { ConstantInt::get(Type::Int64Ty, Range.End-Range.Start), // size ConstantInt::get(Type::Int32Ty, Range.Alignment) // align }; - Value *C = new CallInst(MemSetF, Ops, Ops+4, "", InsertPt); + Value *C = CallInst::Create(MemSetF, Ops, Ops+4, "", InsertPt); DEBUG(cerr << "Replace stores:\n"; for (unsigned i = 0, e = Range.TheStores.size(); i != e; ++i) cerr << *Range.TheStores[i]; @@ -1568,7 +1568,7 @@ bool GVN::processMemCpy(MemCpyInst* M, MemCpyInst* MDep, args.push_back(M->getLength()); args.push_back(M->getAlignment()); - CallInst* C = new CallInst(MemCpyFun, args.begin(), args.end(), "", M); + CallInst* C = CallInst::Create(MemCpyFun, args.begin(), args.end(), "", M); MemoryDependenceAnalysis& MD = getAnalysis<MemoryDependenceAnalysis>(); if (MD.getDependency(C) == MDep) { diff --git a/lib/Transforms/Scalar/GVNPRE.cpp b/lib/Transforms/Scalar/GVNPRE.cpp index 7d38dc7..3bd6bff 100644 --- a/lib/Transforms/Scalar/GVNPRE.cpp +++ b/lib/Transforms/Scalar/GVNPRE.cpp @@ -904,10 +904,10 @@ Value* GVNPRE::phi_translate(Value* V, BasicBlock* pred, BasicBlock* succ) { newVal = new ShuffleVectorInst(newOp1, newOp2, newOp3, S->getName()+".expr"); else if (InsertElementInst* I = dyn_cast<InsertElementInst>(U)) - newVal = new InsertElementInst(newOp1, newOp2, newOp3, - I->getName()+".expr"); + newVal = InsertElementInst::Create(newOp1, newOp2, newOp3, + I->getName()+".expr"); else if (SelectInst* I = dyn_cast<SelectInst>(U)) - newVal = new SelectInst(newOp1, newOp2, newOp3, I->getName()+".expr"); + newVal = SelectInst::Create(newOp1, newOp2, newOp3, I->getName()+".expr"); uint32_t v = VN.lookup_or_add(newVal); @@ -947,9 +947,10 @@ Value* GVNPRE::phi_translate(Value* V, BasicBlock* pred, BasicBlock* succ) { } if (newOp1 != U->getPointerOperand() || changed_idx) { - Instruction* newVal = new GetElementPtrInst(newOp1, - newIdx.begin(), newIdx.end(), - U->getName()+".expr"); + Instruction* newVal = + GetElementPtrInst::Create(newOp1, + newIdx.begin(), newIdx.end(), + U->getName()+".expr"); uint32_t v = VN.lookup_or_add(newVal); @@ -1667,24 +1668,23 @@ void GVNPRE::insertion_pre(Value* e, BasicBlock* BB, newVal = new ShuffleVectorInst(s1, s2, s3, S->getName()+".gvnpre", (*PI)->getTerminator()); else if (InsertElementInst* S = dyn_cast<InsertElementInst>(U)) - newVal = new InsertElementInst(s1, s2, s3, S->getName()+".gvnpre", - (*PI)->getTerminator()); + newVal = InsertElementInst::Create(s1, s2, s3, S->getName()+".gvnpre", + (*PI)->getTerminator()); else if (ExtractElementInst* S = dyn_cast<ExtractElementInst>(U)) newVal = new ExtractElementInst(s1, s2, S->getName()+".gvnpre", (*PI)->getTerminator()); else if (SelectInst* S = dyn_cast<SelectInst>(U)) - newVal = new SelectInst(s1, s2, s3, S->getName()+".gvnpre", - (*PI)->getTerminator()); + newVal = SelectInst::Create(s1, s2, s3, S->getName()+".gvnpre", + (*PI)->getTerminator()); else if (CastInst* C = dyn_cast<CastInst>(U)) newVal = CastInst::create(C->getOpcode(), s1, C->getType(), C->getName()+".gvnpre", (*PI)->getTerminator()); else if (GetElementPtrInst* G = dyn_cast<GetElementPtrInst>(U)) - newVal = new GetElementPtrInst(s1, sVarargs.begin(), sVarargs.end(), - G->getName()+".gvnpre", - (*PI)->getTerminator()); - - + newVal = GetElementPtrInst::Create(s1, sVarargs.begin(), sVarargs.end(), + G->getName()+".gvnpre", + (*PI)->getTerminator()); + VN.add(newVal, VN.lookup(U)); ValueNumberedSet& predAvail = availableOut[*PI]; @@ -1705,7 +1705,7 @@ void GVNPRE::insertion_pre(Value* e, BasicBlock* BB, for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI) { if (p == 0) - p = new PHINode(avail[*PI]->getType(), "gvnpre-join", BB->begin()); + p = PHINode::Create(avail[*PI]->getType(), "gvnpre-join", BB->begin()); p->addIncoming(avail[*PI], *PI); } diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 44c3d78..4305422 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -145,8 +145,8 @@ void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN, Value *AddedVal = GEPI->getOperand(1); // Insert a new integer PHI node into the top of the block. - PHINode *NewPhi = new PHINode(AddedVal->getType(), - PN->getName()+".rec", PN); + PHINode *NewPhi = PHINode::Create(AddedVal->getType(), + PN->getName()+".rec", PN); NewPhi->addIncoming(Constant::getNullValue(NewPhi->getType()), Preheader); // Create the new add instruction. @@ -181,7 +181,7 @@ void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN, Value *Idx[2]; Idx[0] = Constant::getNullValue(Type::Int32Ty); Idx[1] = NewAdd; - GetElementPtrInst *NGEPI = new GetElementPtrInst( + GetElementPtrInst *NGEPI = GetElementPtrInst::Create( NCE, Idx, Idx + 2, GEPI->getName(), GEPI); SE->deleteValueFromRecords(GEPI); @@ -200,8 +200,8 @@ void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN, BasicBlock::iterator InsertPos = PN; ++InsertPos; while (isa<PHINode>(InsertPos)) ++InsertPos; Value *PreInc = - new GetElementPtrInst(PN->getIncomingValue(PreheaderIdx), - NewPhi, "", InsertPos); + GetElementPtrInst::Create(PN->getIncomingValue(PreheaderIdx), + NewPhi, "", InsertPos); PreInc->takeName(PN); PN->replaceAllUsesWith(PreInc); } diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 9e069fd..beeee49 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1811,8 +1811,8 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, uint64_t DemandedElts, } Instruction *New = - new InsertElementInst(UndefValue::get(II->getType()), TmpV, 0U, - II->getName()); + InsertElementInst::Create(UndefValue::get(II->getType()), TmpV, 0U, + II->getName()); InsertNewInstBefore(New, *II); AddSoonDeadInstToWorklist(*II, 0); return New; @@ -2007,8 +2007,8 @@ static Instruction *FoldOpIntoSelect(Instruction &Op, SelectInst *SI, Value *SelectTrueVal = FoldOperationIntoSelectOperand(Op, TV, IC); Value *SelectFalseVal = FoldOperationIntoSelectOperand(Op, FV, IC); - return new SelectInst(SI->getCondition(), SelectTrueVal, - SelectFalseVal); + return SelectInst::Create(SI->getCondition(), SelectTrueVal, + SelectFalseVal); } return 0; } @@ -2048,7 +2048,7 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) { } // Okay, we can do the transformation: create the new PHI node. - PHINode *NewPN = new PHINode(I.getType(), ""); + PHINode *NewPN = PHINode::Create(I.getType(), ""); NewPN->reserveOperandSpace(PN->getNumOperands()/2); InsertNewInstBefore(NewPN, *PN); NewPN->takeName(PN); @@ -2366,7 +2366,7 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { cast<PointerType>(CI->getOperand(0)->getType())->getAddressSpace(); Value *I2 = InsertBitCastBefore(CI->getOperand(0), PointerType::get(Type::Int8Ty, AS), I); - I2 = InsertNewInstBefore(new GetElementPtrInst(I2, Other, "ctg2"), I); + I2 = InsertNewInstBefore(GetElementPtrInst::Create(I2, Other, "ctg2"), I); return new PtrToIntInst(I2, CI->getType()); } } @@ -2388,10 +2388,10 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) { // We check both true and false select arguments for a matching subtract. if (match(FV, m_Zero()) && match(TV, m_Sub(m_Value(N), m_Value(A))) && A == Other) // Fold the add into the true select value. - return new SelectInst(SI->getCondition(), N, A); + return SelectInst::Create(SI->getCondition(), N, A); if (match(TV, m_Zero()) && match(FV, m_Sub(m_Value(N), m_Value(A))) && A == Other) // Fold the add into the false select value. - return new SelectInst(SI->getCondition(), A, N); + return SelectInst::Create(SI->getCondition(), A, N); } } @@ -2875,7 +2875,7 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) { FSI = InsertNewInstBefore(FSI, I); // construct the select instruction and return it. - return new SelectInst(SI->getOperand(0), TSI, FSI, SI->getName()); + return SelectInst::Create(SI->getOperand(0), TSI, FSI, SI->getName()); } } return 0; @@ -3049,7 +3049,7 @@ Instruction *InstCombiner::visitURem(BinaryOperator &I) { BinaryOperator::createAnd(Op0, SubOne(STO), SI->getName()+".t"), I); Value *FalseAnd = InsertNewInstBefore( BinaryOperator::createAnd(Op0, SubOne(SFO), SI->getName()+".f"), I); - return new SelectInst(SI->getOperand(0), TrueAnd, FalseAnd); + return SelectInst::Create(SI->getOperand(0), TrueAnd, FalseAnd); } } } @@ -4021,7 +4021,7 @@ Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) { const Type *Tys[] = { ITy }; Module *M = I.getParent()->getParent()->getParent(); Function *F = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); - return new CallInst(F, V); + return CallInst::Create(F, V); } @@ -4957,7 +4957,7 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) { } if (Op1) - return new SelectInst(LHSI->getOperand(0), Op1, Op2); + return SelectInst::Create(LHSI->getOperand(0), Op1, Op2); break; } } @@ -5257,7 +5257,7 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { } if (Op1) - return new SelectInst(LHSI->getOperand(0), Op1, Op2); + return SelectInst::Create(LHSI->getOperand(0), Op1, Op2); break; } case Instruction::Malloc: @@ -6953,9 +6953,9 @@ Instruction *InstCombiner::commonPointerCastTransforms(CastInst &CI) { // If we were able to index down into an element, create the GEP // and bitcast the result. This eliminates one bitcast, potentially // two. - Instruction *NGEP = new GetElementPtrInst(OrigBase, - NewIndices.begin(), - NewIndices.end(), ""); + Instruction *NGEP = GetElementPtrInst::Create(OrigBase, + NewIndices.begin(), + NewIndices.end(), ""); InsertNewInstBefore(NGEP, CI); NGEP->takeName(GEP); @@ -7517,7 +7517,7 @@ Instruction *InstCombiner::visitIntToPtr(IntToPtrInst &CI) { // If Offset is evenly divisible by Size, we can do this xform. if (Size && !APIntOps::srem(Offset, APInt(Offset.getBitWidth(), Size))){ Offset = APIntOps::sdiv(Offset, APInt(Offset.getBitWidth(), Size)); - return new GetElementPtrInst(X, ConstantInt::get(Offset)); + return GetElementPtrInst::Create(X, ConstantInt::get(Offset)); } } // TODO: Could handle other cases, e.g. where add is indexing into field of @@ -7540,7 +7540,7 @@ Instruction *InstCombiner::visitIntToPtr(IntToPtrInst &CI) { Instruction *P = InsertNewInstBefore(new IntToPtrInst(X, CI.getType(), "tmp"), CI); - return new GetElementPtrInst(P, ConstantInt::get(Offset), "tmp"); + return GetElementPtrInst::Create(P, ConstantInt::get(Offset), "tmp"); } } return 0; @@ -7601,8 +7601,8 @@ Instruction *InstCombiner::visitBitCast(BitCastInst &CI) { // If we found a path from the src to dest, create the getelementptr now. if (SrcElTy == DstElTy) { SmallVector<Value*, 8> Idxs(NumZeros+1, ZeroUInt); - return new GetElementPtrInst(Src, Idxs.begin(), Idxs.end(), "", - ((Instruction*) NULL)); + return GetElementPtrInst::Create(Src, Idxs.begin(), Idxs.end(), "", + ((Instruction*) NULL)); } } @@ -7699,8 +7699,8 @@ Instruction *InstCombiner::FoldSelectOpOp(SelectInst &SI, Instruction *TI, } // Fold this by inserting a select from the input values. - SelectInst *NewSI = new SelectInst(SI.getCondition(), TI->getOperand(0), - FI->getOperand(0), SI.getName()+".v"); + SelectInst *NewSI = SelectInst::Create(SI.getCondition(), TI->getOperand(0), + FI->getOperand(0), SI.getName()+".v"); InsertNewInstBefore(NewSI, SI); return CastInst::create(Instruction::CastOps(TI->getOpcode()), NewSI, TI->getType()); @@ -7740,8 +7740,8 @@ Instruction *InstCombiner::FoldSelectOpOp(SelectInst &SI, Instruction *TI, } // If we reach here, they do have operations in common. - SelectInst *NewSI = new SelectInst(SI.getCondition(), OtherOpT, - OtherOpF, SI.getName()+".v"); + SelectInst *NewSI = SelectInst::Create(SI.getCondition(), OtherOpT, + OtherOpF, SI.getName()+".v"); InsertNewInstBefore(NewSI, SI); if (BinaryOperator *BO = dyn_cast<BinaryOperator>(TI)) { @@ -7990,7 +7990,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { if (AddOp != TI) std::swap(NewTrueOp, NewFalseOp); Instruction *NewSel = - new SelectInst(CondVal, NewTrueOp,NewFalseOp,SI.getName()+".p"); + SelectInst::Create(CondVal, NewTrueOp,NewFalseOp,SI.getName()+".p"); NewSel = InsertNewInstBefore(NewSel, SI); return BinaryOperator::createAdd(SubOp->getOperand(0), NewSel); @@ -8016,7 +8016,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { if (OpToFold) { Constant *C = GetSelectFoldableConstant(TVI); Instruction *NewSel = - new SelectInst(SI.getCondition(), TVI->getOperand(2-OpToFold), C); + SelectInst::Create(SI.getCondition(), TVI->getOperand(2-OpToFold), C); InsertNewInstBefore(NewSel, SI); NewSel->takeName(TVI); if (BinaryOperator *BO = dyn_cast<BinaryOperator>(TVI)) @@ -8041,7 +8041,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { if (OpToFold) { Constant *C = GetSelectFoldableConstant(FVI); Instruction *NewSel = - new SelectInst(SI.getCondition(), C, FVI->getOperand(2-OpToFold)); + SelectInst::Create(SI.getCondition(), C, FVI->getOperand(2-OpToFold)); InsertNewInstBefore(NewSel, SI); NewSel->takeName(FVI); if (BinaryOperator *BO = dyn_cast<BinaryOperator>(FVI)) @@ -8369,7 +8369,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { } // Insert this value into the result vector. - Result = new InsertElementInst(Result, ExtractedElts[Idx], i,"tmp"); + Result = InsertElementInst::Create(Result, ExtractedElts[Idx], i, "tmp"); InsertNewInstBefore(cast<Instruction>(Result), CI); } return CastInst::create(Instruction::BitCast, Result, CI.getType()); @@ -8466,8 +8466,8 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) { if (InvokeInst *II = dyn_cast<InvokeInst>(CS.getInstruction())) { // Don't break the CFG, insert a dummy cond branch. - new BranchInst(II->getNormalDest(), II->getUnwindDest(), - ConstantInt::getTrue(), II); + BranchInst::Create(II->getNormalDest(), II->getUnwindDest(), + ConstantInt::getTrue(), II); } return EraseInstFromFunction(*CS.getInstruction()); } @@ -8678,13 +8678,13 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { Instruction *NC; if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) { - NC = new InvokeInst(Callee, II->getNormalDest(), II->getUnwindDest(), - Args.begin(), Args.end(), Caller->getName(), Caller); + NC = InvokeInst::Create(Callee, II->getNormalDest(), II->getUnwindDest(), + Args.begin(), Args.end(), Caller->getName(), Caller); cast<InvokeInst>(NC)->setCallingConv(II->getCallingConv()); cast<InvokeInst>(NC)->setParamAttrs(NewCallerPAL); } else { - NC = new CallInst(Callee, Args.begin(), Args.end(), - Caller->getName(), Caller); + NC = CallInst::Create(Callee, Args.begin(), Args.end(), + Caller->getName(), Caller); CallInst *CI = cast<CallInst>(Caller); if (CI->isTailCall()) cast<CallInst>(NC)->setTailCall(); @@ -8841,15 +8841,15 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) { Instruction *NewCaller; if (InvokeInst *II = dyn_cast<InvokeInst>(Caller)) { - NewCaller = new InvokeInst(NewCallee, - II->getNormalDest(), II->getUnwindDest(), - NewArgs.begin(), NewArgs.end(), - Caller->getName(), Caller); + NewCaller = InvokeInst::Create(NewCallee, + II->getNormalDest(), II->getUnwindDest(), + NewArgs.begin(), NewArgs.end(), + Caller->getName(), Caller); cast<InvokeInst>(NewCaller)->setCallingConv(II->getCallingConv()); cast<InvokeInst>(NewCaller)->setParamAttrs(NewPAL); } else { - NewCaller = new CallInst(NewCallee, NewArgs.begin(), NewArgs.end(), - Caller->getName(), Caller); + NewCaller = CallInst::Create(NewCallee, NewArgs.begin(), NewArgs.end(), + Caller->getName(), Caller); if (cast<CallInst>(Caller)->isTailCall()) cast<CallInst>(NewCaller)->setTailCall(); cast<CallInst>(NewCaller)-> @@ -8921,7 +8921,7 @@ Instruction *InstCombiner::FoldPHIArgBinOpIntoPHI(PHINode &PN) { Value *InRHS = FirstInst->getOperand(1); PHINode *NewLHS = 0, *NewRHS = 0; if (LHSVal == 0) { - NewLHS = new PHINode(LHSType, FirstInst->getOperand(0)->getName()+".pn"); + NewLHS = PHINode::Create(LHSType, FirstInst->getOperand(0)->getName()+".pn"); NewLHS->reserveOperandSpace(PN.getNumOperands()/2); NewLHS->addIncoming(InLHS, PN.getIncomingBlock(0)); InsertNewInstBefore(NewLHS, PN); @@ -8929,7 +8929,7 @@ Instruction *InstCombiner::FoldPHIArgBinOpIntoPHI(PHINode &PN) { } if (RHSVal == 0) { - NewRHS = new PHINode(RHSType, FirstInst->getOperand(1)->getName()+".pn"); + NewRHS = PHINode::Create(RHSType, FirstInst->getOperand(1)->getName()+".pn"); NewRHS->reserveOperandSpace(PN.getNumOperands()/2); NewRHS->addIncoming(InRHS, PN.getIncomingBlock(0)); InsertNewInstBefore(NewRHS, PN); @@ -8955,7 +8955,7 @@ Instruction *InstCombiner::FoldPHIArgBinOpIntoPHI(PHINode &PN) { RHSVal); else { assert(isa<GetElementPtrInst>(FirstInst)); - return new GetElementPtrInst(LHSVal, RHSVal); + return GetElementPtrInst::Create(LHSVal, RHSVal); } } @@ -9057,8 +9057,8 @@ Instruction *InstCombiner::FoldPHIArgOpIntoPHI(PHINode &PN) { // Okay, they are all the same operation. Create a new PHI node of the // correct type, and PHI together all of the LHS's of the instructions. - PHINode *NewPN = new PHINode(FirstInst->getOperand(0)->getType(), - PN.getName()+".in"); + PHINode *NewPN = PHINode::Create(FirstInst->getOperand(0)->getType(), + PN.getName()+".in"); NewPN->reserveOperandSpace(PN.getNumOperands()/2); Value *InVal = FirstInst->getOperand(0); @@ -9405,8 +9405,8 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { } if (!Indices.empty()) - return new GetElementPtrInst(SrcGEPOperands[0], Indices.begin(), - Indices.end(), GEP.getName()); + return GetElementPtrInst::Create(SrcGEPOperands[0], Indices.begin(), + Indices.end(), GEP.getName()); } else if (GlobalValue *GV = dyn_cast<GlobalValue>(PtrOp)) { // GEP of global variable. If all of the indices for this GEP are @@ -9461,7 +9461,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { Idx[0] = Constant::getNullValue(Type::Int32Ty); Idx[1] = GEP.getOperand(1); Value *V = InsertNewInstBefore( - new GetElementPtrInst(X, Idx, Idx + 2, GEP.getName()), GEP); + GetElementPtrInst::Create(X, Idx, Idx + 2, GEP.getName()), GEP); // V and GEP are both pointer types --> BitCast return new BitCastInst(V, GEP.getType()); } @@ -9519,7 +9519,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { Idx[0] = Constant::getNullValue(Type::Int32Ty); Idx[1] = NewIdx; Instruction *NewGEP = - new GetElementPtrInst(X, Idx, Idx + 2, GEP.getName()); + GetElementPtrInst::Create(X, Idx, Idx + 2, GEP.getName()); NewGEP = InsertNewInstBefore(NewGEP, GEP); // The NewGEP must be pointer typed, so must the old one -> BitCast return new BitCastInst(NewGEP, GEP.getType()); @@ -9562,8 +9562,8 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) { Value *Idx[2]; Idx[0] = NullIdx; Idx[1] = NullIdx; - Value *V = new GetElementPtrInst(New, Idx, Idx + 2, - New->getName()+".sub", It); + Value *V = GetElementPtrInst::Create(New, Idx, Idx + 2, + New->getName()+".sub", It); // Now make everything use the getelementptr instead of the original // allocation. @@ -9874,7 +9874,7 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { SI->getOperand(1)->getName()+".val"), LI); Value *V2 = InsertNewInstBefore(new LoadInst(SI->getOperand(2), SI->getOperand(2)->getName()+".val"), LI); - return new SelectInst(SI->getCondition(), V1, V2); + return SelectInst::Create(SI->getCondition(), V1, V2); } // load (select (cond, null, P)) -> load P @@ -10151,7 +10151,7 @@ bool InstCombiner::SimplifyStoreAtEndOfBlock(StoreInst &SI) { // Insert a PHI node now if we need it. Value *MergedVal = OtherStore->getOperand(0); if (MergedVal != SI.getOperand(0)) { - PHINode *PN = new PHINode(MergedVal->getType(), "storemerge"); + PHINode *PN = PHINode::Create(MergedVal->getType(), "storemerge"); PN->reserveOperandSpace(2); PN->addIncoming(SI.getOperand(0), SI.getParent()); PN->addIncoming(OtherStore->getOperand(0), OtherBB); @@ -10437,7 +10437,7 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) { Value *Ptr = InsertBitCastBefore(I->getOperand(0), PointerType::get(EI.getType(), AS),EI); GetElementPtrInst *GEP = - new GetElementPtrInst(Ptr, EI.getOperand(1), I->getName() + ".gep"); + GetElementPtrInst::Create(Ptr, EI.getOperand(1), I->getName() + ".gep"); InsertNewInstBefore(GEP, EI); return new LoadInst(GEP); } diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp index 48b4535..da6f076 100644 --- a/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp @@ -772,7 +772,7 @@ void LoopIndexSplit::updateLoopBounds(ICmpInst *CI) { "lsplit.add", PHTerminator); Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, A, UB,"lsplit,c", PHTerminator); - NUB = new SelectInst (C, A, UB, "lsplit.nub", PHTerminator); + NUB = SelectInst::Create(C, A, UB, "lsplit.nub", PHTerminator); } // for (i = LB; i <= UB; ++i) @@ -788,7 +788,7 @@ void LoopIndexSplit::updateLoopBounds(ICmpInst *CI) { || ExitCondition->getPredicate() == ICmpInst::ICMP_ULE) { Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, NV, UB, "lsplit.c", PHTerminator); - NUB = new SelectInst (C, NV, UB, "lsplit.nub", PHTerminator); + NUB = SelectInst::Create(C, NV, UB, "lsplit.nub", PHTerminator); } break; case ICmpInst::ICMP_ULT: @@ -806,7 +806,7 @@ void LoopIndexSplit::updateLoopBounds(ICmpInst *CI) { || ExitCondition->getPredicate() == ICmpInst::ICMP_ULT) { Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, NV, UB, "lsplit.c", PHTerminator); - NUB = new SelectInst (C, NV, UB, "lsplit.nub", PHTerminator); + NUB = SelectInst::Create(C, NV, UB, "lsplit.nub", PHTerminator); } // for (i = LB; i <= UB; ++i) @@ -824,7 +824,7 @@ void LoopIndexSplit::updateLoopBounds(ICmpInst *CI) { "lsplit.add", PHTerminator); Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, S, UB, "lsplit.c", PHTerminator); - NUB = new SelectInst (C, S, UB, "lsplit.nub", PHTerminator); + NUB = SelectInst::Create(C, S, UB, "lsplit.nub", PHTerminator); } break; case ICmpInst::ICMP_UGE: @@ -841,7 +841,7 @@ void LoopIndexSplit::updateLoopBounds(ICmpInst *CI) { { Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, NV, StartValue, "lsplit.c", PHTerminator); - NLB = new SelectInst (C, StartValue, NV, "lsplit.nlb", PHTerminator); + NLB = SelectInst::Create(C, StartValue, NV, "lsplit.nlb", PHTerminator); } break; case ICmpInst::ICMP_UGT: @@ -860,7 +860,7 @@ void LoopIndexSplit::updateLoopBounds(ICmpInst *CI) { "lsplit.add", PHTerminator); Value *C = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, A, StartValue, "lsplit.c", PHTerminator); - NLB = new SelectInst (C, StartValue, A, "lsplit.nlb", PHTerminator); + NLB = SelectInst::Create(C, StartValue, A, "lsplit.nlb", PHTerminator); } break; default: @@ -1356,16 +1356,16 @@ void LoopIndexSplit::calculateLoopBounds(SplitInfo &SD) { ExitCondition->getOperand(ExitValueNum), "lsplit.ev", InsertPt); - SD.A_ExitValue = new SelectInst(C1, AEV, - ExitCondition->getOperand(ExitValueNum), - "lsplit.ev", InsertPt); + SD.A_ExitValue = SelectInst::Create(C1, AEV, + ExitCondition->getOperand(ExitValueNum), + "lsplit.ev", InsertPt); Value *C2 = new ICmpInst(Sign ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT, BSV, StartValue, "lsplit.sv", PHTerminator); - SD.B_StartValue = new SelectInst(C2, StartValue, BSV, - "lsplit.sv", PHTerminator); + SD.B_StartValue = SelectInst::Create(C2, StartValue, BSV, + "lsplit.sv", PHTerminator); } /// splitLoop - Split current loop L in two loops using split information @@ -1508,7 +1508,7 @@ bool LoopIndexSplit::splitLoop(SplitInfo &SD) { BI != BE; ++BI) { if (PHINode *PN = dyn_cast<PHINode>(BI)) { Value *V1 = PN->getIncomingValueForBlock(A_ExitBlock); - PHINode *newPHI = new PHINode(PN->getType(), PN->getName()); + PHINode *newPHI = PHINode::Create(PN->getType(), PN->getName()); newPHI->addIncoming(V1, A_ExitingBlock); A_ExitBlock->getInstList().push_front(newPHI); PN->removeIncomingValue(A_ExitBlock); @@ -1598,7 +1598,7 @@ void LoopIndexSplit::moveExitCondition(BasicBlock *CondBB, BasicBlock *ActiveBB, CurrentBR->eraseFromParent(); // Connect exiting block to original destination. - new BranchInst(OrigDestBB, ExitingBB); + BranchInst::Create(OrigDestBB, ExitingBB); // Update PHINodes updatePHINodes(ExitBB, ExitingBB, CondBB, IV, IVAdd, LP); diff --git a/lib/Transforms/Scalar/LoopRotation.cpp b/lib/Transforms/Scalar/LoopRotation.cpp index 153f095..51e2cd8 100644 --- a/lib/Transforms/Scalar/LoopRotation.cpp +++ b/lib/Transforms/Scalar/LoopRotation.cpp @@ -208,7 +208,7 @@ bool LoopRotate::rotateLoop(Loop *Lp, LPPassManager &LPM) { // Create new PHI node with two incoming values for NewHeader. // One incoming value is from OrigLatch (through OrigHeader) and // second incoming value is from original pre-header. - PHINode *NH = new PHINode(In->getType(), In->getName()); + PHINode *NH = PHINode::Create(In->getType(), In->getName()); NH->addIncoming(PN->getIncomingValueForBlock(OrigLatch), OrigHeader); NH->addIncoming(NPV, OrigPreHeader); NewHeader->getInstList().push_front(NH); @@ -249,7 +249,7 @@ bool LoopRotate::rotateLoop(Loop *Lp, LPPassManager &LPM) { // create new PHINode for this instruction. Instruction *NewHeaderReplacement = NULL; if (usedOutsideOriginalHeader(In)) { - PHINode *PN = new PHINode(In->getType(), In->getName()); + PHINode *PN = PHINode::Create(In->getType(), In->getName()); PN->addIncoming(In, OrigHeader); PN->addIncoming(C, OrigPreHeader); NewHeader->getInstList().push_front(PN); @@ -336,7 +336,7 @@ bool LoopRotate::rotateLoop(Loop *Lp, LPPassManager &LPM) { } else { // Used outside Exit block. Create a new PHI node from exit block // to receive value from ne new header ane pre header. - PHINode *PN = new PHINode(U->getType(), U->getName()); + PHINode *PN = PHINode::Create(U->getType(), U->getName()); PN->addIncoming(ILoopHeaderInfo.PreHeader, OrigPreHeader); PN->addIncoming(OldPhi, OrigHeader); Exit->getInstList().push_front(PN); @@ -447,12 +447,12 @@ void LoopRotate::preserveCanonicalLoopForm(LPPassManager &LPM) { // Right now original pre-header has two successors, new header and // exit block. Insert new block between original pre-header and // new header such that loop's new pre-header has only one successor. - BasicBlock *NewPreHeader = new BasicBlock("bb.nph", OrigHeader->getParent(), - NewHeader); + BasicBlock *NewPreHeader = BasicBlock::Create("bb.nph", OrigHeader->getParent(), + NewHeader); LoopInfo &LI = LPM.getAnalysis<LoopInfo>(); if (Loop *PL = LI.getLoopFor(OrigPreHeader)) PL->addBasicBlockToLoop(NewPreHeader, LI.getBase()); - new BranchInst(NewHeader, NewPreHeader); + BranchInst::Create(NewHeader, NewPreHeader); BranchInst *OrigPH_BI = cast<BranchInst>(OrigPreHeader->getTerminator()); if (OrigPH_BI->getSuccessor(0) == NewHeader) @@ -560,7 +560,7 @@ void LoopRotate::preserveCanonicalLoopForm(LPPassManager &LPM) { BasicBlock::iterator I = Exit->begin(), E = Exit->end(); PHINode *PN = NULL; for (; (PN = dyn_cast<PHINode>(I)); ++I) { - PHINode *NewPN = new PHINode(PN->getType(), PN->getName()); + PHINode *NewPN = PHINode::Create(PN->getType(), PN->getName()); unsigned N = PN->getNumIncomingValues(); for (unsigned index = 0; index < N; ++index) if (PN->getIncomingBlock(index) == NExit) { diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index c6f02e8..fbed3b3 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -1271,7 +1271,7 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride, if (RewriteFactor == 0) { // Create a new Phi for this base, and stick it in the loop header. - NewPHI = new PHINode(ReplacedTy, "iv.", PhiInsertBefore); + NewPHI = PHINode::Create(ReplacedTy, "iv.", PhiInsertBefore); ++NumInserted; // Add common base to the new Phi node. diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 966038d..58a2fe0 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -568,7 +568,7 @@ void LoopUnswitch::EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val, std::swap(TrueDest, FalseDest); // Insert the new branch. - new BranchInst(TrueDest, FalseDest, BranchVal, InsertPt); + BranchInst::Create(TrueDest, FalseDest, BranchVal, InsertPt); } @@ -673,9 +673,9 @@ void LoopUnswitch::SplitExitEdges(Loop *L, const SmallVector<BasicBlock *, 8> &E for (BasicBlock::iterator I = EndBlock->begin(); (OldLCSSA = dyn_cast<PHINode>(I)); ++I) { Value* OldValue = OldLCSSA->getIncomingValueForBlock(MiddleBlock); - PHINode* NewLCSSA = new PHINode(OldLCSSA->getType(), - OldLCSSA->getName() + ".us-lcssa", - MiddleBlock->getTerminator()); + PHINode* NewLCSSA = PHINode::Create(OldLCSSA->getType(), + OldLCSSA->getName() + ".us-lcssa", + MiddleBlock->getTerminator()); NewLCSSA->addIncoming(OldValue, StartBlock); OldLCSSA->setIncomingValue(OldLCSSA->getBasicBlockIndex(MiddleBlock), NewLCSSA); @@ -687,9 +687,9 @@ void LoopUnswitch::SplitExitEdges(Loop *L, const SmallVector<BasicBlock *, 8> &E for (BasicBlock::iterator I = MiddleBlock->begin(); (OldLCSSA = dyn_cast<PHINode>(I)) && InsertedPHIs.count(OldLCSSA) == 0; ++I) { - PHINode *NewLCSSA = new PHINode(OldLCSSA->getType(), - OldLCSSA->getName() + ".us-lcssa", - InsertPt); + PHINode *NewLCSSA = PHINode::Create(OldLCSSA->getType(), + OldLCSSA->getName() + ".us-lcssa", + InsertPt); OldLCSSA->replaceAllUsesWith(NewLCSSA); NewLCSSA->addIncoming(OldLCSSA, MiddleBlock); } @@ -1155,8 +1155,8 @@ void LoopUnswitch::RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC, BasicBlock* Split = SplitBlock(Old, SI, this); Instruction* OldTerm = Old->getTerminator(); - new BranchInst(Split, SI->getSuccessor(i), - ConstantInt::getTrue(), OldTerm); + BranchInst::Create(Split, SI->getSuccessor(i), + ConstantInt::getTrue(), OldTerm); LPM->deleteSimpleAnalysisValue(Old->getTerminator(), L); Old->getTerminator()->eraseFromParent(); @@ -1295,7 +1295,7 @@ void LoopUnswitch::SimplifyCode(std::vector<Instruction*> &Worklist, Loop *L) { BasicBlock *DeadSucc = BI->getSuccessor(CB->getZExtValue()); BasicBlock *LiveSucc = BI->getSuccessor(!CB->getZExtValue()); DeadSucc->removePredecessor(BI->getParent(), true); - Worklist.push_back(new BranchInst(LiveSucc, BI)); + Worklist.push_back(BranchInst::Create(LiveSucc, BI)); LPM->deleteSimpleAnalysisValue(BI, L); BI->eraseFromParent(); RemoveFromWorklist(BI, Worklist); diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index a178507..0fd9316 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -1740,7 +1740,7 @@ bool IPSCCP::runOnModule(Module &M) { // Make this an uncond branch to the first successor. TerminatorInst *TI = I->getParent()->getTerminator(); - new BranchInst(TI->getSuccessor(0), TI); + BranchInst::Create(TI->getSuccessor(0), TI); // Remove entries in successor phi nodes to remove edges. for (unsigned i = 1, e = TI->getNumSuccessors(); i != e; ++i) diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 2977afa..51aad84 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -323,8 +323,8 @@ void SROA::DoScalarReplacement(AllocationInst *AI, SmallVector<Value*, 8> NewArgs; NewArgs.push_back(Constant::getNullValue(Type::Int32Ty)); NewArgs.append(GEPI->op_begin()+3, GEPI->op_end()); - RepValue = new GetElementPtrInst(AllocaToUse, NewArgs.begin(), - NewArgs.end(), "", GEPI); + RepValue = GetElementPtrInst::Create(AllocaToUse, NewArgs.begin(), + NewArgs.end(), "", GEPI); RepValue->takeName(GEPI); } @@ -634,9 +634,9 @@ void SROA::RewriteBitCastUserOfAlloca(Instruction *BCInst, AllocationInst *AI, Value *Idx[2]; Idx[0] = Zero; Idx[1] = ConstantInt::get(Type::Int32Ty, i); - OtherElt = new GetElementPtrInst(OtherPtr, Idx, Idx + 2, - OtherPtr->getNameStr()+"."+utostr(i), - MI); + OtherElt = GetElementPtrInst::Create(OtherPtr, Idx, Idx + 2, + OtherPtr->getNameStr()+"."+utostr(i), + MI); } Value *EltPtr = NewElts[i]; @@ -716,7 +716,7 @@ void SROA::RewriteBitCastUserOfAlloca(Instruction *BCInst, AllocationInst *AI, ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size Zero // Align }; - new CallInst(TheFn, Ops, Ops + 4, "", MI); + CallInst::Create(TheFn, Ops, Ops + 4, "", MI); } else { assert(isa<MemSetInst>(MI)); Value *Ops[] = { @@ -724,7 +724,7 @@ void SROA::RewriteBitCastUserOfAlloca(Instruction *BCInst, AllocationInst *AI, ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size Zero // Align }; - new CallInst(TheFn, Ops, Ops + 4, "", MI); + CallInst::Create(TheFn, Ops, Ops + 4, "", MI); } } @@ -838,22 +838,22 @@ void SROA::CanonicalizeAllocaUsers(AllocationInst *AI) { // Insert the new GEP instructions, which are properly indexed. SmallVector<Value*, 8> Indices(GEPI->op_begin()+1, GEPI->op_end()); Indices[1] = Constant::getNullValue(Type::Int32Ty); - Value *ZeroIdx = new GetElementPtrInst(GEPI->getOperand(0), - Indices.begin(), - Indices.end(), - GEPI->getName()+".0", GEPI); + Value *ZeroIdx = GetElementPtrInst::Create(GEPI->getOperand(0), + Indices.begin(), + Indices.end(), + GEPI->getName()+".0", GEPI); Indices[1] = ConstantInt::get(Type::Int32Ty, 1); - Value *OneIdx = new GetElementPtrInst(GEPI->getOperand(0), - Indices.begin(), - Indices.end(), - GEPI->getName()+".1", GEPI); + Value *OneIdx = GetElementPtrInst::Create(GEPI->getOperand(0), + Indices.begin(), + Indices.end(), + GEPI->getName()+".1", GEPI); // Replace all loads of the variable index GEP with loads from both // indexes and a select. while (!GEPI->use_empty()) { LoadInst *LI = cast<LoadInst>(GEPI->use_back()); Value *Zero = new LoadInst(ZeroIdx, LI->getName()+".0", LI); Value *One = new LoadInst(OneIdx , LI->getName()+".1", LI); - Value *R = new SelectInst(IsOne, One, Zero, LI->getName(), LI); + Value *R = SelectInst::Create(IsOne, One, Zero, LI->getName(), LI); LI->replaceAllUsesWith(R); LI->eraseFromParent(); } @@ -1261,9 +1261,9 @@ Value *SROA::ConvertUsesOfStoreToScalar(StoreInst *SI, AllocaInst *NewAI, // Must be an element insertion. const TargetData &TD = getAnalysis<TargetData>(); unsigned Elt = Offset/TD.getABITypeSizeInBits(PTy->getElementType()); - SV = new InsertElementInst(Old, SV, - ConstantInt::get(Type::Int32Ty, Elt), - "tmp", SI); + SV = InsertElementInst::Create(Old, SV, + ConstantInt::get(Type::Int32Ty, Elt), + "tmp", SI); } } else if (isa<PointerType>(AllocaType)) { // If the alloca type is a pointer, then all the elements must be diff --git a/lib/Transforms/Scalar/SimplifyCFG.cpp b/lib/Transforms/Scalar/SimplifyCFG.cpp index 5cb2b40..48342bd 100644 --- a/lib/Transforms/Scalar/SimplifyCFG.cpp +++ b/lib/Transforms/Scalar/SimplifyCFG.cpp @@ -78,15 +78,15 @@ static void ChangeToUnreachable(Instruction *I) { static void ChangeToCall(InvokeInst *II) { BasicBlock *BB = II->getParent(); SmallVector<Value*, 8> Args(II->op_begin()+3, II->op_end()); - CallInst *NewCall = new CallInst(II->getCalledValue(), Args.begin(), - Args.end(), "", II); + CallInst *NewCall = CallInst::Create(II->getCalledValue(), Args.begin(), + Args.end(), "", II); NewCall->takeName(II); NewCall->setCallingConv(II->getCallingConv()); NewCall->setParamAttrs(II->getParamAttrs()); II->replaceAllUsesWith(NewCall); // Follow the call by a branch to the normal destination. - new BranchInst(II->getNormalDest(), II); + BranchInst::Create(II->getNormalDest(), II); // Update PHI nodes in the unwind destination II->getUnwindDest()->removePredecessor(BB); diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp index d1320c9..78b088a 100644 --- a/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -377,10 +377,10 @@ bool TailCallElim::ProcessReturningBlock(ReturnInst *Ret, BasicBlock *&OldEntry, // create the new entry block, allowing us to branch back to the old entry. if (OldEntry == 0) { OldEntry = &F->getEntryBlock(); - BasicBlock *NewEntry = new BasicBlock("", F, OldEntry); + BasicBlock *NewEntry = BasicBlock::Create("", F, OldEntry); NewEntry->takeName(OldEntry); OldEntry->setName("tailrecurse"); - new BranchInst(OldEntry, NewEntry); + BranchInst::Create(OldEntry, NewEntry); // If this tail call is marked 'tail' and if there are any allocas in the // entry block, move them up to the new entry block. @@ -400,7 +400,7 @@ bool TailCallElim::ProcessReturningBlock(ReturnInst *Ret, BasicBlock *&OldEntry, Instruction *InsertPos = OldEntry->begin(); for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I) { - PHINode *PN = new PHINode(I->getType(), I->getName()+".tr", InsertPos); + PHINode *PN = PHINode::Create(I->getType(), I->getName()+".tr", InsertPos); I->replaceAllUsesWith(PN); // Everyone use the PHI node now! PN->addIncoming(I, NewEntry); ArgumentPHIs.push_back(PN); @@ -430,8 +430,8 @@ bool TailCallElim::ProcessReturningBlock(ReturnInst *Ret, BasicBlock *&OldEntry, if (AccumulatorRecursionEliminationInitVal) { Instruction *AccRecInstr = AccumulatorRecursionInstr; // Start by inserting a new PHI node for the accumulator. - PHINode *AccPN = new PHINode(AccRecInstr->getType(), "accumulator.tr", - OldEntry->begin()); + PHINode *AccPN = PHINode::Create(AccRecInstr->getType(), "accumulator.tr", + OldEntry->begin()); // Loop over all of the predecessors of the tail recursion block. For the // real entry into the function we seed the PHI with the initial value, @@ -467,7 +467,7 @@ bool TailCallElim::ProcessReturningBlock(ReturnInst *Ret, BasicBlock *&OldEntry, // Now that all of the PHI nodes are in place, remove the call and // ret instructions, replacing them with an unconditional branch. - new BranchInst(OldEntry, Ret); + BranchInst::Create(OldEntry, Ret); BB->getInstList().erase(Ret); // Remove return. BB->getInstList().erase(CI); // Remove call. ++NumEliminated; |