diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-14 23:09:55 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-14 23:09:55 +0000 |
commit | 9f5b2aa7fba203469386acc413c23dd41a713bc9 (patch) | |
tree | f15d2aa3fea09947494a5d0bb36583dbe3be000a /lib/Transforms | |
parent | a9c6d9a1c4dfea3b5fce0a92297f6fa0a0b4c4f7 (diff) | |
download | external_llvm-9f5b2aa7fba203469386acc413c23dd41a713bc9.zip external_llvm-9f5b2aa7fba203469386acc413c23dd41a713bc9.tar.gz external_llvm-9f5b2aa7fba203469386acc413c23dd41a713bc9.tar.bz2 |
Move EVER MORE stuff over to LLVMContext.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75703 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/IPO/ArgumentPromotion.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 9 | ||||
-rw-r--r-- | lib/Transforms/IPO/IndMemRemoval.cpp | 8 | ||||
-rw-r--r-- | lib/Transforms/IPO/LowerSetJmp.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/IPO/RaiseAllocations.cpp | 3 | ||||
-rw-r--r-- | lib/Transforms/IPO/StructRetPromotion.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Instrumentation/RSProfiling.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 28 | ||||
-rw-r--r-- | lib/Transforms/Scalar/JumpThreading.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/LICM.cpp | 5 | ||||
-rw-r--r-- | lib/Transforms/Scalar/PredicateSimplifier.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/Reg2Mem.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Scalar/ScalarReplAggregates.cpp | 11 | ||||
-rw-r--r-- | lib/Transforms/Scalar/TailDuplication.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Utils/CodeExtractor.cpp | 5 | ||||
-rw-r--r-- | lib/Transforms/Utils/DemoteRegToStack.cpp | 16 | ||||
-rw-r--r-- | lib/Transforms/Utils/InlineFunction.cpp | 5 | ||||
-rw-r--r-- | lib/Transforms/Utils/LowerInvoke.cpp | 24 |
18 files changed, 78 insertions, 56 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index 75a0415..7f1c3cb 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -755,7 +755,7 @@ Function *ArgPromotion::DoPromotion(Function *F, // Just add all the struct element types. const Type *AgTy = cast<PointerType>(I->getType())->getElementType(); - Value *TheAlloca = new AllocaInst(AgTy, 0, "", InsertPt); + Value *TheAlloca = new AllocaInst(*Context, AgTy, 0, "", InsertPt); const StructType *STy = cast<StructType>(AgTy); Value *Idxs[2] = { Context->getConstantInt(Type::Int32Ty, 0), 0 }; diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 398f78a..13fe94a 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -828,7 +828,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV, Type *NewTy = Context->getArrayType(MI->getAllocatedType(), NElements->getZExtValue()); MallocInst *NewMI = - new MallocInst(NewTy, Context->getNullValue(Type::Int32Ty), + new MallocInst(*Context, NewTy, Context->getNullValue(Type::Int32Ty), MI->getAlignment(), MI->getName(), MI); Value* Indices[2]; Indices[0] = Indices[1] = Context->getNullValue(Type::Int32Ty); @@ -1291,7 +1291,7 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI, GV->isThreadLocal()); FieldGlobals.push_back(NGV); - MallocInst *NMI = new MallocInst(FieldTy, MI->getArraySize(), + MallocInst *NMI = new MallocInst(*Context, FieldTy, MI->getArraySize(), MI->getName() + ".f" + utostr(FieldNo),MI); FieldMallocs.push_back(NMI); new StoreInst(NMI, NGV, MI); @@ -1507,7 +1507,7 @@ static bool TryToOptimizeStoreOfMallocToGlobal(GlobalVariable *GV, // structs. malloc [100 x struct],1 -> malloc struct, 100 if (const ArrayType *AT = dyn_cast<ArrayType>(MI->getAllocatedType())) { MallocInst *NewMI = - new MallocInst(AllocSTy, + new MallocInst(*Context, AllocSTy, Context->getConstantInt(Type::Int32Ty, AT->getNumElements()), "", MI); NewMI->takeName(MI); @@ -1703,7 +1703,8 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, Instruction* FirstI = GS.AccessingFunction->getEntryBlock().begin(); const Type* ElemTy = GV->getType()->getElementType(); // FIXME: Pass Global's alignment when globals have alignment - AllocaInst* Alloca = new AllocaInst(ElemTy, NULL, GV->getName(), FirstI); + AllocaInst* Alloca = new AllocaInst(*Context, ElemTy, NULL, + GV->getName(), FirstI); if (!isa<UndefValue>(GV->getInitializer())) new StoreInst(GV->getInitializer(), Alloca, FirstI); diff --git a/lib/Transforms/IPO/IndMemRemoval.cpp b/lib/Transforms/IPO/IndMemRemoval.cpp index b55dea2..d3e609d 100644 --- a/lib/Transforms/IPO/IndMemRemoval.cpp +++ b/lib/Transforms/IPO/IndMemRemoval.cpp @@ -1,4 +1,4 @@ -//===-- IndMemRemoval.cpp - Remove indirect allocations and frees ----------===// +//===-- IndMemRemoval.cpp - Remove indirect allocations and frees ---------===// // // The LLVM Compiler Infrastructure // @@ -10,8 +10,8 @@ // This pass finds places where memory allocation functions may escape into // indirect land. Some transforms are much easier (aka possible) only if free // or malloc are not called indirectly. -// Thus find places where the address of memory functions are taken and construct -// bounce functions with direct calls of those functions. +// Thus find places where the address of memory functions are taken and +// construct bounce functions with direct calls of those functions. // //===----------------------------------------------------------------------===// @@ -73,7 +73,7 @@ bool IndMemRemPass::runOnModule(Module &M) { BasicBlock* bb = BasicBlock::Create("entry",FN); Instruction* c = CastInst::CreateIntegerCast( FN->arg_begin(), Type::Int32Ty, false, "c", bb); - Instruction* a = new MallocInst(Type::Int8Ty, c, "m", bb); + Instruction* a = new MallocInst(*Context, Type::Int8Ty, c, "m", bb); ReturnInst::Create(a, bb); ++NumBounce; NumBounceSites += F->getNumUses(); diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index dfdf5b6..8f5d50d 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -311,7 +311,7 @@ AllocaInst* LowerSetJmp::GetSetJmpMap(Function* Func) // Fill in the alloca and call to initialize the SJ map. const Type *SBPTy = Context->getPointerTypeUnqual(Type::Int8Ty); - AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst); + AllocaInst* Map = new AllocaInst(*Context, SBPTy, 0, "SJMap", Inst); CallInst::Create(InitSJMap, Map, "", Inst); return SJMap[Func] = Map; } @@ -408,7 +408,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst) UI != E; ++UI) if (cast<Instruction>(*UI)->getParent() != ABlock || InstrsAfterCall.count(cast<Instruction>(*UI))) { - DemoteRegToStack(*II); + DemoteRegToStack(*Context, *II); break; } InstrsAfterCall.clear(); diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp index 6c32050..ce976c8 100644 --- a/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/lib/Transforms/IPO/RaiseAllocations.cpp @@ -169,7 +169,8 @@ bool RaiseAllocations::runOnModule(Module &M) { CastInst::CreateIntegerCast(Source, Type::Int32Ty, false/*ZExt*/, "MallocAmtCast", I); - MallocInst *MI = new MallocInst(Type::Int8Ty, Source, "", I); + MallocInst *MI = new MallocInst(*Context, Type::Int8Ty, + Source, "", I); MI->takeName(I); I->replaceAllUsesWith(MI); diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp index 94b37a2..7771bc4 100644 --- a/lib/Transforms/IPO/StructRetPromotion.cpp +++ b/lib/Transforms/IPO/StructRetPromotion.cpp @@ -110,7 +110,7 @@ bool SRETPromotion::PromoteReturn(CallGraphNode *CGN) { DOUT << "SretPromotion: sret argument will be promoted\n"; NumSRET++; // [1] Replace use of sret parameter - AllocaInst *TheAlloca = new AllocaInst (STy, NULL, "mrv", + AllocaInst *TheAlloca = new AllocaInst (*Context, STy, NULL, "mrv", F->getEntryBlock().begin()); Value *NFirstArg = F->arg_begin(); NFirstArg->replaceAllUsesWith(TheAlloca); diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp index 36b4464..ad76ba4 100644 --- a/lib/Transforms/Instrumentation/RSProfiling.cpp +++ b/lib/Transforms/Instrumentation/RSProfiling.cpp @@ -248,7 +248,7 @@ void GlobalRandomCounterOpt::PrepFunction(Function* F) { //make a local temporary to cache the global BasicBlock& bb = F->getEntryBlock(); BasicBlock::iterator InsertPt = bb.begin(); - AI = new AllocaInst(T, 0, "localcounter", InsertPt); + AI = new AllocaInst(*F->getContext(), T, 0, "localcounter", InsertPt); LoadInst* l = new LoadInst(Counter, "counterload", InsertPt); new StoreInst(l, AI, InsertPt); diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index f42827c..4160ee7 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1756,8 +1756,10 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, Value *LHS = II->getOperand(1); Value *RHS = II->getOperand(2); // Extract the element as scalars. - LHS = InsertNewInstBefore(new ExtractElementInst(LHS, 0U,"tmp"), *II); - RHS = InsertNewInstBefore(new ExtractElementInst(RHS, 0U,"tmp"), *II); + LHS = InsertNewInstBefore(new ExtractElementInst(LHS, + Context->getConstantInt(Type::Int32Ty, 0U, false), "tmp"), *II); + RHS = InsertNewInstBefore(new ExtractElementInst(RHS, + Context->getConstantInt(Type::Int32Ty, 0U, false), "tmp"), *II); switch (II->getIntrinsicID()) { default: llvm_unreachable("Case stmts out of sync!"); @@ -1775,7 +1777,8 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, Instruction *New = InsertElementInst::Create( - Context->getUndef(II->getType()), TmpV, 0U, II->getName()); + Context->getUndef(II->getType()), TmpV, + Context->getConstantInt(Type::Int32Ty, 0U, false), II->getName()); InsertNewInstBefore(New, *II); AddSoonDeadInstToWorklist(*II, 0); return New; @@ -7888,9 +7891,9 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI, AllocationInst *New; if (isa<MallocInst>(AI)) - New = new MallocInst(CastElTy, Amt, AI.getAlignment()); + New = new MallocInst(*Context, CastElTy, Amt, AI.getAlignment()); else - New = new AllocaInst(CastElTy, Amt, AI.getAlignment()); + New = new AllocaInst(*Context, CastElTy, Amt, AI.getAlignment()); InsertNewInstBefore(New, AI); New->takeName(&AI); @@ -9974,14 +9977,16 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { if (ExtractedElts[Idx] == 0) { Instruction *Elt = - new ExtractElementInst(Idx < 16 ? Op0 : Op1, Idx&15, "tmp"); + new ExtractElementInst(Idx < 16 ? Op0 : Op1, + Context->getConstantInt(Type::Int32Ty, Idx&15, false), "tmp"); InsertNewInstBefore(Elt, CI); ExtractedElts[Idx] = Elt; } // Insert this value into the result vector. Result = InsertElementInst::Create(Result, ExtractedElts[Idx], - i, "tmp"); + Context->getConstantInt(Type::Int32Ty, i, false), + "tmp"); InsertNewInstBefore(cast<Instruction>(Result), CI); } return CastInst::Create(Instruction::BitCast, Result, CI.getType()); @@ -11363,10 +11368,12 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) { // Create and insert the replacement instruction... if (isa<MallocInst>(AI)) - New = new MallocInst(NewTy, 0, AI.getAlignment(), AI.getName()); + New = new MallocInst(*Context, NewTy, 0, + AI.getAlignment(), AI.getName()); else { assert(isa<AllocaInst>(AI) && "Unknown type of allocation inst!"); - New = new AllocaInst(NewTy, 0, AI.getAlignment(), AI.getName()); + New = new AllocaInst(*Context, NewTy, 0, + AI.getAlignment(), AI.getName()); } InsertNewInstBefore(New, AI); @@ -12475,7 +12482,8 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) { } else { return ReplaceInstUsesWith(EI, Context->getUndef(EI.getType())); } - return new ExtractElementInst(Src, SrcIdx); + return new ExtractElementInst(Src, + Context->getConstantInt(Type::Int32Ty, SrcIdx, false)); } } } diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp index f3536c1..86e03c4 100644 --- a/lib/Transforms/Scalar/JumpThreading.cpp +++ b/lib/Transforms/Scalar/JumpThreading.cpp @@ -912,7 +912,7 @@ bool JumpThreading::ThreadEdge(BasicBlock *BB, BasicBlock *PredBB, // We found a use of I outside of BB. Create a new stack slot to // break this inter-block usage pattern. - DemoteRegToStack(*I); + DemoteRegToStack(*Context, *I); } // We are going to have to map operands from the original BB block to the new diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index 52dd06a..aa49b24 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -508,7 +508,7 @@ void LICM::sink(Instruction &I) { AllocaInst *AI = 0; if (I.getType() != Type::VoidTy) { - AI = new AllocaInst(I.getType(), 0, I.getName(), + AI = new AllocaInst(*Context, I.getType(), 0, I.getName(), I.getParent()->getParent()->getEntryBlock().begin()); CurAST->add(AI); } @@ -853,7 +853,8 @@ void LICM::FindPromotableValuesInLoop( continue; const Type *Ty = cast<PointerType>(V->getType())->getElementType(); - AllocaInst *AI = new AllocaInst(Ty, 0, V->getName()+".tmp", FnStart); + AllocaInst *AI = new AllocaInst(*Context, Ty, 0, + V->getName()+".tmp", FnStart); PromotedValues.push_back(std::make_pair(AI, V)); // Update the AST and alias analysis. diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp index 4116c66..50d6063 100644 --- a/lib/Transforms/Scalar/PredicateSimplifier.cpp +++ b/lib/Transforms/Scalar/PredicateSimplifier.cpp @@ -1891,7 +1891,7 @@ namespace { assert(!Ty->isFPOrFPVector() && "Float in work queue!"); Constant *Zero = Context->getNullValue(Ty); - Constant *One = ConstantInt::get(Ty, 1); + Constant *One = Context->getConstantInt(Ty, 1); ConstantInt *AllOnes = cast<ConstantInt>(Context->getAllOnesValue(Ty)); switch (Opcode) { diff --git a/lib/Transforms/Scalar/Reg2Mem.cpp b/lib/Transforms/Scalar/Reg2Mem.cpp index ac95d25..289f08c 100644 --- a/lib/Transforms/Scalar/Reg2Mem.cpp +++ b/lib/Transforms/Scalar/Reg2Mem.cpp @@ -89,7 +89,7 @@ namespace { NumRegsDemoted += worklist.size(); for (std::list<Instruction*>::iterator ilb = worklist.begin(), ile = worklist.end(); ilb != ile; ++ilb) - DemoteRegToStack(**ilb, false, AllocaInsertionPoint); + DemoteRegToStack(*Context, **ilb, false, AllocaInsertionPoint); worklist.clear(); @@ -105,7 +105,7 @@ namespace { NumPhisDemoted += worklist.size(); for (std::list<Instruction*>::iterator ilb = worklist.begin(), ile = worklist.end(); ilb != ile; ++ilb) - DemotePHIToStack(cast<PHINode>(*ilb), AllocaInsertionPoint); + DemotePHIToStack(*Context, cast<PHINode>(*ilb), AllocaInsertionPoint); return true; } diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 83db90d..d999f9d 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -302,14 +302,16 @@ bool SROA::performScalarRepl(Function &F) { DOUT << "CONVERT TO VECTOR: " << *AI << " TYPE = " << *VectorTy <<"\n"; // Create and insert the vector alloca. - NewAI = new AllocaInst(VectorTy, 0, "", AI->getParent()->begin()); + NewAI = new AllocaInst(*Context, VectorTy, 0, "", + AI->getParent()->begin()); ConvertUsesToScalar(AI, NewAI, 0); } else { DOUT << "CONVERT TO SCALAR INTEGER: " << *AI << "\n"; // Create and insert the integer alloca. const Type *NewTy = Context->getIntegerType(AllocaSize*8); - NewAI = new AllocaInst(NewTy, 0, "", AI->getParent()->begin()); + NewAI = new AllocaInst(*Context, NewTy, 0, "", + AI->getParent()->begin()); ConvertUsesToScalar(AI, NewAI, 0); } NewAI->takeName(AI); @@ -334,7 +336,8 @@ void SROA::DoScalarReplacement(AllocationInst *AI, if (const StructType *ST = dyn_cast<StructType>(AI->getAllocatedType())) { ElementAllocas.reserve(ST->getNumContainedTypes()); for (unsigned i = 0, e = ST->getNumContainedTypes(); i != e; ++i) { - AllocaInst *NA = new AllocaInst(ST->getContainedType(i), 0, + AllocaInst *NA = new AllocaInst(*Context, + ST->getContainedType(i), 0, AI->getAlignment(), AI->getName() + "." + utostr(i), AI); ElementAllocas.push_back(NA); @@ -345,7 +348,7 @@ void SROA::DoScalarReplacement(AllocationInst *AI, ElementAllocas.reserve(AT->getNumElements()); const Type *ElTy = AT->getElementType(); for (unsigned i = 0, e = AT->getNumElements(); i != e; ++i) { - AllocaInst *NA = new AllocaInst(ElTy, 0, AI->getAlignment(), + AllocaInst *NA = new AllocaInst(*Context, ElTy, 0, AI->getAlignment(), AI->getName() + "." + utostr(i), AI); ElementAllocas.push_back(NA); WorkList.push_back(NA); // Add to worklist for recursive processing diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp index 684b0963..5f72210 100644 --- a/lib/Transforms/Scalar/TailDuplication.cpp +++ b/lib/Transforms/Scalar/TailDuplication.cpp @@ -285,7 +285,7 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) { if (I->isUsedOutsideOfBlock(DestBlock)) { // We found a use outside of the tail. Create a new stack slot to // break this inter-block usage pattern. - DemoteRegToStack(*I); + DemoteRegToStack(*Context, *I); } // We are going to have to map operands from the original block B to the new diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index be02560..46e27c8 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -372,7 +372,8 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, StructValues.push_back(*i); } else { AllocaInst *alloca = - new AllocaInst((*i)->getType(), 0, (*i)->getName()+".loc", + new AllocaInst(*codeReplacer->getContext(), + (*i)->getType(), 0, (*i)->getName()+".loc", codeReplacer->getParent()->begin()->begin()); ReloadOutputs.push_back(alloca); params.push_back(alloca); @@ -389,7 +390,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, // Allocate a struct at the beginning of this function Type *StructArgTy = Context->getStructType(ArgTypes); Struct = - new AllocaInst(StructArgTy, 0, "structArg", + new AllocaInst(*codeReplacer->getContext(), StructArgTy, 0, "structArg", codeReplacer->getParent()->begin()->begin()); params.push_back(Struct); diff --git a/lib/Transforms/Utils/DemoteRegToStack.cpp b/lib/Transforms/Utils/DemoteRegToStack.cpp index b8dd754..6cf043b 100644 --- a/lib/Transforms/Utils/DemoteRegToStack.cpp +++ b/lib/Transforms/Utils/DemoteRegToStack.cpp @@ -29,7 +29,8 @@ using namespace llvm; /// invalidating the SSA information for the value. It returns the pointer to /// the alloca inserted to create a stack slot for I. /// -AllocaInst* llvm::DemoteRegToStack(Instruction &I, bool VolatileLoads, +AllocaInst* llvm::DemoteRegToStack(LLVMContext &Context, + Instruction &I, bool VolatileLoads, Instruction *AllocaPoint) { if (I.use_empty()) { I.eraseFromParent(); @@ -39,10 +40,11 @@ AllocaInst* llvm::DemoteRegToStack(Instruction &I, bool VolatileLoads, // Create a stack slot to hold the value. AllocaInst *Slot; if (AllocaPoint) { - Slot = new AllocaInst(I.getType(), 0, I.getName()+".reg2mem", AllocaPoint); + Slot = new AllocaInst(Context, I.getType(), 0, + I.getName()+".reg2mem", AllocaPoint); } else { Function *F = I.getParent()->getParent(); - Slot = new AllocaInst(I.getType(), 0, I.getName()+".reg2mem", + Slot = new AllocaInst(Context, I.getType(), 0, I.getName()+".reg2mem", F->getEntryBlock().begin()); } @@ -107,7 +109,8 @@ AllocaInst* llvm::DemoteRegToStack(Instruction &I, bool VolatileLoads, /// DemotePHIToStack - This function takes a virtual register computed by a phi /// node and replaces it with a slot in the stack frame, allocated via alloca. /// The phi node is deleted and it returns the pointer to the alloca inserted. -AllocaInst* llvm::DemotePHIToStack(PHINode *P, Instruction *AllocaPoint) { +AllocaInst* llvm::DemotePHIToStack(LLVMContext &Context, PHINode *P, + Instruction *AllocaPoint) { if (P->use_empty()) { P->eraseFromParent(); return 0; @@ -116,10 +119,11 @@ AllocaInst* llvm::DemotePHIToStack(PHINode *P, Instruction *AllocaPoint) { // Create a stack slot to hold the value. AllocaInst *Slot; if (AllocaPoint) { - Slot = new AllocaInst(P->getType(), 0, P->getName()+".reg2mem", AllocaPoint); + Slot = new AllocaInst(Context, P->getType(), 0, + P->getName()+".reg2mem", AllocaPoint); } else { Function *F = P->getParent()->getParent(); - Slot = new AllocaInst(P->getType(), 0, P->getName()+".reg2mem", + Slot = new AllocaInst(Context, P->getType(), 0, P->getName()+".reg2mem", F->getEntryBlock().begin()); } diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 0e50cd1..30b1caa 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -309,8 +309,9 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) { // Create the alloca. If we have TargetData, use nice alignment. unsigned Align = 1; if (TD) Align = TD->getPrefTypeAlignment(AggTy); - Value *NewAlloca = new AllocaInst(AggTy, 0, Align, I->getName(), - Caller->begin()->begin()); + Value *NewAlloca = new AllocaInst(*Context, AggTy, 0, Align, + I->getName(), + &*Caller->begin()->begin()); // Emit a memcpy. const Type *Tys[] = { Type::Int64Ty }; Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index 2e13ed3..8ba1439 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -266,7 +266,7 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) { void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo, AllocaInst *InvokeNum, SwitchInst *CatchSwitch) { - ConstantInt *InvokeNoC = ConstantInt::get(Type::Int32Ty, InvokeNo); + ConstantInt *InvokeNoC = Context->getConstantInt(Type::Int32Ty, InvokeNo); // If the unwind edge has phi nodes, split the edge. if (isa<PHINode>(II->getUnwindDest()->begin())) { @@ -417,7 +417,7 @@ splitLiveRangesLiveAcrossInvokes(std::vector<InvokeInst*> &Invokes) { // If we decided we need a spill, do it. if (NeedsSpill) { ++NumSpilled; - DemoteRegToStack(*Inst, true); + DemoteRegToStack(*Context, *Inst, true); } } } @@ -470,13 +470,15 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { // alloca because the value needs to be live across invokes. unsigned Align = TLI ? TLI->getJumpBufAlignment() : 0; AllocaInst *JmpBuf = - new AllocaInst(JBLinkTy, 0, Align, "jblink", F.begin()->begin()); + new AllocaInst(*Context, JBLinkTy, 0, Align, + "jblink", F.begin()->begin()); std::vector<Value*> Idx; Idx.push_back(Context->getNullValue(Type::Int32Ty)); - Idx.push_back(ConstantInt::get(Type::Int32Ty, 1)); + Idx.push_back(Context->getConstantInt(Type::Int32Ty, 1)); OldJmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(), - "OldBuf", EntryBB->getTerminator()); + "OldBuf", + EntryBB->getTerminator()); // Copy the JBListHead to the alloca. Value *OldBuf = new LoadInst(JBListHead, "oldjmpbufptr", true, @@ -492,9 +494,9 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { // Create an alloca which keeps track of which invoke is currently // executing. For normal calls it contains zero. - AllocaInst *InvokeNum = new AllocaInst(Type::Int32Ty, 0, "invokenum", - EntryBB->begin()); - new StoreInst(ConstantInt::get(Type::Int32Ty, 0), InvokeNum, true, + AllocaInst *InvokeNum = new AllocaInst(*Context, Type::Int32Ty, 0, + "invokenum",EntryBB->begin()); + new StoreInst(Context->getConstantInt(Type::Int32Ty, 0), InvokeNum, true, EntryBB->getTerminator()); // Insert a load in the Catch block, and a switch on its value. By default, @@ -513,7 +515,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { BasicBlock *ContBlock = EntryBB->splitBasicBlock(EntryBB->getTerminator(), "setjmp.cont"); - Idx[1] = ConstantInt::get(Type::Int32Ty, 0); + Idx[1] = Context->getConstantInt(Type::Int32Ty, 0); Value *JmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(), "TheJmpBuf", EntryBB->getTerminator()); @@ -567,12 +569,12 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { // Get a pointer to the jmpbuf and longjmp. std::vector<Value*> Idx; Idx.push_back(Context->getNullValue(Type::Int32Ty)); - Idx.push_back(ConstantInt::get(Type::Int32Ty, 0)); + Idx.push_back(Context->getConstantInt(Type::Int32Ty, 0)); Idx[0] = GetElementPtrInst::Create(BufPtr, Idx.begin(), Idx.end(), "JmpBuf", UnwindBlock); Idx[0] = new BitCastInst(Idx[0], PointerType::getUnqual(Type::Int8Ty), "tmp", UnwindBlock); - Idx[1] = ConstantInt::get(Type::Int32Ty, 1); + Idx[1] = Context->getConstantInt(Type::Int32Ty, 1); CallInst::Create(LongJmpFn, Idx.begin(), Idx.end(), "", UnwindBlock); new UnreachableInst(UnwindBlock); |