summaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-07-29 22:17:13 +0000
committerOwen Anderson <resistor@mac.com>2009-07-29 22:17:13 +0000
commitdebcb01b0f0a15f568ca69e8f288fade4bfc7297 (patch)
tree22a274838cf6c55205a8a3f0a80262b09b63b069 /lib/Transforms
parent37c4a2d6f15ff32c9ae91e333d655a349e195993 (diff)
downloadllvm-debcb01b0f0a15f568ca69e8f288fade4bfc7297.tar.gz
llvm-debcb01b0f0a15f568ca69e8f288fade4bfc7297.tar.bz2
llvm-debcb01b0f0a15f568ca69e8f288fade4bfc7297.tar.xz
Move types back to the 2.5 API.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77516 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp2
-rw-r--r--lib/Transforms/IPO/DeadArgumentElimination.cpp7
-rw-r--r--lib/Transforms/IPO/ExtractGV.cpp4
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp10
-rw-r--r--lib/Transforms/IPO/LowerSetJmp.cpp11
-rw-r--r--lib/Transforms/IPO/RaiseAllocations.cpp18
-rw-r--r--lib/Transforms/IPO/StructRetPromotion.cpp3
-rw-r--r--lib/Transforms/Instrumentation/BlockProfiling.cpp4
-rw-r--r--lib/Transforms/Instrumentation/EdgeProfiling.cpp2
-rw-r--r--lib/Transforms/Instrumentation/ProfilingUtils.cpp4
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp35
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp2
-rw-r--r--lib/Transforms/Scalar/MemCpyOptimizer.cpp3
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp27
-rw-r--r--lib/Transforms/Scalar/SimplifyLibCalls.cpp40
-rw-r--r--lib/Transforms/Utils/CloneFunction.cpp3
-rw-r--r--lib/Transforms/Utils/CodeExtractor.cpp9
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp2
-rw-r--r--lib/Transforms/Utils/LowerAllocations.cpp6
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp12
20 files changed, 97 insertions, 107 deletions
diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp
index cb5787b6bd..5cf3a9b6fd 100644
--- a/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -588,7 +588,7 @@ Function *ArgPromotion::DoPromotion(Function *F,
}
// Construct the new function type using the new arguments.
- FunctionType *NFTy = Context.getFunctionType(RetTy, Params, FTy->isVarArg());
+ FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
// Create the new function body and insert it into the module...
Function *NF = Function::Create(NFTy, F->getLinkage(), F->getName());
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 63210487c8..0b7e9d9874 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -197,10 +197,9 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
// Start by computing a new prototype for the function, which is the same as
// the old function, but doesn't have isVarArg set.
const FunctionType *FTy = Fn.getFunctionType();
- LLVMContext &Context = FTy->getContext();
std::vector<const Type*> Params(FTy->param_begin(), FTy->param_end());
- FunctionType *NFTy = Context.getFunctionType(FTy->getReturnType(),
+ FunctionType *NFTy = FunctionType::get(FTy->getReturnType(),
Params, false);
unsigned NumArgs = Params.size();
@@ -641,7 +640,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// something and {} into void.
// Make the new struct packed if we used to return a packed struct
// already.
- NRetTy = Context.getStructType(RetTypes, STy->isPacked());
+ NRetTy = StructType::get(RetTypes, STy->isPacked());
else if (RetTypes.size() == 1)
// One return type? Just a simple value then, but only if we didn't use to
// return a struct with that simple value before.
@@ -709,7 +708,7 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
}
// Create the new function type based on the recomputed parameters.
- FunctionType *NFTy = Context.getFunctionType(NRetTy, Params,
+ FunctionType *NFTy = FunctionType::get(NRetTy, Params,
FTy->isVarArg());
// No change?
diff --git a/lib/Transforms/IPO/ExtractGV.cpp b/lib/Transforms/IPO/ExtractGV.cpp
index 9c28fdbe64..dfbad61cf5 100644
--- a/lib/Transforms/IPO/ExtractGV.cpp
+++ b/lib/Transforms/IPO/ExtractGV.cpp
@@ -103,13 +103,13 @@ namespace {
// by putting them in the used array
{
std::vector<Constant *> AUGs;
- const Type *SBP= Context.getPointerTypeUnqual(Type::Int8Ty);
+ const Type *SBP= PointerType::getUnqual(Type::Int8Ty);
for (std::vector<GlobalValue*>::iterator GI = Named.begin(),
GE = Named.end(); GI != GE; ++GI) {
(*GI)->setLinkage(GlobalValue::ExternalLinkage);
AUGs.push_back(ConstantExpr::getBitCast(*GI, SBP));
}
- ArrayType *AT = Context.getArrayType(SBP, AUGs.size());
+ ArrayType *AT = ArrayType::get(SBP, AUGs.size());
Constant *Init = ConstantArray::get(AT, AUGs);
GlobalValue *gv = new GlobalVariable(M, AT, false,
GlobalValue::AppendingLinkage,
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 5be3239a63..61e4316a61 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -826,7 +826,7 @@ static GlobalVariable *OptimizeGlobalAddressOfMalloc(GlobalVariable *GV,
if (NElements->getZExtValue() != 1) {
// If we have an array allocation, transform it to a single element
// allocation to make the code below simpler.
- Type *NewTy = Context.getArrayType(MI->getAllocatedType(),
+ Type *NewTy = ArrayType::get(MI->getAllocatedType(),
NElements->getZExtValue());
MallocInst *NewMI =
new MallocInst(NewTy, Context.getNullValue(Type::Int32Ty),
@@ -1161,7 +1161,7 @@ static Value *GetHeapSROAValue(Value *V, unsigned FieldNo,
cast<StructType>(cast<PointerType>(PN->getType())->getElementType());
Result =
- PHINode::Create(Context.getPointerTypeUnqual(ST->getElementType(FieldNo)),
+ PHINode::Create(PointerType::getUnqual(ST->getElementType(FieldNo)),
PN->getName()+".f"+utostr(FieldNo), PN);
PHIsToRewrite.push_back(std::make_pair(PN, FieldNo));
} else {
@@ -1282,7 +1282,7 @@ static GlobalVariable *PerformHeapAllocSRoA(GlobalVariable *GV, MallocInst *MI,
for (unsigned FieldNo = 0, e = STy->getNumElements(); FieldNo != e;++FieldNo){
const Type *FieldTy = STy->getElementType(FieldNo);
- const Type *PFieldTy = Context.getPointerTypeUnqual(FieldTy);
+ const Type *PFieldTy = PointerType::getUnqual(FieldTy);
GlobalVariable *NGV =
new GlobalVariable(*GV->getParent(),
@@ -1957,8 +1957,8 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL,
if (Ctors[i]) {
CSVals[1] = Ctors[i];
} else {
- const Type *FTy = Context.getFunctionType(Type::VoidTy, false);
- const PointerType *PFTy = Context.getPointerTypeUnqual(FTy);
+ const Type *FTy = FunctionType::get(Type::VoidTy, false);
+ const PointerType *PFTy = PointerType::getUnqual(FTy);
CSVals[1] = Context.getNullValue(PFTy);
CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647);
}
diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp
index 980123af57..d2837a30ed 100644
--- a/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/lib/Transforms/IPO/LowerSetJmp.cpp
@@ -201,9 +201,8 @@ bool LowerSetJmp::runOnModule(Module& M) {
// This function is always successful, unless it isn't.
bool LowerSetJmp::doInitialization(Module& M)
{
- LLVMContext &Context = M.getContext();
- const Type *SBPTy = Context.getPointerTypeUnqual(Type::Int8Ty);
- const Type *SBPPTy = Context.getPointerTypeUnqual(SBPTy);
+ const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
+ const Type *SBPPTy = PointerType::getUnqual(SBPTy);
// N.B. See llvm/runtime/GCCLibraries/libexception/SJLJ-Exception.h for
// a description of the following library functions.
@@ -259,7 +258,7 @@ bool LowerSetJmp::IsTransformableFunction(const std::string& Name) {
// throwing the exception for us.
void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
{
- const Type* SBPTy = Inst->getContext().getPointerTypeUnqual(Type::Int8Ty);
+ const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty);
// Create the call to "__llvm_sjljeh_throw_longjmp". This takes the
// same parameters as "longjmp", except that the buffer is cast to a
@@ -312,7 +311,7 @@ AllocaInst* LowerSetJmp::GetSetJmpMap(Function* Func)
assert(Inst && "Couldn't find even ONE instruction in entry block!");
// Fill in the alloca and call to initialize the SJ map.
- const Type *SBPTy = Func->getContext().getPointerTypeUnqual(Type::Int8Ty);
+ const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst);
CallInst::Create(InitSJMap, Map, "", Inst);
return SJMap[Func] = Map;
@@ -378,7 +377,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst)
Function* Func = ABlock->getParent();
// Add this setjmp to the setjmp map.
- const Type* SBPTy = Inst->getContext().getPointerTypeUnqual(Type::Int8Ty);
+ const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty);
CastInst* BufPtr =
new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst);
std::vector<Value*> Args =
diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp
index 3c9178ed0a..943d3cf160 100644
--- a/lib/Transforms/IPO/RaiseAllocations.cpp
+++ b/lib/Transforms/IPO/RaiseAllocations.cpp
@@ -70,8 +70,6 @@ ModulePass *llvm::createRaiseAllocationsPass() {
// function into the appropriate instruction.
//
void RaiseAllocations::doInitialization(Module &M) {
- LLVMContext &Context = M.getContext();
-
// Get Malloc and free prototypes if they exist!
MallocFunc = M.getFunction("malloc");
if (MallocFunc) {
@@ -79,7 +77,7 @@ void RaiseAllocations::doInitialization(Module &M) {
// Get the expected prototype for malloc
const FunctionType *Malloc1Type =
- Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty),
+ FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
std::vector<const Type*>(1, Type::Int64Ty), false);
// Chck to see if we got the expected malloc
@@ -87,14 +85,14 @@ void RaiseAllocations::doInitialization(Module &M) {
// Check to see if the prototype is wrong, giving us i8*(i32) * malloc
// This handles the common declaration of: 'void *malloc(unsigned);'
const FunctionType *Malloc2Type =
- Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty),
+ FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
std::vector<const Type*>(1, Type::Int32Ty), false);
if (TyWeHave != Malloc2Type) {
// Check to see if the prototype is missing, giving us
// i8*(...) * malloc
// This handles the common declaration of: 'void *malloc();'
const FunctionType *Malloc3Type =
- Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty),
+ FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
true);
if (TyWeHave != Malloc3Type)
// Give up
@@ -108,21 +106,21 @@ void RaiseAllocations::doInitialization(Module &M) {
const FunctionType* TyWeHave = FreeFunc->getFunctionType();
// Get the expected prototype for void free(i8*)
- const FunctionType *Free1Type = Context.getFunctionType(Type::VoidTy,
- std::vector<const Type*>(1, Context.getPointerTypeUnqual(Type::Int8Ty)),
+ const FunctionType *Free1Type = FunctionType::get(Type::VoidTy,
+ std::vector<const Type*>(1, PointerType::getUnqual(Type::Int8Ty)),
false);
if (TyWeHave != Free1Type) {
// Check to see if the prototype was forgotten, giving us
// void (...) * free
// This handles the common forward declaration of: 'void free();'
- const FunctionType* Free2Type = Context.getFunctionType(Type::VoidTy,
+ const FunctionType* Free2Type = FunctionType::get(Type::VoidTy,
true);
if (TyWeHave != Free2Type) {
// One last try, check to see if we can find free as
// int (...)* free. This handles the case where NOTHING was declared.
- const FunctionType* Free3Type = Context.getFunctionType(Type::Int32Ty,
+ const FunctionType* Free3Type = FunctionType::get(Type::Int32Ty,
true);
if (TyWeHave != Free3Type) {
@@ -224,7 +222,7 @@ bool RaiseAllocations::runOnModule(Module &M) {
Value *Source = *CS.arg_begin();
if (!isa<PointerType>(Source->getType()))
Source = new IntToPtrInst(Source,
- Context.getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
"FreePtrCast", I);
new FreeInst(Source, I);
diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp
index 8d6671dbb7..a2413597a3 100644
--- a/lib/Transforms/IPO/StructRetPromotion.cpp
+++ b/lib/Transforms/IPO/StructRetPromotion.cpp
@@ -232,8 +232,7 @@ Function *SRETPromotion::cloneFunctionBody(Function *F,
AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));
- FunctionType *NFTy =
- F->getContext().getFunctionType(STy, Params, FTy->isVarArg());
+ FunctionType *NFTy = FunctionType::get(STy, Params, FTy->isVarArg());
Function *NF = Function::Create(NFTy, F->getLinkage());
NF->takeName(F);
NF->copyAttributesFrom(F);
diff --git a/lib/Transforms/Instrumentation/BlockProfiling.cpp b/lib/Transforms/Instrumentation/BlockProfiling.cpp
index 065bd1125d..700260db46 100644
--- a/lib/Transforms/Instrumentation/BlockProfiling.cpp
+++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp
@@ -63,7 +63,7 @@ bool FunctionProfiler::runOnModule(Module &M) {
if (!I->isDeclaration())
++NumFunctions;
- const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumFunctions);
+ const Type *ATy = ArrayType::get(Type::Int32Ty, NumFunctions);
GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
M.getContext().getNullValue(ATy), "FuncProfCounters");
@@ -108,7 +108,7 @@ bool BlockProfiler::runOnModule(Module &M) {
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
NumBlocks += I->size();
- const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumBlocks);
+ const Type *ATy = ArrayType::get(Type::Int32Ty, NumBlocks);
GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
M.getContext().getNullValue(ATy), "BlockProfCounters");
diff --git a/lib/Transforms/Instrumentation/EdgeProfiling.cpp b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
index d1aa370187..b900945dac 100644
--- a/lib/Transforms/Instrumentation/EdgeProfiling.cpp
+++ b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
@@ -64,7 +64,7 @@ bool EdgeProfiler::runOnModule(Module &M) {
NumEdges += BB->getTerminator()->getNumSuccessors();
}
- const Type *ATy = M.getContext().getArrayType(Type::Int32Ty, NumEdges);
+ const Type *ATy = ArrayType::get(Type::Int32Ty, NumEdges);
GlobalVariable *Counters =
new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
M.getContext().getNullValue(ATy), "EdgeProfCounters");
diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp
index 70ce86a2c3..d5752b72d2 100644
--- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp
+++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp
@@ -25,8 +25,8 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
GlobalValue *Array) {
LLVMContext &Context = MainFn->getContext();
const Type *ArgVTy =
- Context.getPointerTypeUnqual(Context.getPointerTypeUnqual(Type::Int8Ty));
- const PointerType *UIntPtr = Context.getPointerTypeUnqual(Type::Int32Ty);
+ PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty));
+ const PointerType *UIntPtr = PointerType::getUnqual(Type::Int32Ty);
Module &M = *MainFn->getParent();
Constant *InitFn = M.getOrInsertFunction(FnName, Type::Int32Ty, Type::Int32Ty,
ArgVTy, UIntPtr, Type::Int32Ty,
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 63dddaeee1..554591ac25 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -7681,7 +7681,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
case 32 :
case 64 :
case 128:
- SExtType = Context->getIntegerType(Ty->getBitWidth() - ShiftAmt1);
+ SExtType = IntegerType::get(Ty->getBitWidth() - ShiftAmt1);
break;
default: break;
}
@@ -9697,7 +9697,7 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
// Use an integer load+store unless we can find something better.
Type *NewPtrTy =
- Context->getPointerTypeUnqual(Context->getIntegerType(Size<<3));
+ PointerType::getUnqual(IntegerType::get(Size<<3));
// Memcpy forces the use of i8* for the source and destination. That means
// that if you're using memcpy to move one double around, you'll get a cast
@@ -9726,7 +9726,7 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
}
if (SrcETy->isSingleValueType())
- NewPtrTy = Context->getPointerTypeUnqual(SrcETy);
+ NewPtrTy = PointerType::getUnqual(SrcETy);
}
}
@@ -9768,10 +9768,10 @@ Instruction *InstCombiner::SimplifyMemSet(MemSetInst *MI) {
// memset(s,c,n) -> store s, c (for n=1,2,4,8)
if (Len <= 8 && isPowerOf2_32((uint32_t)Len)) {
- const Type *ITy = Context->getIntegerType(Len*8); // n=1 -> i8.
+ const Type *ITy = IntegerType::get(Len*8); // n=1 -> i8.
Value *Dest = MI->getDest();
- Dest = InsertBitCastBefore(Dest, Context->getPointerTypeUnqual(ITy), *MI);
+ Dest = InsertBitCastBefore(Dest, PointerType::getUnqual(ITy), *MI);
// Alignment 0 is identity for alignment 1 for memset, but not store.
if (Alignment == 0) Alignment = 1;
@@ -9875,7 +9875,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// Turn X86 loadups -> load if the pointer is known aligned.
if (GetOrEnforceKnownAlignment(II->getOperand(1), 16) >= 16) {
Value *Ptr = InsertBitCastBefore(II->getOperand(1),
- Context->getPointerTypeUnqual(II->getType()),
+ PointerType::getUnqual(II->getType()),
CI);
return new LoadInst(Ptr);
}
@@ -9885,7 +9885,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// Turn stvx -> store if the pointer is known aligned.
if (GetOrEnforceKnownAlignment(II->getOperand(2), 16) >= 16) {
const Type *OpPtrTy =
- Context->getPointerTypeUnqual(II->getOperand(1)->getType());
+ PointerType::getUnqual(II->getOperand(1)->getType());
Value *Ptr = InsertBitCastBefore(II->getOperand(2), OpPtrTy, CI);
return new StoreInst(II->getOperand(1), Ptr);
}
@@ -9896,7 +9896,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// Turn X86 storeu -> store if the pointer is known aligned.
if (GetOrEnforceKnownAlignment(II->getOperand(1), 16) >= 16) {
const Type *OpPtrTy =
- Context->getPointerTypeUnqual(II->getOperand(2)->getType());
+ PointerType::getUnqual(II->getOperand(2)->getType());
Value *Ptr = InsertBitCastBefore(II->getOperand(1), OpPtrTy, CI);
return new StoreInst(II->getOperand(2), Ptr);
}
@@ -10062,7 +10062,7 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
// If the call and callee calling conventions don't match, this call must
// be unreachable, as the call is undefined.
new StoreInst(Context->getTrue(),
- Context->getUndef(Context->getPointerTypeUnqual(Type::Int1Ty)),
+ Context->getUndef(PointerType::getUnqual(Type::Int1Ty)),
OldCall);
if (!OldCall->use_empty())
OldCall->replaceAllUsesWith(Context->getUndef(OldCall->getType()));
@@ -10076,7 +10076,7 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
// undef so that we know that this code is not reachable, despite the fact
// that we can't modify the CFG here.
new StoreInst(Context->getTrue(),
- Context->getUndef(Context->getPointerTypeUnqual(Type::Int1Ty)),
+ Context->getUndef(PointerType::getUnqual(Type::Int1Ty)),
CS.getInstruction());
if (!CS.getInstruction()->use_empty())
@@ -10457,13 +10457,12 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
// Replace the trampoline call with a direct call. Let the generic
// code sort out any function type mismatches.
- FunctionType *NewFTy =
- Context->getFunctionType(FTy->getReturnType(), NewTypes,
+ FunctionType *NewFTy = FunctionType::get(FTy->getReturnType(), NewTypes,
FTy->isVarArg());
Constant *NewCallee =
- NestF->getType() == Context->getPointerTypeUnqual(NewFTy) ?
+ NestF->getType() == PointerType::getUnqual(NewFTy) ?
NestF : ConstantExpr::getBitCast(NestF,
- Context->getPointerTypeUnqual(NewFTy));
+ PointerType::getUnqual(NewFTy));
const AttrListPtr &NewPAL = AttrListPtr::get(NewAttrs.begin(),
NewAttrs.end());
@@ -11367,7 +11366,7 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) {
if (AI.isArrayAllocation()) { // Check C != 1
if (const ConstantInt *C = dyn_cast<ConstantInt>(AI.getArraySize())) {
const Type *NewTy =
- Context->getArrayType(AI.getAllocatedType(), C->getZExtValue());
+ ArrayType::get(AI.getAllocatedType(), C->getZExtValue());
AllocationInst *New = 0;
// Create and insert the replacement instruction...
@@ -11427,7 +11426,7 @@ Instruction *InstCombiner::visitFreeInst(FreeInst &FI) {
if (isa<UndefValue>(Op)) {
// Insert a new store to null because we cannot modify the CFG here.
new StoreInst(Context->getTrue(),
- Context->getUndef(Context->getPointerTypeUnqual(Type::Int1Ty)), &FI);
+ Context->getUndef(PointerType::getUnqual(Type::Int1Ty)), &FI);
return EraseInstFromFunction(FI);
}
@@ -11734,7 +11733,7 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) {
}
}
- SrcTy = Context->getPointerType(SrcPTy, SrcTy->getAddressSpace());
+ SrcTy = PointerType::get(SrcPTy, SrcTy->getAddressSpace());
}
if (!SrcPTy->isInteger() && !isa<PointerType>(SrcPTy))
@@ -12456,7 +12455,7 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
unsigned AS =
cast<PointerType>(I->getOperand(0)->getType())->getAddressSpace();
Value *Ptr = InsertBitCastBefore(I->getOperand(0),
- Context->getPointerType(EI.getType(), AS),EI);
+ PointerType::get(EI.getType(), AS),EI);
GetElementPtrInst *GEP =
GetElementPtrInst::Create(Ptr, EI.getOperand(1), I->getName()+".gep");
cast<GEPOperator>(GEP)->setIsInBounds(true);
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 9fd0fdf0b0..619e1f1093 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -1947,7 +1947,7 @@ ICmpInst *LoopStrengthReduce::ChangeCompareStride(Loop *L, ICmpInst *Cond,
NewCmpTy = NewCmpLHS->getType();
NewTyBits = SE->getTypeSizeInBits(NewCmpTy);
- const Type *NewCmpIntTy = Context.getIntegerType(NewTyBits);
+ const Type *NewCmpIntTy = IntegerType::get(NewTyBits);
if (RequiresTypeConversion(NewCmpTy, CmpTy)) {
// Check if it is possible to rewrite it using
// an iv / stride of a smaller integer type.
diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index afbed3741f..224a136648 100644
--- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -352,7 +352,6 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
TargetData &TD = getAnalysis<TargetData>();
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
- LLVMContext &Context = SI->getContext();
Module *M = SI->getParent()->getParent()->getParent();
// Okay, so we now have a single store that can be splatable. Scan to find
@@ -441,7 +440,7 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
StartPtr = Range.StartPtr;
// Cast the start ptr to be i8* as memset requires.
- const Type *i8Ptr = Context.getPointerTypeUnqual(Type::Int8Ty);
+ const Type *i8Ptr = PointerType::getUnqual(Type::Int8Ty);
if (StartPtr->getType() != i8Ptr)
StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(),
InsertPt);
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index 7ca2c5e7f3..73dd23cf68 100644
--- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -307,7 +307,7 @@ bool SROA::performScalarRepl(Function &F) {
DOUT << "CONVERT TO SCALAR INTEGER: " << *AI << "\n";
// Create and insert the integer alloca.
- const Type *NewTy = F.getContext().getIntegerType(AllocaSize*8);
+ const Type *NewTy = IntegerType::get(AllocaSize*8);
NewAI = new AllocaInst(NewTy, 0, "", AI->getParent()->begin());
ConvertUsesToScalar(AI, NewAI, 0);
}
@@ -900,7 +900,6 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI,
SmallVector<AllocaInst*, 32> &NewElts){
// Extract each element out of the integer according to its structure offset
// and store the element value to the individual alloca.
- LLVMContext &Context = SI->getContext();
Value *SrcVal = SI->getOperand(0);
const Type *AllocaEltTy = AI->getType()->getElementType();
uint64_t AllocaSizeBits = TD->getTypeAllocSizeInBits(AllocaEltTy);
@@ -914,7 +913,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI,
// Handle tail padding by extending the operand
if (TD->getTypeSizeInBits(SrcVal->getType()) != AllocaSizeBits)
SrcVal = new ZExtInst(SrcVal,
- Context.getIntegerType(AllocaSizeBits), "", SI);
+ IntegerType::get(AllocaSizeBits), "", SI);
DOUT << "PROMOTING STORE TO WHOLE ALLOCA: " << *AI << *SI;
@@ -946,7 +945,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI,
if (FieldSizeBits != AllocaSizeBits)
EltVal = new TruncInst(EltVal,
- Context.getIntegerType(FieldSizeBits), "", SI);
+ IntegerType::get(FieldSizeBits), "", SI);
Value *DestField = NewElts[i];
if (EltVal->getType() == FieldTy) {
// Storing to an integer field of this size, just do it.
@@ -956,7 +955,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI,
} else {
// Otherwise, bitcast the dest pointer (for aggregates).
DestField = new BitCastInst(DestField,
- Context.getPointerTypeUnqual(EltVal->getType()),
+ PointerType::getUnqual(EltVal->getType()),
"", SI);
}
new StoreInst(EltVal, DestField, SI);
@@ -989,7 +988,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI,
// Truncate down to an integer of the right size.
if (ElementSizeBits != AllocaSizeBits)
EltVal = new TruncInst(EltVal,
- Context.getIntegerType(ElementSizeBits),"",SI);
+ IntegerType::get(ElementSizeBits),"",SI);
Value *DestField = NewElts[i];
if (EltVal->getType() == ArrayEltTy) {
// Storing to an integer field of this size, just do it.
@@ -999,7 +998,7 @@ void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI,
} else {
// Otherwise, bitcast the dest pointer (for aggregates).
DestField = new BitCastInst(DestField,
- Context.getPointerTypeUnqual(EltVal->getType()),
+ PointerType::getUnqual(EltVal->getType()),
"", SI);
}
new StoreInst(EltVal, DestField, SI);
@@ -1046,7 +1045,7 @@ void SROA::RewriteLoadUserOfWholeAlloca(LoadInst *LI, AllocationInst *AI,
LLVMContext &Context = LI->getContext();
Value *ResultVal =
- Context.getNullValue(Context.getIntegerType(AllocaSizeBits));
+ Context.getNullValue(IntegerType::get(AllocaSizeBits));
for (unsigned i = 0, e = NewElts.size(); i != e; ++i) {
// Load the value from the alloca. If the NewElt is an aggregate, cast
@@ -1059,11 +1058,11 @@ void SROA::RewriteLoadUserOfWholeAlloca(LoadInst *LI, AllocationInst *AI,
// Ignore zero sized fields like {}, they obviously contain no data.
if (FieldSizeBits == 0) continue;
- const IntegerType *FieldIntTy = Context.getIntegerType(FieldSizeBits);
+ const IntegerType *FieldIntTy = IntegerType::get(FieldSizeBits);
if (!isa<IntegerType>(FieldTy) && !FieldTy->isFloatingPoint() &&
!isa<VectorType>(FieldTy))
SrcField = new BitCastInst(SrcField,
- Context.getPointerTypeUnqual(FieldIntTy),
+ PointerType::getUnqual(FieldIntTy),
"", LI);
SrcField = new LoadInst(SrcField, "sroa.load.elt", LI);
@@ -1297,7 +1296,7 @@ static void MergeInType(const Type *In, uint64_t Offset, const Type *&VecTy,
cast<VectorType>(VecTy)->getElementType()
->getPrimitiveSizeInBits()/8 == EltSize)) {
if (VecTy == 0)
- VecTy = In->getContext().getVectorType(In, AllocaSize/EltSize);
+ VecTy = VectorType::get(In, AllocaSize/EltSize);
return;
}
}
@@ -1623,10 +1622,10 @@ Value *SROA::ConvertScalar_ExtractValue(Value *FromVal, const Type *ToType,
unsigned LIBitWidth = TD->getTypeSizeInBits(ToType);
if (LIBitWidth < NTy->getBitWidth())
FromVal =
- Builder.CreateTrunc(FromVal, Context.getIntegerType(LIBitWidth), "tmp");
+ Builder.CreateTrunc(FromVal, IntegerType::get(LIBitWidth), "tmp");
else if (LIBitWidth > NTy->getBitWidth())
FromVal =
- Builder.CreateZExt(FromVal, Context.getIntegerType(LIBitWidth), "tmp");
+ Builder.CreateZExt(FromVal, IntegerType::get(LIBitWidth), "tmp");
// If the result is an integer, this is a trunc or bitcast.
if (isa<IntegerType>(ToType)) {
@@ -1711,7 +1710,7 @@ Value *SROA::ConvertScalar_InsertValue(Value *SV, Value *Old,
unsigned SrcStoreWidth = TD->getTypeStoreSizeInBits(SV->getType());
unsigned DestStoreWidth = TD->getTypeStoreSizeInBits(AllocaType);
if (SV->getType()->isFloatingPoint() || isa<VectorType>(SV->getType()))
- SV = Builder.CreateBitCast(SV, Context.getIntegerType(SrcWidth), "tmp");
+ SV = Builder.CreateBitCast(SV, IntegerType::get(SrcWidth), "tmp");
else if (isa<PointerType>(SV->getType()))
SV = Builder.CreatePtrToInt(SV, TD->getIntPtrType(), "tmp");
diff --git a/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
index c421ee2406..04bc39b4e0 100644
--- a/lib/Transforms/Scalar/SimplifyLibCalls.cpp
+++ b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
@@ -126,7 +126,7 @@ public:
/// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*.
Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder<> &B) {
return
- B.CreateBitCast(V, Context->getPointerTypeUnqual(Type::Int8Ty), "cstr");
+ B.CreateBitCast(V, PointerType::getUnqual(Type::Int8Ty), "cstr");
}
/// EmitStrLen - Emit a call to the strlen function to the builder, for the
@@ -140,7 +140,7 @@ Value *LibCallOptimization::EmitStrLen(Value *Ptr, IRBuilder<> &B) {
Constant *StrLen =M->getOrInsertFunction("strlen", AttrListPtr::get(AWI, 2),
TD->getIntPtrType(),
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
NULL);
CallInst *CI = B.CreateCall(StrLen, CastToCStr(Ptr, B), "strlen");
if (const Function *F = dyn_cast<Function>(StrLen->stripPointerCasts()))
@@ -171,8 +171,8 @@ Value *LibCallOptimization::EmitMemChr(Value *Ptr, Value *Val,
AWI = AttributeWithIndex::get(~0u, Attribute::ReadOnly | Attribute::NoUnwind);
Value *MemChr = M->getOrInsertFunction("memchr", AttrListPtr::get(&AWI, 1),
- Context->getPointerTypeUnqual(Type::Int8Ty),
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
Type::Int32Ty, TD->getIntPtrType(),
NULL);
CallInst *CI = B.CreateCall3(MemChr, CastToCStr(Ptr, B), Val, Len, "memchr");
@@ -195,8 +195,8 @@ Value *LibCallOptimization::EmitMemCmp(Value *Ptr1, Value *Ptr2,
Value *MemCmp = M->getOrInsertFunction("memcmp", AttrListPtr::get(AWI, 3),
Type::Int32Ty,
- Context->getPointerTypeUnqual(Type::Int8Ty),
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
TD->getIntPtrType(), NULL);
CallInst *CI = B.CreateCall3(MemCmp, CastToCStr(Ptr1, B), CastToCStr(Ptr2, B),
Len, "memcmp");
@@ -274,7 +274,7 @@ void LibCallOptimization::EmitPutS(Value *Str, IRBuilder<> &B) {
Value *PutS = M->getOrInsertFunction("puts", AttrListPtr::get(AWI, 2),
Type::Int32Ty,
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
NULL);
CallInst *CI = B.CreateCall(PutS, CastToCStr(Str, B), "puts");
if (const Function *F = dyn_cast<Function>(PutS->stripPointerCasts()))
@@ -314,11 +314,11 @@ void LibCallOptimization::EmitFPutS(Value *Str, Value *File, IRBuilder<> &B) {
Constant *F;
if (isa<PointerType>(File->getType()))
F = M->getOrInsertFunction("fputs", AttrListPtr::get(AWI, 3), Type::Int32Ty,
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
File->getType(), NULL);
else
F = M->getOrInsertFunction("fputs", Type::Int32Ty,
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
File->getType(), NULL);
CallInst *CI = B.CreateCall2(F, CastToCStr(Str, B), File, "fputs");
@@ -339,12 +339,12 @@ void LibCallOptimization::EmitFWrite(Value *Ptr, Value *Size, Value *File,
if (isa<PointerType>(File->getType()))
F = M->getOrInsertFunction("fwrite", AttrListPtr::get(AWI, 3),
TD->getIntPtrType(),
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
TD->getIntPtrType(), TD->getIntPtrType(),
File->getType(), NULL);
else
F = M->getOrInsertFunction("fwrite", TD->getIntPtrType(),
- Context->getPointerTypeUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
TD->getIntPtrType(), TD->getIntPtrType(),
File->getType(), NULL);
CallInst *CI = B.CreateCall4(F, CastToCStr(Ptr, B), Size,
@@ -555,7 +555,7 @@ struct VISIBILITY_HIDDEN StrCatOpt : public LibCallOptimization {
// Verify the "strcat" function prototype.
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 2 ||
- FT->getReturnType() != Context->getPointerTypeUnqual(Type::Int8Ty) ||
+ FT->getReturnType() != PointerType::getUnqual(Type::Int8Ty) ||
FT->getParamType(0) != FT->getReturnType() ||
FT->getParamType(1) != FT->getReturnType())
return 0;
@@ -602,7 +602,7 @@ struct VISIBILITY_HIDDEN StrNCatOpt : public StrCatOpt {
// Verify the "strncat" function prototype.
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 ||
- FT->getReturnType() != Context->getPointerTypeUnqual(Type::Int8Ty) ||
+ FT->getReturnType() != PointerType::getUnqual(Type::Int8Ty) ||
FT->getParamType(0) != FT->getReturnType() ||
FT->getParamType(1) != FT->getReturnType() ||
!isa<IntegerType>(FT->getParamType(2)))
@@ -647,7 +647,7 @@ struct VISIBILITY_HIDDEN StrChrOpt : public LibCallOptimization {
// Verify the "strchr" function prototype.
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 2 ||
- FT->getReturnType() != Context->getPointerTypeUnqual(Type::Int8Ty) ||
+ FT->getReturnType() != PointerType::getUnqual(Type::Int8Ty) ||
FT->getParamType(0) != FT->getReturnType())
return 0;
@@ -701,7 +701,7 @@ struct VISIBILITY_HIDDEN StrCmpOpt : public LibCallOptimization {
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 2 || FT->getReturnType() != Type::Int32Ty ||
FT->getParamType(0) != FT->getParamType(1) ||
- FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty))
+ FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty))
return 0;
Value *Str1P = CI->getOperand(1), *Str2P = CI->getOperand(2);
@@ -745,7 +745,7 @@ struct VISIBILITY_HIDDEN StrNCmpOpt : public LibCallOptimization {
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 || FT->getReturnType() != Type::Int32Ty ||
FT->getParamType(0) != FT->getParamType(1) ||
- FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty) ||
+ FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) ||
!isa<IntegerType>(FT->getParamType(2)))
return 0;
@@ -791,7 +791,7 @@ struct VISIBILITY_HIDDEN StrCpyOpt : public LibCallOptimization {
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 2 || FT->getReturnType() != FT->getParamType(0) ||
FT->getParamType(0) != FT->getParamType(1) ||
- FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty))
+ FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty))
return 0;
Value *Dst = CI->getOperand(1), *Src = CI->getOperand(2);
@@ -818,7 +818,7 @@ struct VISIBILITY_HIDDEN StrNCpyOpt : public LibCallOptimization {
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 || FT->getReturnType() != FT->getParamType(0) ||
FT->getParamType(0) != FT->getParamType(1) ||
- FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty) ||
+ FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) ||
!isa<IntegerType>(FT->getParamType(2)))
return 0;
@@ -863,7 +863,7 @@ struct VISIBILITY_HIDDEN StrLenOpt : public LibCallOptimization {
virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 1 ||
- FT->getParamType(0) != Context->getPointerTypeUnqual(Type::Int8Ty) ||
+ FT->getParamType(0) != PointerType::getUnqual(Type::Int8Ty) ||
!isa<IntegerType>(FT->getReturnType()))
return 0;
@@ -937,7 +937,7 @@ struct VISIBILITY_HIDDEN MemCmpOpt : public LibCallOptimization {
// memcmp(S1,S2,2) != 0 -> (*(short*)LHS ^ *(short*)RHS) != 0
// memcmp(S1,S2,4) != 0 -> (*(int*)LHS ^ *(int*)RHS) != 0
if ((Len == 2 || Len == 4) && IsOnlyUsedInZeroEqualityComparison(CI)) {
- const Type *PTy = Context->getPointerTypeUnqual(Len == 2 ?
+ const Type *PTy = PointerType::getUnqual(Len == 2 ?
Type::Int16Ty : Type::Int32Ty);
LHS = B.CreateBitCast(LHS, PTy, "tmp");
RHS = B.CreateBitCast(RHS, PTy, "tmp");
diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp
index dae39b7a79..7b8a8a498b 100644
--- a/lib/Transforms/Utils/CloneFunction.cpp
+++ b/lib/Transforms/Utils/CloneFunction.cpp
@@ -151,8 +151,7 @@ Function *llvm::CloneFunction(const Function *F,
ArgTypes.push_back(I->getType());
// Create a new function type...
- FunctionType *FTy =
- F->getContext().getFunctionType(F->getFunctionType()->getReturnType(),
+ FunctionType *FTy = FunctionType::get(F->getFunctionType()->getReturnType(),
ArgTypes, F->getFunctionType()->isVarArg());
// Create the new function...
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp
index ab10baa772..d897c2acd1 100644
--- a/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/lib/Transforms/Utils/CodeExtractor.cpp
@@ -266,8 +266,7 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
if (AggregateArgs)
paramTy.push_back((*I)->getType());
else
- paramTy.push_back(
- header->getContext().getPointerTypeUnqual((*I)->getType()));
+ paramTy.push_back(PointerType::getUnqual((*I)->getType()));
}
DOUT << "Function type: " << *RetTy << " f(";
@@ -278,12 +277,12 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
if (AggregateArgs && (inputs.size() + outputs.size() > 0)) {
PointerType *StructPtr =
- Context.getPointerTypeUnqual(Context.getStructType(paramTy));
+ PointerType::getUnqual(StructType::get(paramTy));
paramTy.clear();
paramTy.push_back(StructPtr);
}
const FunctionType *funcType =
- Context.getFunctionType(RetTy, paramTy, false);
+ FunctionType::get(RetTy, paramTy, false);
// Create the new function
Function *newFunction = Function::Create(funcType,
@@ -387,7 +386,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer,
ArgTypes.push_back((*v)->getType());
// Allocate a struct at the beginning of this function
- Type *StructArgTy = Context.getStructType(ArgTypes);
+ Type *StructArgTy = StructType::get(ArgTypes);
Struct =
new AllocaInst(StructArgTy, 0, "structArg",
codeReplacer->getParent()->begin()->begin());
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index cdde678d75..43b996af3f 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -304,7 +304,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
if (CalledFunc->paramHasAttr(ArgNo+1, Attribute::ByVal) &&
!CalledFunc->onlyReadsMemory()) {
const Type *AggTy = cast<PointerType>(I->getType())->getElementType();
- const Type *VoidPtrTy = Context.getPointerTypeUnqual(Type::Int8Ty);
+ const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
// Create the alloca. If we have TargetData, use nice alignment.
unsigned Align = 1;
diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp
index 522166d6f2..305897c8ff 100644
--- a/lib/Transforms/Utils/LowerAllocations.cpp
+++ b/lib/Transforms/Utils/LowerAllocations.cpp
@@ -87,10 +87,10 @@ Pass *llvm::createLowerAllocationsPass(bool LowerMallocArgToInteger) {
// This function is always successful.
//
bool LowerAllocations::doInitialization(Module &M) {
- const Type *BPTy = M.getContext().getPointerTypeUnqual(Type::Int8Ty);
+ const Type *BPTy = PointerType::getUnqual(Type::Int8Ty);
// Prototype malloc as "char* malloc(...)", because we don't know in
// doInitialization whether size_t is int or long.
- FunctionType *FT = M.getContext().getFunctionType(BPTy, true);
+ FunctionType *FT = FunctionType::get(BPTy, true);
MallocFunc = M.getOrInsertFunction("malloc", FT);
FreeFunc = M.getOrInsertFunction("free" , Type::VoidTy, BPTy, (Type *)0);
return true;
@@ -166,7 +166,7 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
} else if (FreeInst *FI = dyn_cast<FreeInst>(I)) {
Value *PtrCast =
new BitCastInst(FI->getOperand(0),
- Context.getPointerTypeUnqual(Type::Int8Ty), "", I);
+ PointerType::getUnqual(Type::Int8Ty), "", I);
// Insert a call to the free function...
CallInst::Create(FreeFunc, PtrCast, "", I)->setTailCall();
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index b880734c14..a9d218c5fd 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -117,26 +117,26 @@ FunctionPass *llvm::createLowerInvokePass(const TargetLowering *TLI) {
bool LowerInvoke::doInitialization(Module &M) {
LLVMContext &Context = M.getContext();
- const Type *VoidPtrTy = Context.getPointerTypeUnqual(Type::Int8Ty);
+ const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
AbortMessage = 0;
if (ExpensiveEHSupport) {
// Insert a type for the linked list of jump buffers.
unsigned JBSize = TLI ? TLI->getJumpBufSize() : 0;
JBSize = JBSize ? JBSize : 200;
- const Type *JmpBufTy = Context.getArrayType(VoidPtrTy, JBSize);
+ const Type *JmpBufTy = ArrayType::get(VoidPtrTy, JBSize);
{ // The type is recursive, so use a type holder.
std::vector<const Type*> Elements;
Elements.push_back(JmpBufTy);
- OpaqueType *OT = Context.getOpaqueType();
- Elements.push_back(Context.getPointerTypeUnqual(OT));
- PATypeHolder JBLType(Context.getStructType(Elements));
+ OpaqueType *OT = OpaqueType::get();
+ Elements.push_back(PointerType::getUnqual(OT));
+ PATypeHolder JBLType(StructType::get(Elements));
OT->refineAbstractTypeTo(JBLType.get()); // Complete the cycle.
JBLinkTy = JBLType.get();
M.addTypeName("llvm.sjljeh.jmpbufty", JBLinkTy);
}
- const Type *PtrJBList = Context.getPointerTypeUnqual(JBLinkTy);
+ const Type *PtrJBList = PointerType::getUnqual(JBLinkTy);
// Now that we've done that, insert the jmpbuf list head global, unless it
// already exists.