diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-31 20:28:14 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-31 20:28:14 +0000 |
commit | a7235ea7245028a0723e8ab7fd011386b3900777 (patch) | |
tree | 4d702ea3baaaeaeaeb5cf194e266a0911882c613 /lib/Transforms/Utils | |
parent | 2a29899d74476e2a14069af7231ab76d8322a157 (diff) | |
download | external_llvm-a7235ea7245028a0723e8ab7fd011386b3900777.tar.gz external_llvm-a7235ea7245028a0723e8ab7fd011386b3900777.tar.bz2 external_llvm-a7235ea7245028a0723e8ab7fd011386b3900777.zip |
Move a few more APIs back to 2.5 forms. The only remaining ones left to change back are
metadata related, which I'm waiting on to avoid conflicting with Devang.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77721 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r-- | lib/Transforms/Utils/BasicBlockUtils.cpp | 3 | ||||
-rw-r--r-- | lib/Transforms/Utils/CodeExtractor.cpp | 16 | ||||
-rw-r--r-- | lib/Transforms/Utils/LowerAllocations.cpp | 4 | ||||
-rw-r--r-- | lib/Transforms/Utils/LowerInvoke.cpp | 26 |
4 files changed, 17 insertions, 32 deletions
diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp index e6522749bc..4e1015968d 100644 --- a/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -252,8 +252,7 @@ void llvm::RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum) { // Create a value to return... if the function doesn't return null... if (BB->getParent()->getReturnType() != Type::VoidTy) - RetVal = TI->getContext().getNullValue( - BB->getParent()->getReturnType()); + RetVal = Constant::getNullValue(BB->getParent()->getReturnType()); // Create the return... NewTI = ReturnInst::Create(RetVal); diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index d897c2acd1..80da263df5 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -239,8 +239,6 @@ Function *CodeExtractor::constructFunction(const Values &inputs, DOUT << "inputs: " << inputs.size() << "\n"; DOUT << "outputs: " << outputs.size() << "\n"; - LLVMContext &Context = header->getContext(); - // This function returns unsigned, outputs will go back by reference. switch (NumExitBlocks) { case 0: @@ -304,7 +302,7 @@ Function *CodeExtractor::constructFunction(const Values &inputs, Value *RewriteVal; if (AggregateArgs) { Value *Idx[2]; - Idx[0] = Context.getNullValue(Type::Int32Ty); + Idx[0] = Constant::getNullValue(Type::Int32Ty); Idx[1] = ConstantInt::get(Type::Int32Ty, i); TerminatorInst *TI = newFunction->begin()->getTerminator(); GetElementPtrInst *GEP = @@ -352,8 +350,6 @@ Function *CodeExtractor::constructFunction(const Values &inputs, void CodeExtractor:: emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, Values &inputs, Values &outputs) { - LLVMContext &Context = codeReplacer->getContext(); - // Emit a call to the new function, passing in: *pointer to struct (if // aggregating parameters), or plan inputs and allocated memory for outputs std::vector<Value*> params, StructValues, ReloadOutputs; @@ -394,7 +390,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, for (unsigned i = 0, e = inputs.size(); i != e; ++i) { Value *Idx[2]; - Idx[0] = Context.getNullValue(Type::Int32Ty); + Idx[0] = Constant::getNullValue(Type::Int32Ty); Idx[1] = ConstantInt::get(Type::Int32Ty, i); GetElementPtrInst *GEP = GetElementPtrInst::Create(Struct, Idx, Idx + 2, @@ -420,7 +416,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, Value *Output = 0; if (AggregateArgs) { Value *Idx[2]; - Idx[0] = Context.getNullValue(Type::Int32Ty); + Idx[0] = Constant::getNullValue(Type::Int32Ty); Idx[1] = ConstantInt::get(Type::Int32Ty, FirstOut + i); GetElementPtrInst *GEP = GetElementPtrInst::Create(Struct, Idx, Idx + 2, @@ -442,7 +438,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, // Now we can emit a switch statement using the call as a value. SwitchInst *TheSwitch = - SwitchInst::Create(Context.getNullValue(Type::Int16Ty), + SwitchInst::Create(Constant::getNullValue(Type::Int16Ty), codeReplacer, 0, codeReplacer); // Since there may be multiple exits from the original region, make the new @@ -521,7 +517,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, if (DominatesDef) { if (AggregateArgs) { Value *Idx[2]; - Idx[0] = Context.getNullValue(Type::Int32Ty); + Idx[0] = Constant::getNullValue(Type::Int32Ty); Idx[1] = ConstantInt::get(Type::Int32Ty,FirstOut+out); GetElementPtrInst *GEP = GetElementPtrInst::Create(OAI, Idx, Idx + 2, @@ -559,7 +555,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, } else { // Otherwise we must have code extracted an unwind or something, just // return whatever we want. - ReturnInst::Create(Context.getNullValue(OldFnRetTy), TheSwitch); + ReturnInst::Create(Constant::getNullValue(OldFnRetTy), TheSwitch); } TheSwitch->eraseFromParent(); diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index 305897c8ff..ce7b04a497 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/lib/Transforms/Utils/LowerAllocations.cpp @@ -103,8 +103,6 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) { bool Changed = false; assert(MallocFunc && FreeFunc && "Pass not initialized!"); - LLVMContext &Context = BB.getContext(); - BasicBlock::InstListType &BBIL = BB.getInstList(); const TargetData &TD = getAnalysis<TargetData>(); @@ -156,7 +154,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) { if (MCall->getType() != Type::VoidTy) MCast = new BitCastInst(MCall, MI->getType(), "", I); else - MCast = Context.getNullValue(MI->getType()); + MCast = Constant::getNullValue(MI->getType()); // Replace all uses of the old malloc inst with the cast inst MI->replaceAllUsesWith(MCast); diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index a9d218c5fd..4eac467e07 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -115,8 +115,6 @@ FunctionPass *llvm::createLowerInvokePass(const TargetLowering *TLI) { // doInitialization - Make sure that there is a prototype for abort in the // current module. bool LowerInvoke::doInitialization(Module &M) { - LLVMContext &Context = M.getContext(); - const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty); AbortMessage = 0; if (ExpensiveEHSupport) { @@ -143,7 +141,7 @@ bool LowerInvoke::doInitialization(Module &M) { if (!(JBListHead = M.getGlobalVariable("llvm.sjljeh.jblist", PtrJBList))) { JBListHead = new GlobalVariable(M, PtrJBList, false, GlobalValue::LinkOnceAnyLinkage, - Context.getNullValue(PtrJBList), + Constant::getNullValue(PtrJBList), "llvm.sjljeh.jblist"); } @@ -177,8 +175,6 @@ bool LowerInvoke::doInitialization(Module &M) { } void LowerInvoke::createAbortMessage(Module *M) { - LLVMContext &Context = M->getContext(); - if (ExpensiveEHSupport) { // The abort message for expensive EH support tells the user that the // program 'unwound' without an 'invoke' instruction. @@ -189,7 +185,7 @@ void LowerInvoke::createAbortMessage(Module *M) { GlobalVariable *MsgGV = new GlobalVariable(*M, Msg->getType(), true, GlobalValue::InternalLinkage, Msg, "abortmsg"); - std::vector<Constant*> GEPIdx(2, Context.getNullValue(Type::Int32Ty)); + std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::Int32Ty)); AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, &GEPIdx[0], 2); } else { // The abort message for cheap EH support tells the user that EH is not @@ -202,7 +198,7 @@ void LowerInvoke::createAbortMessage(Module *M) { GlobalVariable *MsgGV = new GlobalVariable(*M, Msg->getType(), true, GlobalValue::InternalLinkage, Msg, "abortmsg"); - std::vector<Constant*> GEPIdx(2, Context.getNullValue(Type::Int32Ty)); + std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::Int32Ty)); AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, &GEPIdx[0], 2); } } @@ -223,7 +219,6 @@ void LowerInvoke::writeAbortMessage(Instruction *IB) { } bool LowerInvoke::insertCheapEHSupport(Function &F) { - LLVMContext &Context = F.getContext(); bool Changed = false; for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) if (InvokeInst *II = dyn_cast<InvokeInst>(BB->getTerminator())) { @@ -256,7 +251,7 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) { // Insert a return instruction. This really should be a "barrier", as it // is unreachable. ReturnInst::Create(F.getReturnType() == Type::VoidTy ? 0 : - Context.getNullValue(F.getReturnType()), UI); + Constant::getNullValue(F.getReturnType()), UI); // Remove the unwind instruction now. BB->getInstList().erase(UI); @@ -271,7 +266,6 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) { void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo, AllocaInst *InvokeNum, SwitchInst *CatchSwitch) { - LLVMContext &Context = II->getContext(); ConstantInt *InvokeNoC = ConstantInt::get(Type::Int32Ty, InvokeNo); // If the unwind edge has phi nodes, split the edge. @@ -291,7 +285,7 @@ void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo, BasicBlock::iterator NI = II->getNormalDest()->getFirstNonPHI(); // nonvolatile. - new StoreInst(Context.getNullValue(Type::Int32Ty), InvokeNum, false, NI); + new StoreInst(Constant::getNullValue(Type::Int32Ty), InvokeNum, false, NI); // Add a switch case to our unwind block. CatchSwitch->addCase(InvokeNoC, II->getUnwindDest()); @@ -433,8 +427,6 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { std::vector<UnwindInst*> Unwinds; std::vector<InvokeInst*> Invokes; - LLVMContext &Context = F.getContext(); - for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) if (ReturnInst *RI = dyn_cast<ReturnInst>(BB->getTerminator())) { // Remember all return instructions in case we insert an invoke into this @@ -482,7 +474,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { "jblink", F.begin()->begin()); std::vector<Value*> Idx; - Idx.push_back(Context.getNullValue(Type::Int32Ty)); + Idx.push_back(Constant::getNullValue(Type::Int32Ty)); Idx.push_back(ConstantInt::get(Type::Int32Ty, 1)); OldJmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(), "OldBuf", @@ -535,7 +527,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { // Compare the return value to zero. Value *IsNormal = new ICmpInst(EntryBB->getTerminator(), ICmpInst::ICMP_EQ, SJRet, - Context.getNullValue(SJRet->getType()), + Constant::getNullValue(SJRet->getType()), "notunwind"); // Nuke the uncond branch. EntryBB->getTerminator()->eraseFromParent(); @@ -569,14 +561,14 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) { // Load the JBList, if it's null, then there was no catch! Value *NotNull = new ICmpInst(*UnwindHandler, ICmpInst::ICMP_NE, BufPtr, - Context.getNullValue(BufPtr->getType()), + Constant::getNullValue(BufPtr->getType()), "notnull"); BranchInst::Create(UnwindBlock, TermBlock, NotNull, UnwindHandler); // Create the block to do the longjmp. // Get a pointer to the jmpbuf and longjmp. std::vector<Value*> Idx; - Idx.push_back(Context.getNullValue(Type::Int32Ty)); + Idx.push_back(Constant::getNullValue(Type::Int32Ty)); Idx.push_back(ConstantInt::get(Type::Int32Ty, 0)); Idx[0] = GetElementPtrInst::Create(BufPtr, Idx.begin(), Idx.end(), "JmpBuf", UnwindBlock); |