diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2009-10-13 10:07:13 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2009-10-13 10:07:13 +0000 |
commit | 3c0ef8cc0dc246bd3083e8cdd63005e8873d36d2 (patch) | |
tree | 58cf4d4581c365f1dcf6a6d99ec91d1c3066504d /lib/CodeGen/CGExprScalar.cpp | |
parent | 3ae9f48ae0d07a5aa352bf03c944f557a5ac4c95 (diff) |
Simplify pointer creation with the new Type::getInt*Ptr methods.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83964 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index dcb5684032..cc81256032 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -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()); |