forked from OSchip/llvm-project
Simplify pointer creation with the new Type::getInt*Ptr methods.
llvm-svn: 83964
This commit is contained in:
parent
1008612b36
commit
abd5b90e4c
|
@ -414,8 +414,7 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
|
|||
|
||||
BlockLiteral =
|
||||
Builder.CreateBitCast(BlockLiteral,
|
||||
llvm::PointerType::getUnqual(
|
||||
llvm::Type::getInt8Ty(VMContext)),
|
||||
llvm::Type::getInt8PtrTy(VMContext),
|
||||
"tmp");
|
||||
|
||||
// Add the block literal.
|
||||
|
|
|
@ -112,8 +112,7 @@ public:
|
|||
GenericBlockLiteralType(0), GenericExtendedBlockLiteralType(0),
|
||||
BlockObjectAssign(0), BlockObjectDispose(0) {
|
||||
Block.GlobalUniqueCount = 0;
|
||||
PtrToInt8Ty = llvm::PointerType::getUnqual(
|
||||
llvm::Type::getInt8Ty(M.getContext()));
|
||||
PtrToInt8Ty = llvm::Type::getInt8PtrTy(M.getContext());
|
||||
}
|
||||
|
||||
bool BlockRequiresCopying(QualType Ty) {
|
||||
|
|
|
@ -77,8 +77,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
|
|||
case Builtin::BI__builtin_va_start:
|
||||
case Builtin::BI__builtin_va_end: {
|
||||
Value *ArgValue = EmitVAListRef(E->getArg(0));
|
||||
const llvm::Type *DestType =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *DestType = llvm::Type::getInt8PtrTy(VMContext);
|
||||
if (ArgValue->getType() != DestType)
|
||||
ArgValue = Builder.CreateBitCast(ArgValue, DestType,
|
||||
ArgValue->getName().data());
|
||||
|
@ -91,8 +90,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
|
|||
Value *DstPtr = EmitVAListRef(E->getArg(0));
|
||||
Value *SrcPtr = EmitVAListRef(E->getArg(1));
|
||||
|
||||
const llvm::Type *Type =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *Type = llvm::Type::getInt8PtrTy(VMContext);
|
||||
|
||||
DstPtr = Builder.CreateBitCast(DstPtr, Type);
|
||||
SrcPtr = Builder.CreateBitCast(SrcPtr, Type);
|
||||
|
@ -349,16 +347,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
|
|||
Builder.CreateStore(FrameAddr, Buf);
|
||||
// Call the setjmp intrinsic
|
||||
Value *F = CGM.getIntrinsic(Intrinsic::eh_sjlj_setjmp, 0, 0);
|
||||
const llvm::Type *DestType =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *DestType = llvm::Type::getInt8PtrTy(VMContext);
|
||||
Buf = Builder.CreateBitCast(Buf, DestType);
|
||||
return RValue::get(Builder.CreateCall(F, Buf));
|
||||
}
|
||||
case Builtin::BI__builtin_longjmp: {
|
||||
Value *F = CGM.getIntrinsic(Intrinsic::eh_sjlj_longjmp, 0, 0);
|
||||
Value *Buf = EmitScalarExpr(E->getArg(0));
|
||||
const llvm::Type *DestType =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *DestType = llvm::Type::getInt8PtrTy(VMContext);
|
||||
Buf = Builder.CreateBitCast(Buf, DestType);
|
||||
return RValue::get(Builder.CreateCall(F, Buf));
|
||||
}
|
||||
|
@ -760,7 +756,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
|
|||
return Builder.CreateCall(F, &Ops[0], &Ops[0] + Ops.size(), "cmpss");
|
||||
}
|
||||
case X86::BI__builtin_ia32_ldmxcsr: {
|
||||
llvm::Type *PtrTy = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *PtrTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
Value *One = llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 1);
|
||||
Value *Tmp = Builder.CreateAlloca(llvm::Type::getInt32Ty(VMContext), One, "tmp");
|
||||
Builder.CreateStore(Ops[0], Tmp);
|
||||
|
@ -768,7 +764,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
|
|||
Builder.CreateBitCast(Tmp, PtrTy));
|
||||
}
|
||||
case X86::BI__builtin_ia32_stmxcsr: {
|
||||
llvm::Type *PtrTy = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *PtrTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
Value *One = llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 1);
|
||||
Value *Tmp = Builder.CreateAlloca(llvm::Type::getInt32Ty(VMContext), One, "tmp");
|
||||
One = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse_stmxcsr),
|
||||
|
|
|
@ -144,8 +144,7 @@ CodeGenFunction::GetAddressCXXOfBaseClass(llvm::Value *BaseValue,
|
|||
EmitBlock(CastNotNull);
|
||||
}
|
||||
|
||||
const llvm::Type *Int8PtrTy =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
|
||||
llvm::Value *Offset =
|
||||
GetCXXBaseClassOffset(*this, BaseValue, ClassDecl, BaseClassDecl);
|
||||
|
|
|
@ -231,8 +231,7 @@ const llvm::Type *CodeGenFunction::BuildByRefType(const ValueDecl *D) {
|
|||
|
||||
std::vector<const llvm::Type *> Types;
|
||||
|
||||
const llvm::PointerType *Int8PtrTy
|
||||
= llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::PointerType *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
|
||||
llvm::PATypeHolder ByRefTypeHolder = llvm::OpaqueType::get(VMContext);
|
||||
|
||||
|
@ -345,8 +344,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
|
|||
|
||||
if (!DidCallStackSave) {
|
||||
// Save the stack.
|
||||
const llvm::Type *LTy =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *LTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
llvm::Value *Stack = CreateTempAlloca(LTy, "saved_stack");
|
||||
|
||||
llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::stacksave);
|
||||
|
@ -433,8 +431,7 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) {
|
|||
}
|
||||
|
||||
if (isByRef) {
|
||||
const llvm::PointerType *PtrToInt8Ty
|
||||
= llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::PointerType *PtrToInt8Ty = llvm::Type::getInt8PtrTy(VMContext);
|
||||
|
||||
EnsureInsertPoint();
|
||||
llvm::Value *isa_field = Builder.CreateStructGEP(DeclPtr, 0);
|
||||
|
|
|
@ -969,8 +969,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) {
|
|||
|
||||
Idx = Builder.CreateMul(Idx, InterfaceSize);
|
||||
|
||||
llvm::Type *i8PTy =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *i8PTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
Address = Builder.CreateGEP(Builder.CreateBitCast(Base, i8PTy),
|
||||
Idx, "arrayidx");
|
||||
Address = Builder.CreateBitCast(Address, Base->getType());
|
||||
|
|
|
@ -641,8 +641,7 @@ void CodeGenFunction::EmitAggregateCopy(llvm::Value *DestPtr,
|
|||
// equal, but other compilers do this optimization, and almost every memcpy
|
||||
// implementation handles this case safely. If there is a libc that does not
|
||||
// safely handle this, we can add a target hook.
|
||||
const llvm::Type *BP =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *BP = llvm::Type::getInt8PtrTy(VMContext);
|
||||
if (DestPtr->getType() != BP)
|
||||
DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp");
|
||||
if (SrcPtr->getType() != BP)
|
||||
|
|
|
@ -826,8 +826,7 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
|
|||
|
||||
// Apply offset if necessary.
|
||||
if (!Offset->isNullValue()) {
|
||||
const llvm::Type *Type =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *Type = llvm::Type::getInt8PtrTy(VMContext);
|
||||
llvm::Constant *Casted = llvm::ConstantExpr::getBitCast(C, Type);
|
||||
Casted = llvm::ConstantExpr::getGetElementPtr(Casted, &Offset, 1);
|
||||
C = llvm::ConstantExpr::getBitCast(Casted, C->getType());
|
||||
|
|
|
@ -789,8 +789,7 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
|
|||
if (!isInc)
|
||||
size = -size;
|
||||
Inc = llvm::ConstantInt::get(Inc->getType(), size);
|
||||
const llvm::Type *i8Ty =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *i8Ty = llvm::Type::getInt8PtrTy(VMContext);
|
||||
InVal = Builder.CreateBitCast(InVal, i8Ty);
|
||||
NextVal = Builder.CreateGEP(InVal, Inc, "add.ptr");
|
||||
llvm::Value *lhs = LV.getAddress();
|
||||
|
@ -799,8 +798,7 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
|
|||
} else
|
||||
NextVal = Builder.CreateInBoundsGEP(InVal, Inc, "ptrincdec");
|
||||
} else {
|
||||
const llvm::Type *i8Ty =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *i8Ty = llvm::Type::getInt8PtrTy(VMContext);
|
||||
NextVal = Builder.CreateBitCast(InVal, i8Ty, "tmp");
|
||||
NextVal = Builder.CreateGEP(NextVal, Inc, "ptrincdec");
|
||||
NextVal = Builder.CreateBitCast(NextVal, InVal->getType());
|
||||
|
@ -1159,8 +1157,7 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
|
|||
llvm::ConstantInt::get(Idx->getType(),
|
||||
CGF.getContext().getTypeSize(OIT) / 8);
|
||||
Idx = Builder.CreateMul(Idx, InterfaceSize);
|
||||
const llvm::Type *i8Ty =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *i8Ty = llvm::Type::getInt8PtrTy(VMContext);
|
||||
Value *Casted = Builder.CreateBitCast(Ptr, i8Ty);
|
||||
Value *Res = Builder.CreateGEP(Casted, Idx, "add.ptr");
|
||||
return Builder.CreateBitCast(Res, Ptr->getType());
|
||||
|
@ -1170,8 +1167,7 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
|
|||
// GNU void* casts amount to no-ops since our void* type is i8*, but this is
|
||||
// future proof.
|
||||
if (ElementType->isVoidType() || ElementType->isFunctionType()) {
|
||||
const llvm::Type *i8Ty =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *i8Ty = llvm::Type::getInt8PtrTy(VMContext);
|
||||
Value *Casted = Builder.CreateBitCast(Ptr, i8Ty);
|
||||
Value *Res = Builder.CreateGEP(Casted, Idx, "add.ptr");
|
||||
return Builder.CreateBitCast(Res, Ptr->getType());
|
||||
|
@ -1225,8 +1221,7 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) {
|
|||
llvm::ConstantInt::get(Idx->getType(),
|
||||
CGF.getContext().getTypeSize(OIT) / 8);
|
||||
Idx = Builder.CreateMul(Idx, InterfaceSize);
|
||||
const llvm::Type *i8Ty =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *i8Ty = llvm::Type::getInt8PtrTy(VMContext);
|
||||
Value *LHSCasted = Builder.CreateBitCast(Ops.LHS, i8Ty);
|
||||
Value *Res = Builder.CreateGEP(LHSCasted, Idx, "add.ptr");
|
||||
return Builder.CreateBitCast(Res, Ops.LHS->getType());
|
||||
|
@ -1236,8 +1231,7 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) {
|
|||
// extensions. The GNU void* casts amount to no-ops since our void* type is
|
||||
// i8*, but this is future proof.
|
||||
if (LHSElementType->isVoidType() || LHSElementType->isFunctionType()) {
|
||||
const llvm::Type *i8Ty =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *i8Ty = llvm::Type::getInt8PtrTy(VMContext);
|
||||
Value *LHSCasted = Builder.CreateBitCast(Ops.LHS, i8Ty);
|
||||
Value *Res = Builder.CreateGEP(LHSCasted, Idx, "sub.ptr");
|
||||
return Builder.CreateBitCast(Res, Ops.LHS->getType());
|
||||
|
|
|
@ -1917,8 +1917,8 @@ llvm::GlobalVariable *CGObjCGNU::ObjCIvarOffsetVariable(
|
|||
IvarOffsetGV, Name);
|
||||
} else {
|
||||
IvarOffsetPointer = new llvm::GlobalVariable(TheModule,
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt32Ty(VMContext)),
|
||||
false, llvm::GlobalValue::ExternalLinkage, 0, Name);
|
||||
llvm::Type::getInt32PtrTy(VMContext), false,
|
||||
llvm::GlobalValue::ExternalLinkage, 0, Name);
|
||||
}
|
||||
}
|
||||
return IvarOffsetPointer;
|
||||
|
|
|
@ -104,8 +104,7 @@ LValue CGObjCRuntime::EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF,
|
|||
unsigned CVRQualifiers,
|
||||
llvm::Value *Offset) {
|
||||
// Compute (type*) ( (char *) BaseValue + Offset)
|
||||
llvm::Type *I8Ptr =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(CGF.getLLVMContext()));
|
||||
const llvm::Type *I8Ptr = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
|
||||
QualType IvarTy = Ivar->getType();
|
||||
const llvm::Type *LTy = CGF.CGM.getTypes().ConvertTypeForMem(IvarTy);
|
||||
llvm::Value *V = CGF.Builder.CreateBitCast(BaseValue, I8Ptr);
|
||||
|
@ -556,7 +555,7 @@ public:
|
|||
/// SetJmpFn - LLVM _setjmp function.
|
||||
llvm::Constant *getSetJmpFn() {
|
||||
std::vector<const llvm::Type*> Params;
|
||||
Params.push_back(llvm::PointerType::getUnqual(llvm::Type::getInt32Ty(VMContext)));
|
||||
Params.push_back(llvm::Type::getInt32PtrTy(VMContext));
|
||||
return
|
||||
CGM.CreateRuntimeFunction(llvm::FunctionType::get(llvm::Type::getInt32Ty(VMContext),
|
||||
Params, false),
|
||||
|
@ -3208,7 +3207,7 @@ llvm::Constant *CGObjCCommonMac::BuildIvarLayout(
|
|||
bool hasUnion = false;
|
||||
|
||||
unsigned int WordsToScan, WordsToSkip;
|
||||
const llvm::Type *PtrTy = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *PtrTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
if (CGM.getLangOptions().getGCMode() == LangOptions::NonGC)
|
||||
return llvm::Constant::getNullValue(PtrTy);
|
||||
|
||||
|
@ -3535,7 +3534,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
|
|||
IntTy = Types.ConvertType(Ctx.IntTy);
|
||||
LongTy = Types.ConvertType(Ctx.LongTy);
|
||||
LongLongTy = Types.ConvertType(Ctx.LongLongTy);
|
||||
Int8PtrTy = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
|
||||
ObjectPtrTy = Types.ConvertType(Ctx.getObjCIdType());
|
||||
PtrObjectPtrTy = llvm::PointerType::getUnqual(ObjectPtrTy);
|
||||
|
@ -3823,7 +3822,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
|
|||
|
||||
// Exceptions
|
||||
const llvm::Type *StackPtrTy = llvm::ArrayType::get(
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext)), 4);
|
||||
llvm::Type::getInt8PtrTy(VMContext), 4);
|
||||
|
||||
ExceptionDataTy =
|
||||
llvm::StructType::get(VMContext, llvm::ArrayType::get(llvm::Type::getInt32Ty(VMContext),
|
||||
|
|
|
@ -411,8 +411,7 @@ void CodeGenModule::EmitLLVMUsed() {
|
|||
if (LLVMUsed.empty())
|
||||
return;
|
||||
|
||||
llvm::Type *i8PTy =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *i8PTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
|
||||
// Convert LLVMUsed to what ConstantArray needs.
|
||||
std::vector<llvm::Constant*> UsedArray;
|
||||
|
@ -477,8 +476,7 @@ llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV,
|
|||
|
||||
// get [N x i8] constants for the annotation string, and the filename string
|
||||
// which are the 2nd and 3rd elements of the global annotation structure.
|
||||
const llvm::Type *SBP =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *SBP = llvm::Type::getInt8PtrTy(VMContext);
|
||||
llvm::Constant *anno = llvm::ConstantArray::get(VMContext,
|
||||
AA->getAnnotation(), true);
|
||||
llvm::Constant *unit = llvm::ConstantArray::get(VMContext,
|
||||
|
|
|
@ -384,8 +384,7 @@ ABIArgInfo X86_32ABIInfo::classifyReturnType(QualType RetTy,
|
|||
} else if (SeltTy->isPointerType()) {
|
||||
// FIXME: It would be really nice if this could come out as the proper
|
||||
// pointer type.
|
||||
llvm::Type *PtrTy =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(VMContext));
|
||||
const llvm::Type *PtrTy = llvm::Type::getInt8PtrTy(VMContext);
|
||||
return ABIArgInfo::getCoerce(PtrTy);
|
||||
} else if (SeltTy->isVectorType()) {
|
||||
// 64- and 128-bit vectors are never returned in a
|
||||
|
@ -455,7 +454,7 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty,
|
|||
|
||||
llvm::Value *X86_32ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
|
||||
CodeGenFunction &CGF) const {
|
||||
const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(CGF.getLLVMContext()));
|
||||
const llvm::Type *BP = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
|
||||
const llvm::Type *BPP = llvm::PointerType::getUnqual(BP);
|
||||
|
||||
CGBuilderTy &Builder = CGF.Builder;
|
||||
|
@ -1589,8 +1588,7 @@ ABIArgInfo ARMABIInfo::classifyReturnType(QualType RetTy,
|
|||
llvm::Value *ARMABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
|
||||
CodeGenFunction &CGF) const {
|
||||
// FIXME: Need to handle alignment
|
||||
const llvm::Type *BP =
|
||||
llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(CGF.getLLVMContext()));
|
||||
const llvm::Type *BP = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
|
||||
const llvm::Type *BPP = llvm::PointerType::getUnqual(BP);
|
||||
|
||||
CGBuilderTy &Builder = CGF.Builder;
|
||||
|
|
Loading…
Reference in New Issue