diff options
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 11 | ||||
-rw-r--r-- | lib/VMCore/Constants.cpp | 2 | ||||
-rw-r--r-- | lib/VMCore/Core.cpp | 3 | ||||
-rw-r--r-- | lib/VMCore/Function.cpp | 3 | ||||
-rw-r--r-- | lib/VMCore/InlineAsm.cpp | 4 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 14 | ||||
-rw-r--r-- | lib/VMCore/Module.cpp | 4 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 4 |
8 files changed, 27 insertions, 18 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index a99ae9ded8..20e04cae4f 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -1383,12 +1383,13 @@ Constant *llvm::ConstantFoldGetElementPtr(const Constant *C, return const_cast<Constant*>(C); if (isa<UndefValue>(C)) { - const Type *Ty = GetElementPtrInst::getIndexedType(C->getType(), + const PointerType *Ptr = cast<PointerType>(C->getType()); + const Type *Ty = GetElementPtrInst::getIndexedType(Ptr, (Value **)Idxs, (Value **)Idxs+NumIdx, true); assert(Ty != 0 && "Invalid indices for GEP!"); - return UndefValue::get(PointerType::get(Ty)); + return UndefValue::get(PointerType::get(Ty, Ptr->getAddressSpace())); } Constant *Idx0 = Idxs[0]; @@ -1400,12 +1401,14 @@ Constant *llvm::ConstantFoldGetElementPtr(const Constant *C, break; } if (isNull) { - const Type *Ty = GetElementPtrInst::getIndexedType(C->getType(), + const PointerType *Ptr = cast<PointerType>(C->getType()); + const Type *Ty = GetElementPtrInst::getIndexedType(Ptr, (Value**)Idxs, (Value**)Idxs+NumIdx, true); assert(Ty != 0 && "Invalid indices for GEP!"); - return ConstantPointerNull::get(PointerType::get(Ty)); + return + ConstantPointerNull::get(PointerType::get(Ty,Ptr->getAddressSpace())); } } diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 964d8880e8..83070c00e1 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -1710,7 +1710,7 @@ Constant *ConstantExpr::getSizeOf(const Type *Ty) { // sizeof is implemented as: (i64) gep (Ty*)null, 1 Constant *GEPIdx = ConstantInt::get(Type::Int32Ty, 1); Constant *GEP = - getGetElementPtr(getNullValue(PointerType::get(Ty)), &GEPIdx, 1); + getGetElementPtr(getNullValue(PointerType::getUnqual(Ty)), &GEPIdx, 1); return getCast(Instruction::PtrToInt, GEP, Type::Int64Ty); } diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index b910cf1501..9a7c7909e8 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -150,7 +150,8 @@ LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount){ } LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType) { - return wrap(PointerType::get(unwrap(ElementType))); + // FIXME: Needst to handle address spaces + return wrap(PointerType::getUnqual(unwrap(ElementType))); } LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType,unsigned ElementCount){ diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 856385bb00..f985899b20 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -271,7 +271,8 @@ ParamAttrsList::~ParamAttrsList() { Function::Function(const FunctionType *Ty, LinkageTypes Linkage, const std::string &name, Module *ParentModule) - : GlobalValue(PointerType::get(Ty), Value::FunctionVal, 0, 0, Linkage, name), + : GlobalValue(PointerType::getUnqual(Ty), + Value::FunctionVal, 0, 0, Linkage, name), ParamAttrs(0) { SymTab = new ValueSymbolTable(); diff --git a/lib/VMCore/InlineAsm.cpp b/lib/VMCore/InlineAsm.cpp index ca4ecad058..e3634e2be5 100644 --- a/lib/VMCore/InlineAsm.cpp +++ b/lib/VMCore/InlineAsm.cpp @@ -34,7 +34,9 @@ InlineAsm *InlineAsm::get(const FunctionType *Ty, const std::string &AsmString, InlineAsm::InlineAsm(const FunctionType *Ty, const std::string &asmString, const std::string &constraints, bool hasSideEffects) - : Value(PointerType::get(Ty), Value::InlineAsmVal), AsmString(asmString), + : Value(PointerType::getUnqual(Ty), + Value::InlineAsmVal), + AsmString(asmString), Constraints(constraints), HasSideEffects(hasSideEffects) { // Do various checks on the constraint string and type. diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 511a0e851a..6c8a072c19 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -72,8 +72,6 @@ bool CallSite::isNoUnwind() const { return cast<InvokeInst>(I)->isNoUnwind(); } - - //===----------------------------------------------------------------------===// // TerminatorInst Class //===----------------------------------------------------------------------===// @@ -672,7 +670,7 @@ static Value *getAISize(Value *Amt) { AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align, const std::string &Name, Instruction *InsertBefore) - : UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize), + : UnaryInstruction(PointerType::getUnqual(Ty), iTy, getAISize(ArraySize), InsertBefore), Alignment(Align) { assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); assert(Ty != Type::VoidTy && "Cannot allocate void!"); @@ -682,7 +680,7 @@ AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align, const std::string &Name, BasicBlock *InsertAtEnd) - : UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize), + : UnaryInstruction(PointerType::getUnqual(Ty), iTy, getAISize(ArraySize), InsertAtEnd), Alignment(Align) { assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); assert(Ty != Type::VoidTy && "Cannot allocate void!"); @@ -925,6 +923,10 @@ void StoreInst::setAlignment(unsigned Align) { // GetElementPtrInst Implementation //===----------------------------------------------------------------------===// +static unsigned retrieveAddrSpace(const Value *Val) { + return cast<PointerType>(Val->getType())->getAddressSpace(); +} + void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx) { NumOperands = 1+NumIdx; Use *OL = OperandList = new Use[NumOperands]; @@ -944,7 +946,7 @@ void GetElementPtrInst::init(Value *Ptr, Value *Idx) { GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, const std::string &Name, Instruction *InBe) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx)), - cast<PointerType>(Ptr->getType())->getAddressSpace()), + retrieveAddrSpace(Ptr)), GetElementPtr, 0, 0, InBe) { init(Ptr, Idx); setName(Name); @@ -953,7 +955,7 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx, const std::string &Name, BasicBlock *IAE) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(),Idx)), - cast<PointerType>(Ptr->getType())->getAddressSpace()), + retrieveAddrSpace(Ptr)), GetElementPtr, 0, 0, IAE) { init(Ptr, Idx); setName(Name); diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index e20dab30be..56b510927d 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -164,8 +164,8 @@ Constant *Module::getOrInsertFunction(const std::string &Name, // If the function exists but has the wrong type, return a bitcast to the // right type. - if (F->getType() != PointerType::get(Ty)) - return ConstantExpr::getBitCast(F, PointerType::get(Ty)); + if (F->getType() != PointerType::getUnqual(Ty)) + return ConstantExpr::getBitCast(F, PointerType::getUnqual(Ty)); // Otherwise, we just found the existing function or a prototype. return F; diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index fb8db1785d..08f031f40e 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -1161,12 +1161,12 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { break; case Intrinsic::gcwrite: Assert1(CI.getOperand(3)->getType() - == PointerType::get(CI.getOperand(1)->getType()), + == PointerType::getUnqual(CI.getOperand(1)->getType()), "Call to llvm.gcwrite must be with type 'void (%ty*, %ty2*, %ty**)'.", &CI); break; case Intrinsic::gcread: - Assert1(CI.getOperand(2)->getType() == PointerType::get(CI.getType()), + Assert1(CI.getOperand(2)->getType() == PointerType::getUnqual(CI.getType()), "Call to llvm.gcread must be with type '%ty* (%ty2*, %ty**).'", &CI); break; |