summaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChristopher Lamb <christopher.lamb@gmail.com>2007-12-17 01:12:55 +0000
committerChristopher Lamb <christopher.lamb@gmail.com>2007-12-17 01:12:55 +0000
commit43ad6b3e0d6ada51e9b23aab3e061187f1f5710c (patch)
treeaccb30ee96c29fc9e1021feaa850a435b60f81fc /lib/Transforms
parent303dae993aba2474a23753ed66737b8c38cc97a0 (diff)
downloadllvm-43ad6b3e0d6ada51e9b23aab3e061187f1f5710c.tar.gz
llvm-43ad6b3e0d6ada51e9b23aab3e061187f1f5710c.tar.bz2
llvm-43ad6b3e0d6ada51e9b23aab3e061187f1f5710c.tar.xz
Change the PointerType api for creating pointer types. The old functionality of PointerType::get() has become PointerType::getUnqual(), which returns a pointer in the generic address space. The new prototype of PointerType::get() requires both a type and an address space.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45082 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp4
-rw-r--r--lib/Transforms/IPO/LowerSetJmp.cpp10
-rw-r--r--lib/Transforms/IPO/RaiseAllocations.cpp11
-rw-r--r--lib/Transforms/IPO/SimplifyLibCalls.cpp52
-rw-r--r--lib/Transforms/Instrumentation/ProfilingUtils.cpp5
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp32
-rw-r--r--lib/Transforms/Scalar/LowerGC.cpp14
-rw-r--r--lib/Transforms/Utils/CodeExtractor.cpp4
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp2
-rw-r--r--lib/Transforms/Utils/LowerAllocations.cpp7
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp11
11 files changed, 82 insertions, 70 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index f574ed4606..a858fb22fa 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -1052,7 +1052,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 = PointerType::get(FieldTy);
+ const Type *PFieldTy = PointerType::getUnqual(FieldTy);
GlobalVariable *NGV =
new GlobalVariable(PFieldTy, false, GlobalValue::InternalLinkage,
@@ -1618,7 +1618,7 @@ static GlobalVariable *InstallGlobalCtors(GlobalVariable *GCL,
} else {
const Type *FTy = FunctionType::get(Type::VoidTy,
std::vector<const Type*>(), false);
- const PointerType *PFTy = PointerType::get(FTy);
+ const PointerType *PFTy = PointerType::getUnqual(FTy);
CSVals[1] = Constant::getNullValue(PFTy);
CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647);
}
diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp
index 90ece1799d..389ddebc6a 100644
--- a/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/lib/Transforms/IPO/LowerSetJmp.cpp
@@ -199,8 +199,8 @@ bool LowerSetJmp::runOnModule(Module& M) {
// This function is always successful, unless it isn't.
bool LowerSetJmp::doInitialization(Module& M)
{
- const Type *SBPTy = PointerType::get(Type::Int8Ty);
- const Type *SBPPTy = PointerType::get(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.
@@ -256,7 +256,7 @@ bool LowerSetJmp::IsTransformableFunction(const std::string& Name) {
// throwing the exception for us.
void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
{
- const Type* SBPTy = PointerType::get(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
@@ -308,7 +308,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 = PointerType::get(Type::Int8Ty);
+ const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst);
new CallInst(InitSJMap, Map, "", Inst);
return SJMap[Func] = Map;
@@ -378,7 +378,7 @@ void LowerSetJmp::TransformSetJmpCall(CallInst* Inst)
Function* Func = ABlock->getParent();
// Add this setjmp to the setjmp map.
- const Type* SBPTy = PointerType::get(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 e6d8723f45..ca4be9e528 100644
--- a/lib/Transforms/IPO/RaiseAllocations.cpp
+++ b/lib/Transforms/IPO/RaiseAllocations.cpp
@@ -78,7 +78,7 @@ void RaiseAllocations::doInitialization(Module &M) {
// Get the expected prototype for malloc
const FunctionType *Malloc1Type =
- FunctionType::get(PointerType::get(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
@@ -86,14 +86,14 @@ void RaiseAllocations::doInitialization(Module &M) {
// Check to see if the prototype is wrong, giving us sbyte*(uint) * malloc
// This handles the common declaration of: 'void *malloc(unsigned);'
const FunctionType *Malloc2Type =
- FunctionType::get(PointerType::get(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
// sbyte*(...) * malloc
// This handles the common declaration of: 'void *malloc();'
const FunctionType *Malloc3Type =
- FunctionType::get(PointerType::get(Type::Int8Ty),
+ FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
std::vector<const Type*>(), true);
if (TyWeHave != Malloc3Type)
// Give up
@@ -108,7 +108,7 @@ void RaiseAllocations::doInitialization(Module &M) {
// Get the expected prototype for void free(i8*)
const FunctionType *Free1Type = FunctionType::get(Type::VoidTy,
- std::vector<const Type*>(1, PointerType::get(Type::Int8Ty)), false);
+ std::vector<const Type*>(1, PointerType::getUnqual(Type::Int8Ty)), false);
if (TyWeHave != Free1Type) {
// Check to see if the prototype was forgotten, giving us
@@ -219,7 +219,8 @@ bool RaiseAllocations::runOnModule(Module &M) {
//
Value *Source = *CS.arg_begin();
if (!isa<PointerType>(Source->getType()))
- Source = new IntToPtrInst(Source, PointerType::get(Type::Int8Ty),
+ Source = new IntToPtrInst(Source,
+ PointerType::getUnqual(Type::Int8Ty),
"FreePtrCast", I);
new FreeInst(Source, I);
diff --git a/lib/Transforms/IPO/SimplifyLibCalls.cpp b/lib/Transforms/IPO/SimplifyLibCalls.cpp
index 0904c4c6c1..1547b6c308 100644
--- a/lib/Transforms/IPO/SimplifyLibCalls.cpp
+++ b/lib/Transforms/IPO/SimplifyLibCalls.cpp
@@ -244,7 +244,7 @@ public:
Constant *get_puts() {
if (!puts_func)
puts_func = M->getOrInsertFunction("puts", Type::Int32Ty,
- PointerType::get(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
NULL);
return puts_func;
}
@@ -261,7 +261,7 @@ public:
Constant *get_fputs(const Type* FILEptr_type) {
if (!fputs_func)
fputs_func = M->getOrInsertFunction("fputs", Type::Int32Ty,
- PointerType::get(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
FILEptr_type, NULL);
return fputs_func;
}
@@ -270,7 +270,7 @@ public:
Constant *get_fwrite(const Type* FILEptr_type) {
if (!fwrite_func)
fwrite_func = M->getOrInsertFunction("fwrite", TD->getIntPtrType(),
- PointerType::get(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
TD->getIntPtrType(),
TD->getIntPtrType(),
FILEptr_type, NULL);
@@ -289,9 +289,9 @@ public:
Constant *get_strcpy() {
if (!strcpy_func)
strcpy_func = M->getOrInsertFunction("strcpy",
- PointerType::get(Type::Int8Ty),
- PointerType::get(Type::Int8Ty),
- PointerType::get(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
NULL);
return strcpy_func;
}
@@ -300,7 +300,7 @@ public:
Constant *get_strlen() {
if (!strlen_func)
strlen_func = M->getOrInsertFunction("strlen", TD->getIntPtrType(),
- PointerType::get(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
NULL);
return strlen_func;
}
@@ -309,8 +309,8 @@ public:
Constant *get_memchr() {
if (!memchr_func)
memchr_func = M->getOrInsertFunction("memchr",
- PointerType::get(Type::Int8Ty),
- PointerType::get(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
+ PointerType::getUnqual(Type::Int8Ty),
Type::Int32Ty, TD->getIntPtrType(),
NULL);
return memchr_func;
@@ -319,7 +319,7 @@ public:
/// @brief Return a Function* for the memcpy libcall
Constant *get_memcpy() {
if (!memcpy_func) {
- const Type *SBP = PointerType::get(Type::Int8Ty);
+ const Type *SBP = PointerType::getUnqual(Type::Int8Ty);
const char *N = TD->getIntPtrType() == Type::Int32Ty ?
"llvm.memcpy.i32" : "llvm.memcpy.i64";
memcpy_func = M->getOrInsertFunction(N, Type::VoidTy, SBP, SBP,
@@ -471,7 +471,7 @@ public:
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
const FunctionType *FT = F->getFunctionType();
return FT->getNumParams() == 2 &&
- FT->getReturnType() == PointerType::get(Type::Int8Ty) &&
+ FT->getReturnType() == PointerType::getUnqual(Type::Int8Ty) &&
FT->getParamType(0) == FT->getReturnType() &&
FT->getParamType(1) == FT->getReturnType();
}
@@ -528,7 +528,7 @@ public:
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
const FunctionType *FT = F->getFunctionType();
return FT->getNumParams() == 2 &&
- FT->getReturnType() == PointerType::get(Type::Int8Ty) &&
+ FT->getReturnType() == PointerType::getUnqual(Type::Int8Ty) &&
FT->getParamType(0) == FT->getReturnType() &&
isa<IntegerType>(FT->getParamType(1));
}
@@ -594,7 +594,7 @@ public:
const FunctionType *FT = F->getFunctionType();
return FT->getReturnType() == Type::Int32Ty && FT->getNumParams() == 2 &&
FT->getParamType(0) == FT->getParamType(1) &&
- FT->getParamType(0) == PointerType::get(Type::Int8Ty);
+ FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty);
}
/// @brief Perform the strcmp optimization
@@ -647,7 +647,7 @@ public:
const FunctionType *FT = F->getFunctionType();
return FT->getReturnType() == Type::Int32Ty && FT->getNumParams() == 3 &&
FT->getParamType(0) == FT->getParamType(1) &&
- FT->getParamType(0) == PointerType::get(Type::Int8Ty) &&
+ FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) &&
isa<IntegerType>(FT->getParamType(2));
return false;
}
@@ -715,7 +715,7 @@ public:
return FT->getNumParams() == 2 &&
FT->getParamType(0) == FT->getParamType(1) &&
FT->getReturnType() == FT->getParamType(0) &&
- FT->getParamType(0) == PointerType::get(Type::Int8Ty);
+ FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty);
}
/// @brief Perform the strcpy optimization
@@ -770,7 +770,7 @@ struct VISIBILITY_HIDDEN StrLenOptimization : public LibCallOptimization {
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
const FunctionType *FT = F->getFunctionType();
return FT->getNumParams() == 1 &&
- FT->getParamType(0) == PointerType::get(Type::Int8Ty) &&
+ FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) &&
isa<IntegerType>(FT->getReturnType());
}
@@ -870,7 +870,7 @@ struct VISIBILITY_HIDDEN memcmpOptimization : public LibCallOptimization {
return ReplaceCallWith(CI, Constant::getNullValue(CI->getType()));
case 1: {
// memcmp(S1,S2,1) -> *(ubyte*)S1 - *(ubyte*)S2
- const Type *UCharPtr = PointerType::get(Type::Int8Ty);
+ const Type *UCharPtr = PointerType::getUnqual(Type::Int8Ty);
CastInst *Op1Cast = CastInst::create(
Instruction::BitCast, LHS, UCharPtr, LHS->getName(), CI);
CastInst *Op2Cast = CastInst::create(
@@ -888,7 +888,7 @@ struct VISIBILITY_HIDDEN memcmpOptimization : public LibCallOptimization {
// TODO: IF both are aligned, use a short load/compare.
// memcmp(S1,S2,2) -> S1[0]-S2[0] | S1[1]-S2[1] iff only ==/!= 0 matters
- const Type *UCharPtr = PointerType::get(Type::Int8Ty);
+ const Type *UCharPtr = PointerType::getUnqual(Type::Int8Ty);
CastInst *Op1Cast = CastInst::create(
Instruction::BitCast, LHS, UCharPtr, LHS->getName(), CI);
CastInst *Op2Cast = CastInst::create(
@@ -976,9 +976,9 @@ struct VISIBILITY_HIDDEN LLVMMemCpyMoveOptzn : public LibCallOptimization {
// Cast source and dest to the right sized primitive and then load/store
CastInst* SrcCast = CastInst::create(Instruction::BitCast,
- src, PointerType::get(castType), src->getName()+".cast", ci);
+ src, PointerType::getUnqual(castType), src->getName()+".cast", ci);
CastInst* DestCast = CastInst::create(Instruction::BitCast,
- dest, PointerType::get(castType),dest->getName()+".cast", ci);
+ dest, PointerType::getUnqual(castType),dest->getName()+".cast", ci);
LoadInst* LI = new LoadInst(SrcCast,SrcCast->getName()+".val",ci);
new StoreInst(LI, DestCast, ci);
return ReplaceCallWith(ci, 0);
@@ -1085,7 +1085,7 @@ struct VISIBILITY_HIDDEN LLVMMemSetOptimization : public LibCallOptimization {
}
// Cast dest to the right sized primitive and then load/store
- CastInst* DestCast = new BitCastInst(dest, PointerType::get(castType),
+ CastInst* DestCast = new BitCastInst(dest, PointerType::getUnqual(castType),
dest->getName()+".cast", ci);
new StoreInst(ConstantInt::get(castType,fill_value),DestCast, ci);
return ReplaceCallWith(ci, 0);
@@ -1207,7 +1207,7 @@ public:
Init, "str",
CI->getParent()->getParent()->getParent());
// Cast GV to be a pointer to char.
- GV = ConstantExpr::getBitCast(GV, PointerType::get(Type::Int8Ty));
+ GV = ConstantExpr::getBitCast(GV, PointerType::getUnqual(Type::Int8Ty));
new CallInst(SLC.get_puts(), GV, "", CI);
if (CI->use_empty()) return ReplaceCallWith(CI, 0);
@@ -1268,7 +1268,7 @@ public:
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
const FunctionType *FT = F->getFunctionType();
return FT->getNumParams() == 2 && // two fixed arguments.
- FT->getParamType(1) == PointerType::get(Type::Int8Ty) &&
+ FT->getParamType(1) == PointerType::getUnqual(Type::Int8Ty) &&
isa<PointerType>(FT->getParamType(0)) &&
isa<IntegerType>(FT->getReturnType());
}
@@ -1358,7 +1358,7 @@ public:
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
const FunctionType *FT = F->getFunctionType();
return FT->getNumParams() == 2 && // two fixed arguments.
- FT->getParamType(1) == PointerType::get(Type::Int8Ty) &&
+ FT->getParamType(1) == PointerType::getUnqual(Type::Int8Ty) &&
FT->getParamType(0) == FT->getParamType(1) &&
isa<IntegerType>(FT->getReturnType());
}
@@ -1491,7 +1491,7 @@ public:
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
const FunctionType *FT = F->getFunctionType();
return FT->getNumParams() == 4 &&
- FT->getParamType(0) == PointerType::get(Type::Int8Ty) &&
+ FT->getParamType(0) == PointerType::getUnqual(Type::Int8Ty) &&
FT->getParamType(1) == FT->getParamType(2) &&
isa<IntegerType>(FT->getParamType(1)) &&
isa<PointerType>(FT->getParamType(3)) &&
@@ -1927,7 +1927,7 @@ static bool GetConstantStringInfo(Value *V, std::string &Str) {
static Value *CastToCStr(Value *V, Instruction *IP) {
assert(isa<PointerType>(V->getType()) &&
"Can't cast non-pointer type to C string type");
- const Type *SBPTy = PointerType::get(Type::Int8Ty);
+ const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
if (V->getType() != SBPTy)
return new BitCastInst(V, SBPTy, V->getName(), IP);
return V;
diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp
index 91b8ec2c5c..dacd92aef7 100644
--- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp
+++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp
@@ -22,8 +22,9 @@
void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName,
GlobalValue *Array) {
- const Type *ArgVTy = PointerType::get(PointerType::get(Type::Int8Ty));
- const PointerType *UIntPtr = PointerType::get(Type::Int32Ty);
+ const Type *ArgVTy =
+ 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 aa9e932fc5..7989ebf197 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -2122,8 +2122,10 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
(CI->getType()->getPrimitiveSizeInBits() ==
TD->getIntPtrType()->getPrimitiveSizeInBits())
&& isa<PointerType>(CI->getOperand(0)->getType())) {
+ unsigned AS =
+ cast<PointerType>(CI->getOperand(0)->getType())->getAddressSpace();
Value *I2 = InsertCastBefore(Instruction::BitCast, CI->getOperand(0),
- PointerType::get(Type::Int8Ty), I);
+ PointerType::get(Type::Int8Ty, AS), I);
I2 = InsertNewInstBefore(new GetElementPtrInst(I2, Other, "ctg2"), I);
return new PtrToIntInst(I2, CI->getType());
}
@@ -7740,7 +7742,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// If Size is 2 then use Int16Ty
// If Size is 1 then use Int8Ty
if (Size && Size <=8 && !(Size&(Size-1)))
- NewPtrTy = PointerType::get(IntegerType::get(Size<<3));
+ NewPtrTy = PointerType::getUnqual(IntegerType::get(Size<<3));
if (NewPtrTy) {
Value *Src = InsertCastBefore(Instruction::BitCast, CI.getOperand(2),
@@ -7774,8 +7776,9 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
// Turn PPC lvx -> load if the pointer is known aligned.
// Turn X86 loadups -> load if the pointer is known aligned.
if (GetOrEnforceKnownAlignment(II->getOperand(1), TD, 16) >= 16) {
- Value *Ptr = InsertCastBefore(Instruction::BitCast, II->getOperand(1),
- PointerType::get(II->getType()), CI);
+ Value *Ptr =
+ InsertCastBefore(Instruction::BitCast, II->getOperand(1),
+ PointerType::getUnqual(II->getType()), CI);
return new LoadInst(Ptr);
}
break;
@@ -7783,7 +7786,8 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
case Intrinsic::ppc_altivec_stvxl:
// Turn stvx -> store if the pointer is known aligned.
if (GetOrEnforceKnownAlignment(II->getOperand(2), TD, 16) >= 16) {
- const Type *OpPtrTy = PointerType::get(II->getOperand(1)->getType());
+ const Type *OpPtrTy =
+ PointerType::getUnqual(II->getOperand(1)->getType());
Value *Ptr = InsertCastBefore(Instruction::BitCast, II->getOperand(2),
OpPtrTy, CI);
return new StoreInst(II->getOperand(1), Ptr);
@@ -7795,7 +7799,8 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
case Intrinsic::x86_sse2_storel_dq:
// Turn X86 storeu -> store if the pointer is known aligned.
if (GetOrEnforceKnownAlignment(II->getOperand(1), TD, 16) >= 16) {
- const Type *OpPtrTy = PointerType::get(II->getOperand(2)->getType());
+ const Type *OpPtrTy =
+ PointerType::getUnqual(II->getOperand(2)->getType());
Value *Ptr = InsertCastBefore(Instruction::BitCast, II->getOperand(1),
OpPtrTy, CI);
return new StoreInst(II->getOperand(2), Ptr);
@@ -7921,7 +7926,8 @@ 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(ConstantInt::getTrue(),
- UndefValue::get(PointerType::get(Type::Int1Ty)), OldCall);
+ UndefValue::get(PointerType::getUnqual(Type::Int1Ty)),
+ OldCall);
if (!OldCall->use_empty())
OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType()));
if (isa<CallInst>(OldCall)) // Not worth removing an invoke here.
@@ -7934,7 +7940,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(ConstantInt::getTrue(),
- UndefValue::get(PointerType::get(Type::Int1Ty)),
+ UndefValue::get(PointerType::getUnqual(Type::Int1Ty)),
CS.getInstruction());
if (!CS.getInstruction()->use_empty())
@@ -8299,8 +8305,8 @@ Instruction *InstCombiner::transformCallThroughTrampoline(CallSite CS) {
// code sort out any function type mismatches.
FunctionType *NewFTy =
FunctionType::get(FTy->getReturnType(), NewTypes, FTy->isVarArg());
- Constant *NewCallee = NestF->getType() == PointerType::get(NewFTy) ?
- NestF : ConstantExpr::getBitCast(NestF, PointerType::get(NewFTy));
+ Constant *NewCallee = NestF->getType() == PointerType::getUnqual(NewFTy) ?
+ NestF : ConstantExpr::getBitCast(NestF, PointerType::getUnqual(NewFTy));
const ParamAttrsList *NewPAL = ParamAttrsList::get(NewAttrs);
Instruction *NewCaller;
@@ -9052,7 +9058,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(ConstantInt::getTrue(),
- UndefValue::get(PointerType::get(Type::Int1Ty)), &FI);
+ UndefValue::get(PointerType::getUnqual(Type::Int1Ty)), &FI);
return EraseInstFromFunction(FI);
}
@@ -9887,8 +9893,10 @@ Instruction *InstCombiner::visitExtractElementInst(ExtractElementInst &EI) {
return BinaryOperator::create(BO->getOpcode(), newEI0, newEI1);
}
} else if (isa<LoadInst>(I)) {
+ unsigned AS =
+ cast<PointerType>(I->getOperand(0)->getType())->getAddressSpace();
Value *Ptr = InsertCastBefore(Instruction::BitCast, I->getOperand(0),
- PointerType::get(EI.getType()), EI);
+ PointerType::get(EI.getType(), AS), EI);
GetElementPtrInst *GEP =
new GetElementPtrInst(Ptr, EI.getOperand(1), I->getName() + ".gep");
InsertNewInstBefore(GEP, EI);
diff --git a/lib/Transforms/Scalar/LowerGC.cpp b/lib/Transforms/Scalar/LowerGC.cpp
index 9935a84cda..e7a9997bc1 100644
--- a/lib/Transforms/Scalar/LowerGC.cpp
+++ b/lib/Transforms/Scalar/LowerGC.cpp
@@ -86,7 +86,7 @@ const StructType *LowerGC::getRootRecordType(unsigned NumRoots) {
PATypeHolder RootListH =
MainRootRecordType ? (Type*)MainRootRecordType : (Type*)OpaqueType::get();
ST.clear();
- ST.push_back(PointerType::get(RootListH)); // Prev pointer
+ ST.push_back(PointerType::getUnqual(RootListH)); // Prev pointer
ST.push_back(Type::Int32Ty); // NumElements in array
ST.push_back(PairArrTy); // The pairs
StructType *RootList = StructType::get(ST);
@@ -107,8 +107,8 @@ bool LowerGC::doInitialization(Module &M) {
GCWriteInt = M.getFunction("llvm.gcwrite");
if (!GCRootInt && !GCReadInt && !GCWriteInt) return false;
- PointerType *VoidPtr = PointerType::get(Type::Int8Ty);
- PointerType *VoidPtrPtr = PointerType::get(VoidPtr);
+ PointerType *VoidPtr = PointerType::getUnqual(Type::Int8Ty);
+ PointerType *VoidPtrPtr = PointerType::getUnqual(VoidPtr);
// If the program is using read/write barriers, find the implementations of
// them from the GC runtime library.
@@ -122,7 +122,7 @@ bool LowerGC::doInitialization(Module &M) {
// If the program has GC roots, get or create the global root list.
if (GCRootInt) {
const StructType *RootListTy = getRootRecordType(0);
- const Type *PRLTy = PointerType::get(RootListTy);
+ const Type *PRLTy = PointerType::getUnqual(RootListTy);
M.addTypeName("llvm_gc_root_ty", RootListTy);
// Get the root chain if it already exists.
@@ -163,8 +163,8 @@ bool LowerGC::runOnFunction(Function &F) {
// Quick exit for programs that are not using GC mechanisms.
if (!GCRootInt && !GCReadInt && !GCWriteInt) return false;
- PointerType *VoidPtr = PointerType::get(Type::Int8Ty);
- PointerType *VoidPtrPtr = PointerType::get(VoidPtr);
+ PointerType *VoidPtr = PointerType::getUnqual(Type::Int8Ty);
+ PointerType *VoidPtrPtr = PointerType::getUnqual(VoidPtr);
// If there are read/write barriers in the program, perform a quick pass over
// the function eliminating them. While we are at it, remember where we see
@@ -290,7 +290,7 @@ bool LowerGC::runOnFunction(Function &F) {
// Now that the record is all initialized, store the pointer into the global
// pointer.
- Value *C = new BitCastInst(AI, PointerType::get(MainRootRecordType), "", IP);
+ Value *C = new BitCastInst(AI, PointerType::getUnqual(MainRootRecordType), "", IP);
new StoreInst(C, RootChain, IP);
// Eliminate all the gcroot records now.
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp
index c42d5e177d..98b3f2b940 100644
--- a/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/lib/Transforms/Utils/CodeExtractor.cpp
@@ -263,7 +263,7 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
if (AggregateArgs)
paramTy.push_back((*I)->getType());
else
- paramTy.push_back(PointerType::get((*I)->getType()));
+ paramTy.push_back(PointerType::getUnqual((*I)->getType()));
}
DOUT << "Function type: " << *RetTy << " f(";
@@ -273,7 +273,7 @@ Function *CodeExtractor::constructFunction(const Values &inputs,
DOUT << ")\n";
if (AggregateArgs && (inputs.size() + outputs.size() > 0)) {
- PointerType *StructPtr = PointerType::get(StructType::get(paramTy));
+ PointerType *StructPtr = PointerType::getUnqual(StructType::get(paramTy));
paramTy.clear();
paramTy.push_back(StructPtr);
}
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index e9f6b28e98..e88eb94282 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -277,7 +277,7 @@ bool llvm::InlineFunction(CallSite CS, CallGraph *CG, const TargetData *TD) {
// code with llvm.stacksave/llvm.stackrestore intrinsics.
if (InlinedFunctionInfo.ContainsDynamicAllocas) {
Module *M = Caller->getParent();
- const Type *BytePtr = PointerType::get(Type::Int8Ty);
+ const Type *BytePtr = PointerType::getUnqual(Type::Int8Ty);
// Get the two intrinsics we care about.
Constant *StackSave, *StackRestore;
StackSave = M->getOrInsertFunction("llvm.stacksave", BytePtr, NULL);
diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp
index b089cd6d8b..c5c8bd50da 100644
--- a/lib/Transforms/Utils/LowerAllocations.cpp
+++ b/lib/Transforms/Utils/LowerAllocations.cpp
@@ -87,7 +87,7 @@ Pass *llvm::createLowerAllocationsPass(bool LowerMallocArgToInteger) {
// This function is always successful.
//
bool LowerAllocations::doInitialization(Module &M) {
- const Type *BPTy = PointerType::get(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 = FunctionType::get(BPTy, std::vector<const Type*>(), true);
@@ -158,8 +158,9 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) {
Changed = true;
++NumLowered;
} else if (FreeInst *FI = dyn_cast<FreeInst>(I)) {
- Value *PtrCast = new BitCastInst(FI->getOperand(0),
- PointerType::get(Type::Int8Ty), "", I);
+ Value *PtrCast =
+ new BitCastInst(FI->getOperand(0),
+ PointerType::getUnqual(Type::Int8Ty), "", I);
// Insert a call to the free function...
(new CallInst(FreeFunc, PtrCast, "", I))->setTailCall();
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index 24b167ac87..db49b780fd 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -114,7 +114,7 @@ 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) {
- const Type *VoidPtrTy = PointerType::get(Type::Int8Ty);
+ const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
AbortMessage = 0;
if (ExpensiveEHSupport) {
// Insert a type for the linked list of jump buffers.
@@ -126,14 +126,14 @@ bool LowerInvoke::doInitialization(Module &M) {
std::vector<const Type*> Elements;
Elements.push_back(JmpBufTy);
OpaqueType *OT = OpaqueType::get();
- Elements.push_back(PointerType::get(OT));
+ 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 = PointerType::get(JBLinkTy);
+ const Type *PtrJBList = PointerType::getUnqual(JBLinkTy);
// Now that we've done that, insert the jmpbuf list head global, unless it
// already exists.
@@ -144,9 +144,10 @@ bool LowerInvoke::doInitialization(Module &M) {
"llvm.sjljeh.jblist", &M);
}
SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::Int32Ty,
- PointerType::get(JmpBufTy), (Type *)0);
+ PointerType::getUnqual(JmpBufTy),
+ (Type *)0);
LongJmpFn = M.getOrInsertFunction("llvm.longjmp", Type::VoidTy,
- PointerType::get(JmpBufTy),
+ PointerType::getUnqual(JmpBufTy),
Type::Int32Ty, (Type *)0);
}