diff options
author | Owen Anderson <resistor@mac.com> | 2009-07-24 23:12:02 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-07-24 23:12:02 +0000 |
commit | eed707b1e6097aac2bb6b3d47271f6300ace7f2e (patch) | |
tree | c7390f63d90fc0c0ac483a90275863f41b69c085 /lib/Transforms | |
parent | e8530a3d8c940fb7710be7e25098b5c3b2c2de19 (diff) |
Revert the ConstantInt constructors back to their 2.5 forms where possible, thanks to contexts-on-types. More to come.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77011 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
22 files changed, 268 insertions, 270 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index 472f4eaa11..90077cd50b 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -638,9 +638,9 @@ Function *ArgPromotion::DoPromotion(Function *F, // Emit a GEP and load for each element of the struct. const Type *AgTy = cast<PointerType>(I->getType())->getElementType(); const StructType *STy = cast<StructType>(AgTy); - Value *Idxs[2] = { Context.getConstantInt(Type::Int32Ty, 0), 0 }; + Value *Idxs[2] = { ConstantInt::get(Type::Int32Ty, 0), 0 }; for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { - Idxs[1] = Context.getConstantInt(Type::Int32Ty, i); + Idxs[1] = ConstantInt::get(Type::Int32Ty, i); Value *Idx = GetElementPtrInst::Create(*AI, Idxs, Idxs+2, (*AI)->getName()+"."+utostr(i), Call); @@ -665,7 +665,7 @@ Function *ArgPromotion::DoPromotion(Function *F, // Use i32 to index structs, and i64 for others (pointers/arrays). // This satisfies GEP constraints. const Type *IdxTy = (isa<StructType>(ElTy) ? Type::Int32Ty : Type::Int64Ty); - Ops.push_back(Context.getConstantInt(IdxTy, *II)); + Ops.push_back(ConstantInt::get(IdxTy, *II)); // Keep track of the type we're currently indexing ElTy = cast<CompositeType>(ElTy)->getTypeAtIndex(*II); } @@ -758,10 +758,10 @@ Function *ArgPromotion::DoPromotion(Function *F, const Type *AgTy = cast<PointerType>(I->getType())->getElementType(); Value *TheAlloca = new AllocaInst(AgTy, 0, "", InsertPt); const StructType *STy = cast<StructType>(AgTy); - Value *Idxs[2] = { Context.getConstantInt(Type::Int32Ty, 0), 0 }; + Value *Idxs[2] = { ConstantInt::get(Type::Int32Ty, 0), 0 }; for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { - Idxs[1] = Context.getConstantInt(Type::Int32Ty, i); + Idxs[1] = ConstantInt::get(Type::Int32Ty, i); Value *Idx = GetElementPtrInst::Create(TheAlloca, Idxs, Idxs+2, TheAlloca->getName()+"."+utostr(i), diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index b0363d32b1..c16db835d4 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -488,7 +488,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD, const StructLayout &Layout = *TD.getStructLayout(STy); for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { Constant *In = getAggregateConstantElement(Init, - Context.getConstantInt(Type::Int32Ty, i), + ConstantInt::get(Type::Int32Ty, i), Context); assert(In && "Couldn't get element of initializer?"); GlobalVariable *NGV = new GlobalVariable(Context, @@ -523,7 +523,7 @@ static GlobalVariable *SRAGlobal(GlobalVariable *GV, const TargetData &TD, unsigned EltAlign = TD.getABITypeAlignment(STy->getElementType()); for (unsigned i = 0, e = NumElements; i != e; ++i) { Constant *In = getAggregateConstantElement(Init, - Context.getConstantInt(Type::Int32Ty, i), + ConstantInt::get(Type::Int32Ty, i), Context); assert(In && "Couldn't get element of initializer?"); @@ -1508,7 +1508,7 @@ static bool TryToOptimizeStoreOfMallocToGlobal(GlobalVariable *GV, if (const ArrayType *AT = dyn_cast<ArrayType>(MI->getAllocatedType())) { MallocInst *NewMI = new MallocInst(AllocSTy, - Context.getConstantInt(Type::Int32Ty, AT->getNumElements()), + ConstantInt::get(Type::Int32Ty, AT->getNumElements()), "", MI); NewMI->takeName(MI); Value *Cast = new BitCastInst(NewMI, MI->getType(), "tmp", MI); @@ -1605,7 +1605,7 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal, // Only do this if we weren't storing a loaded value. Value *StoreVal; if (StoringOther || SI->getOperand(0) == InitVal) - StoreVal = Context.getConstantInt(Type::Int1Ty, StoringOther); + StoreVal = ConstantInt::get(Type::Int1Ty, StoringOther); else { // Otherwise, we are storing a previously loaded copy. To do this, // change the copy from copying the original value to just copying the @@ -1947,7 +1947,7 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL, LLVMContext &Context) { // If we made a change, reassemble the initializer list. std::vector<Constant*> CSVals; - CSVals.push_back(Context.getConstantInt(Type::Int32Ty, 65535)); + CSVals.push_back(ConstantInt::get(Type::Int32Ty, 65535)); CSVals.push_back(0); // Create the new init list. @@ -1959,7 +1959,7 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL, const Type *FTy = Context.getFunctionType(Type::VoidTy, false); const PointerType *PFTy = Context.getPointerTypeUnqual(FTy); CSVals[1] = Context.getNullValue(PFTy); - CSVals[0] = Context.getConstantInt(Type::Int32Ty, 2147483647); + CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647); } CAList.push_back(Context.getConstantStruct(CSVals)); } diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index e5ac22e8c7..980123af57 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -383,8 +383,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst) new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst); std::vector<Value*> Args = make_vector<Value*>(GetSetJmpMap(Func), BufPtr, - Inst->getContext().getConstantInt(Type::Int32Ty, - SetJmpIDMap[Func]++), 0); + ConstantInt::get(Type::Int32Ty,SetJmpIDMap[Func]++), 0); CallInst::Create(AddSJToMap, Args.begin(), Args.end(), "", Inst); // We are guaranteed that there are no values live across basic blocks @@ -434,9 +433,8 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst) // Add the case for this setjmp's number... SwitchValuePair SVP = GetSJSwitch(Func, GetRethrowBB(Func)); - SVP.first->addCase(Inst->getContext().getConstantInt(Type::Int32Ty, - SetJmpIDMap[Func] - 1), - SetJmpContBlock); + SVP.first->addCase(ConstantInt::get(Type::Int32Ty, SetJmpIDMap[Func] - 1), + SetJmpContBlock); // Value coming from the handling of the exception. PHI->addIncoming(SVP.second, SVP.second->getParent()); diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp index b43ca0a4c5..5e6b71a3e4 100644 --- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp +++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp @@ -55,7 +55,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName, // pass null. Args[2] = Context.getConstantPointerNull(UIntPtr); } - Args[3] = Context.getConstantInt(Type::Int32Ty, NumElements); + Args[3] = ConstantInt::get(Type::Int32Ty, NumElements); Instruction *InitCall = CallInst::Create(InitFn, Args.begin(), Args.end(), "newargc", InsertPos); @@ -111,7 +111,7 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum, // Create the getelementptr constant expression std::vector<Constant*> Indices(2); Indices[0] = Context.getNullValue(Type::Int32Ty); - Indices[1] = Context.getConstantInt(Type::Int32Ty, CounterNum); + Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum); Constant *ElementPtr = Context.getConstantExprGetElementPtr(CounterArray, &Indices[0], Indices.size()); @@ -119,7 +119,7 @@ void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum, // Load, increment and store the value back. Value *OldVal = new LoadInst(ElementPtr, "OldFuncCounter", InsertPos); Value *NewVal = BinaryOperator::Create(Instruction::Add, OldVal, - Context.getConstantInt(Type::Int32Ty, 1), + ConstantInt::get(Type::Int32Ty, 1), "NewFuncCounter", InsertPos); new StoreInst(NewVal, ElementPtr, InsertPos); } diff --git a/lib/Transforms/Instrumentation/RSProfiling.cpp b/lib/Transforms/Instrumentation/RSProfiling.cpp index 05196cd310..30c2dc7162 100644 --- a/lib/Transforms/Instrumentation/RSProfiling.cpp +++ b/lib/Transforms/Instrumentation/RSProfiling.cpp @@ -197,7 +197,7 @@ static void getBackEdges(Function& F, T& BackEdges); GlobalRandomCounter::GlobalRandomCounter(Module& M, const IntegerType* t, uint64_t resetval) : T(t) { - ConstantInt* Init = M.getContext().getConstantInt(T, resetval); + ConstantInt* Init = ConstantInt::get(T, resetval); ResetValue = Init; Counter = new GlobalVariable(M, T, false, GlobalValue::InternalLinkage, Init, "RandomSteeringCounter"); @@ -209,16 +209,15 @@ void GlobalRandomCounter::PrepFunction(Function* F) {} void GlobalRandomCounter::ProcessChoicePoint(BasicBlock* bb) { BranchInst* t = cast<BranchInst>(bb->getTerminator()); - LLVMContext &Context = bb->getContext(); //decrement counter LoadInst* l = new LoadInst(Counter, "counter", t); ICmpInst* s = new ICmpInst(t, ICmpInst::ICMP_EQ, l, - Context.getConstantInt(T, 0), + ConstantInt::get(T, 0), "countercc"); - Value* nv = BinaryOperator::CreateSub(l, Context.getConstantInt(T, 1), + Value* nv = BinaryOperator::CreateSub(l, ConstantInt::get(T, 1), "counternew", t); new StoreInst(nv, Counter, t); t->setCondition(s); @@ -236,7 +235,7 @@ void GlobalRandomCounter::ProcessChoicePoint(BasicBlock* bb) { GlobalRandomCounterOpt::GlobalRandomCounterOpt(Module& M, const IntegerType* t, uint64_t resetval) : AI(0), T(t) { - ConstantInt* Init = M.getContext().getConstantInt(T, resetval); + ConstantInt* Init = ConstantInt::get(T, resetval); ResetValue = Init; Counter = new GlobalVariable(M, T, false, GlobalValue::InternalLinkage, Init, "RandomSteeringCounter"); @@ -283,16 +282,15 @@ void GlobalRandomCounterOpt::PrepFunction(Function* F) { void GlobalRandomCounterOpt::ProcessChoicePoint(BasicBlock* bb) { BranchInst* t = cast<BranchInst>(bb->getTerminator()); - LLVMContext &Context = bb->getContext(); //decrement counter LoadInst* l = new LoadInst(AI, "counter", t); ICmpInst* s = new ICmpInst(t, ICmpInst::ICMP_EQ, l, - Context.getConstantInt(T, 0), + ConstantInt::get(T, 0), "countercc"); - Value* nv = BinaryOperator::CreateSub(l, Context.getConstantInt(T, 1), + Value* nv = BinaryOperator::CreateSub(l, ConstantInt::get(T, 1), "counternew", t); new StoreInst(nv, AI, t); t->setCondition(s); @@ -318,15 +316,14 @@ void CycleCounter::PrepFunction(Function* F) {} void CycleCounter::ProcessChoicePoint(BasicBlock* bb) { BranchInst* t = cast<BranchInst>(bb->getTerminator()); - LLVMContext &Context = bb->getContext(); CallInst* c = CallInst::Create(F, "rdcc", t); BinaryOperator* b = - BinaryOperator::CreateAnd(c, Context.getConstantInt(Type::Int64Ty, rm), + BinaryOperator::CreateAnd(c, ConstantInt::get(Type::Int64Ty, rm), "mrdcc", t); ICmpInst *s = new ICmpInst(t, ICmpInst::ICMP_EQ, b, - Context.getConstantInt(Type::Int64Ty, 0), + ConstantInt::get(Type::Int64Ty, 0), "mrdccc"); t->setCondition(s); @@ -353,7 +350,7 @@ void RSProfilers_std::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNu // Create the getelementptr constant expression std::vector<Constant*> Indices(2); Indices[0] = BB->getContext().getNullValue(Type::Int32Ty); - Indices[1] = BB->getContext().getConstantInt(Type::Int32Ty, CounterNum); + Indices[1] = ConstantInt::get(Type::Int32Ty, CounterNum); Constant *ElementPtr = BB->getContext().getConstantExprGetElementPtr(CounterArray, &Indices[0], 2); @@ -362,7 +359,7 @@ void RSProfilers_std::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNu Value *OldVal = new LoadInst(ElementPtr, "OldCounter", InsertPos); profcode.insert(OldVal); Value *NewVal = BinaryOperator::CreateAdd(OldVal, - BB->getContext().getConstantInt(Type::Int32Ty, 1), + ConstantInt::get(Type::Int32Ty, 1), "NewCounter", InsertPos); profcode.insert(NewVal); profcode.insert(new StoreInst(NewVal, ElementPtr, InsertPos)); @@ -483,7 +480,7 @@ void ProfilerRS::ProcessBackEdge(BasicBlock* src, BasicBlock* dst, Function& F) //b: BranchInst::Create(cast<BasicBlock>(Translate(dst)), bbC); BranchInst::Create(dst, cast<BasicBlock>(Translate(dst)), - F.getContext().getConstantInt(Type::Int1Ty, true), bbCp); + ConstantInt::get(Type::Int1Ty, true), bbCp); //c: { TerminatorInst* iB = src->getTerminator(); @@ -540,8 +537,7 @@ bool ProfilerRS::runOnFunction(Function& F) { ReplaceInstWithInst(T, BranchInst::Create(T->getSuccessor(0), cast<BasicBlock>( Translate(T->getSuccessor(0))), - F.getContext().getConstantInt(Type::Int1Ty, - true))); + ConstantInt::get(Type::Int1Ty, true))); //do whatever is needed now that the function is duplicated c->PrepFunction(&F); diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp index 8c8d26164b..b67bd7f7bf 100644 --- a/lib/Transforms/Scalar/CodeGenPrepare.cpp +++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp @@ -617,7 +617,7 @@ bool CodeGenPrepare::OptimizeMemoryInst(Instruction *MemoryInst, Value *Addr, V = new SExtInst(V, IntPtrTy, "sunkaddr", InsertPt); } if (AddrMode.Scale != 1) - V = BinaryOperator::CreateMul(V, Context.getConstantInt(IntPtrTy, + V = BinaryOperator::CreateMul(V, ConstantInt::get(IntPtrTy, AddrMode.Scale), "sunkaddr", InsertPt); Result = V; @@ -649,7 +649,7 @@ bool CodeGenPrepare::OptimizeMemoryInst(Instruction *MemoryInst, Value *Addr, // Add in the Base Offset if present. if (AddrMode.BaseOffs) { - Value *V = Context.getConstantInt(IntPtrTy, AddrMode.BaseOffs); + Value *V = ConstantInt::get(IntPtrTy, AddrMode.BaseOffs); if (Result) Result = BinaryOperator::CreateAdd(Result, V, "sunkaddr", InsertPt); else diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 66a786287f..1b650ec6dd 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -718,18 +718,18 @@ void IndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PH) { // Insert new integer induction variable. PHINode *NewPHI = PHINode::Create(Type::Int32Ty, PH->getName()+".int", PH); - NewPHI->addIncoming(Context.getConstantInt(Type::Int32Ty, newInitValue), + NewPHI->addIncoming(ConstantInt::get(Type::Int32Ty, newInitValue), PH->getIncomingBlock(IncomingEdge)); Value *NewAdd = BinaryOperator::CreateAdd(NewPHI, - Context.getConstantInt(Type::Int32Ty, + ConstantInt::get(Type::Int32Ty, newIncrValue), Incr->getName()+".int", Incr); NewPHI->addIncoming(NewAdd, PH->getIncomingBlock(BackEdge)); // The back edge is edge 1 of newPHI, whatever it may have been in the // original PHI. - ConstantInt *NewEV = Context.getConstantInt(Type::Int32Ty, intEV); + ConstantInt *NewEV = ConstantInt::get(Type::Int32Ty, intEV); Value *LHS = (EVIndex == 1 ? NewPHI->getIncomingValue(1) : NewEV); Value *RHS = (EVIndex == 1 ? NewEV : NewPHI->getIncomingValue(1)); ICmpInst *NewEC = new ICmpInst(EC->getParent()->getTerminator(), diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 367a4d7af5..4a777b331b 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -599,7 +599,7 @@ static inline Value *dyn_castNotVal(Value *V, LLVMContext *Context) { // Constants can be considered to be not'ed values... if (ConstantInt *C = dyn_cast<ConstantInt>(V)) - return Context->getConstantInt(~C->getValue()); + return ConstantInt::get(*Context, ~C->getValue()); return 0; } @@ -620,7 +620,7 @@ static inline Value *dyn_castFoldableMul(Value *V, ConstantInt *&CST, // The multiplier is really 1 << CST. uint32_t BitWidth = cast<IntegerType>(V->getType())->getBitWidth(); uint32_t CSTVal = CST->getLimitedValue(BitWidth); - CST = Context->getConstantInt(APInt(BitWidth, 1).shl(CSTVal)); + CST = ConstantInt::get(*Context, APInt(BitWidth, 1).shl(CSTVal)); return I->getOperand(0); } } @@ -640,12 +640,12 @@ static User *dyn_castGetElementPtr(Value *V) { /// AddOne - Add one to a ConstantInt static Constant *AddOne(Constant *C, LLVMContext *Context) { return Context->getConstantExprAdd(C, - Context->getConstantInt(C->getType(), 1)); + ConstantInt::get(C->getType(), 1)); } /// SubOne - Subtract one from a ConstantInt static Constant *SubOne(ConstantInt *C, LLVMContext *Context) { return Context->getConstantExprSub(C, - Context->getConstantInt(C->getType(), 1)); + ConstantInt::get(C->getType(), 1)); } /// MultiplyOverflows - True if the multiply can not be expressed in an int /// this size. @@ -692,7 +692,7 @@ static bool ShrinkDemandedConstant(Instruction *I, unsigned OpNo, // This instruction is producing bits that are not demanded. Shrink the RHS. Demanded &= OpC->getValue(); - I->setOperand(OpNo, Context->getConstantInt(Demanded)); + I->setOperand(OpNo, ConstantInt::get(*Context, Demanded)); return true; } @@ -1023,7 +1023,8 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask, if ((DemandedMask & (RHSKnownZero|RHSKnownOne)) == DemandedMask) { // all known if ((RHSKnownOne & LHSKnownOne) == RHSKnownOne) { - Constant *AndC = Context->getConstantInt(~RHSKnownOne & DemandedMask); + Constant *AndC = ConstantInt::get(*Context, + ~RHSKnownOne & DemandedMask); Instruction *And = BinaryOperator::CreateAnd(I->getOperand(0), AndC, "tmp"); return InsertNewInstBefore(And, *I); @@ -1395,10 +1396,10 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask, Instruction *NewVal; if (InputBit > ResultBit) NewVal = BinaryOperator::CreateLShr(I->getOperand(1), - Context->getConstantInt(I->getType(), InputBit-ResultBit)); + ConstantInt::get(I->getType(), InputBit-ResultBit)); else NewVal = BinaryOperator::CreateShl(I->getOperand(1), - Context->getConstantInt(I->getType(), ResultBit-InputBit)); + ConstantInt::get(I->getType(), ResultBit-InputBit)); NewVal->takeName(I); return InsertNewInstBefore(NewVal, *I); } @@ -1415,7 +1416,7 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask, // If the client is only demanding bits that we know, return the known // constant. if ((DemandedMask & (RHSKnownZero|RHSKnownOne)) == DemandedMask) { - Constant *C = Context->getConstantInt(RHSKnownOne); + Constant *C = ConstantInt::get(*Context, RHSKnownOne); if (isa<PointerType>(V->getType())) C = Context->getConstantExprIntToPtr(C, V->getType()); return C; @@ -1602,7 +1603,7 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, if (UndefElts[i]) Elts.push_back(Context->getUndef(Type::Int32Ty)); else - Elts.push_back(Context->getConstantInt(Type::Int32Ty, + Elts.push_back(ConstantInt::get(Type::Int32Ty, Shuffle->getMaskValue(i))); } I->setOperand(2, Context->getConstantVector(Elts)); @@ -1733,9 +1734,9 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, Value *RHS = II->getOperand(2); // Extract the element as scalars. LHS = InsertNewInstBefore(new ExtractElementInst(LHS, - Context->getConstantInt(Type::Int32Ty, 0U, false), "tmp"), *II); + ConstantInt::get(Type::Int32Ty, 0U, false), "tmp"), *II); RHS = InsertNewInstBefore(new ExtractElementInst(RHS, - Context->getConstantInt(Type::Int32Ty, 0U, false), "tmp"), *II); + ConstantInt::get(Type::Int32Ty, 0U, false), "tmp"), *II); switch (II->getIntrinsicID()) { default: llvm_unreachable("Case stmts out of sync!"); @@ -1754,7 +1755,7 @@ Value *InstCombiner::SimplifyDemandedVectorElts(Value *V, APInt DemandedElts, Instruction *New = InsertElementInst::Create( Context->getUndef(II->getType()), TmpV, - Context->getConstantInt(Type::Int32Ty, 0U, false), II->getName()); + ConstantInt::get(Type::Int32Ty, 0U, false), II->getName()); InsertNewInstBefore(New, *II); AddSoonDeadInstToWorklist(*II, 0); return New; @@ -1860,7 +1861,7 @@ struct AddRHS { bool shouldApply(Value *LHS) const { return LHS == RHS; } Instruction *apply(BinaryOperator &Add) const { return BinaryOperator::CreateShl(Add.getOperand(0), - Context->getConstantInt(Add.getType(), 1)); + ConstantInt::get(Add.getType(), 1)); } }; @@ -2543,7 +2544,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) { ConstantInt *C2 = 0; if (dyn_castFoldableMul(Op1I, C2, Context) == Op0) { Constant *CP1 = - Context->getConstantExprSub(Context->getConstantInt(I.getType(), 1), + Context->getConstantExprSub(ConstantInt::get(I.getType(), 1), C2); return BinaryOperator::CreateMul(Op0, CP1); } @@ -2654,7 +2655,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { const APInt& Val = cast<ConstantInt>(CI)->getValue(); if (Val.isPowerOf2()) { // Replace X*(2^C) with X << C return BinaryOperator::CreateShl(Op0, - Context->getConstantInt(Op0->getType(), Val.logBase2())); + ConstantInt::get(Op0->getType(), Val.logBase2())); } } else if (isa<VectorType>(Op1->getType())) { if (Op1->isNullValue()) @@ -2761,7 +2762,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { isSignBitCheck(SCI->getPredicate(), cast<ConstantInt>(SCIOp1), TIS) && TIS) { // Shift the X value right to turn it into "all signbits". - Constant *Amt = Context->getConstantInt(SCIOp0->getType(), + Constant *Amt = ConstantInt::get(SCIOp0->getType(), SCOpTy->getPrimitiveSizeInBits()-1); Value *V = InsertNewInstBefore( @@ -2932,12 +2933,12 @@ Instruction *InstCombiner::commonIDivTransforms(BinaryOperator &I) { // (sdiv X, X) --> 1 (udiv X, X) --> 1 if (Op0 == Op1) { if (const VectorType *Ty = dyn_cast<VectorType>(I.getType())) { - Constant *CI = Context->getConstantInt(Ty->getElementType(), 1); + Constant *CI = ConstantInt::get(Ty->getElementType(), 1); std::vector<Constant*> Elts(Ty->getNumElements(), CI); return ReplaceInstUsesWith(I, Context->getConstantVector(Elts)); } - Constant *CI = Context->getConstantInt(I.getType(), 1); + Constant *CI = ConstantInt::get(I.getType(), 1); return ReplaceInstUsesWith(I, CI); } @@ -3008,7 +3009,7 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) { // if so, convert to a right shift. if (C->getValue().isPowerOf2()) // 0 not included in isPowerOf2 return BinaryOperator::CreateLShr(Op0, - Context->getConstantInt(Op0->getType(), C->getValue().logBase2())); + ConstantInt::get(Op0->getType(), C->getValue().logBase2())); // X udiv C, where C >= signbit if (C->getValue().isNegative()) { @@ -3016,7 +3017,7 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) { ICmpInst::ICMP_ULT, Op0, C), I); return SelectInst::Create(IC, Context->getNullValue(I.getType()), - Context->getConstantInt(I.getType(), 1)); + ConstantInt::get(I.getType(), 1)); } } @@ -3029,7 +3030,7 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) { Value *N = RHSI->getOperand(1); const Type *NTy = N->getType(); if (uint32_t C2 = C1.logBase2()) { - Constant *C2V = Context->getConstantInt(NTy, C2); + Constant *C2V = ConstantInt::get(NTy, C2); N = InsertNewInstBefore(BinaryOperator::CreateAdd(N, C2V, "tmp"), I); } return BinaryOperator::CreateLShr(Op0, N); @@ -3047,13 +3048,13 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) { // Compute the shift amounts uint32_t TSA = TVA.logBase2(), FSA = FVA.logBase2(); // Construct the "on true" case of the select - Constant *TC = Context->getConstantInt(Op0->getType(), TSA); + Constant *TC = ConstantInt::get(Op0->getType(), TSA); Instruction *TSI = BinaryOperator::CreateLShr( Op0, TC, SI->getName()+".t"); TSI = InsertNewInstBefore(TSI, I); // Construct the "on false" case of the select - Constant *FC = Context->getConstantInt(Op0->getType(), FSA); + Constant *FC = ConstantInt::get(Op0->getType(), FSA); Instruction *FSI = BinaryOperator::CreateLShr( Op0, FC, SI->getName()+".f"); FSI = InsertNewInstBefore(FSI, I); @@ -3577,7 +3578,7 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, uint32_t BitWidth = AndRHS->getType()->getBitWidth(); uint32_t OpRHSVal = OpRHS->getLimitedValue(BitWidth); APInt ShlMask(APInt::getHighBitsSet(BitWidth, BitWidth-OpRHSVal)); - ConstantInt *CI = Context->getConstantInt(AndRHS->getValue() & ShlMask); + ConstantInt *CI = ConstantInt::get(*Context, AndRHS->getValue() & ShlMask); if (CI->getValue() == ShlMask) { // Masking out bits that the shift already masks @@ -3597,7 +3598,7 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, uint32_t BitWidth = AndRHS->getType()->getBitWidth(); uint32_t OpRHSVal = OpRHS->getLimitedValue(BitWidth); APInt ShrMask(APInt::getLowBitsSet(BitWidth, BitWidth - OpRHSVal)); - ConstantInt *CI = Context->getConstantInt(AndRHS->getValue() & ShrMask); + ConstantInt *CI = ConstantInt::get(*Context, AndRHS->getValue() & ShrMask); if (CI->getValue() == ShrMask) { // Masking out bits that the shift already masks. @@ -3616,7 +3617,7 @@ Instruction *InstCombiner::OptAndOp(Instruction *Op, uint32_t BitWidth = AndRHS->getType()->getBitWidth(); uint32_t OpRHSVal = OpRHS->getLimitedValue(BitWidth); APInt ShrMask(APInt::getLowBitsSet(BitWidth, BitWidth - OpRHSVal)); - Constant *C = Context->getConstantInt(AndRHS->getValue() & ShrMask); + Constant *C = ConstantInt::get(*Context, AndRHS->getValue() & ShrMask); if (C == AndRHS) { // Masking out bits shifted in. // (Val ashr C1) & C2 -> (Val lshr C1) & C2 // Make the argument unsigned. @@ -3856,7 +3857,7 @@ Instruction *InstCombiner::FoldAndOfICmps(Instruction &I, Val->getName()+".off"); InsertNewInstBefore(Add, I); return new ICmpInst(*Context, ICmpInst::ICMP_UGT, Add, - Context->getConstantInt(Add->getType(), 1)); + ConstantInt::get(Add->getType(), 1)); } break; // (X != 13 & X != 15) -> no change } @@ -4770,7 +4771,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { InsertNewInstBefore(Or, I); Or->takeName(Op0); return BinaryOperator::CreateAnd(Or, - Context->getConstantInt(RHS->getValue() | C1->getValue())); + ConstantInt::get(*Context, RHS->getValue() | C1->getValue())); } // (X ^ C1) | C2 --> (X | C2) ^ (C1&~C2) @@ -4780,7 +4781,7 @@ Instruction *InstCombiner::visitOr(BinaryOperator &I) { InsertNewInstBefore(Or, I); Or->takeName(Op0); return BinaryOperator::CreateXor(Or, - Context->getConstantInt(C1->getValue() & ~RHS->getValue())); + ConstantInt::get(*Context, C1->getValue() & ~RHS->getValue())); } // Try to fold constant and into select arguments. @@ -5107,7 +5108,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { if (Constant *Op0I0C = dyn_cast<Constant>(Op0I->getOperand(0))) { Constant *NegOp0I0C = Context->getConstantExprNeg(Op0I0C); Constant *ConstantRHS = Context->getConstantExprSub(NegOp0I0C, - Context->getConstantInt(I.getType(), 1)); + ConstantInt::get(I.getType(), 1)); return BinaryOperator::CreateAdd(Op0I->getOperand(1), ConstantRHS); } @@ -5118,12 +5119,12 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { Constant *NegOp0CI = Context->getConstantExprNeg(Op0CI); return BinaryOperator::CreateSub( Context->getConstantExprSub(NegOp0CI, - Context->getConstantInt(I.getType(), 1)), + ConstantInt::get(I.getType(), 1)), Op0I->getOperand(0)); } else if (RHS->getValue().isSignBit()) { // (X + C) ^ signbit -> (X + C + signbit) - Constant *C = - Context->getConstantInt(RHS->getValue() + Op0CI->getValue()); + Constant *C = ConstantInt::get(*Context, + RHS->getValue() + Op0CI->getValue()); return BinaryOperator::CreateAdd(Op0I->getOp |