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 ed9d9309d0..d909d0227c 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 d062297c55..39a1b25725 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 12ce28660c..c966311c9e 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 7d38dc75a1..3bd6bff5d6 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 44c3d78e8f..43054227ae 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 9e069fd05b..beeee4911a 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 48b45351a0..da6f076a9a 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 153f09563d..51e2cd8900 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. |