summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-08-12 00:33:55 +0000
committerDan Gohman <gohman@apple.com>2009-08-12 00:33:55 +0000
commit43b4484f87d955e46324d7d9e0729da50462e310 (patch)
treecc27f0cc39730bea1d728cfb19bc75cd3a223297 /clang/lib/CodeGen
parent76733748e1e7bfe22731de2c5a812c0e59cedbe2 (diff)
downloadbcm5719-llvm-43b4484f87d955e46324d7d9e0729da50462e310.tar.gz
bcm5719-llvm-43b4484f87d955e46324d7d9e0729da50462e310.zip
Use the inbounds variant of getelementptr for common pointer arithmetic.
llvm-svn: 78756
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp6
-rw-r--r--clang/lib/CodeGen/CGExprScalar.cpp6
2 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 3e9a2739c4c..a97f9ad0630 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -889,7 +889,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) {
Idx = Builder.CreateUDiv(Idx,
llvm::ConstantInt::get(Idx->getType(),
BaseTypeSize));
- Address = Builder.CreateGEP(Base, Idx, "arrayidx");
+ Address = Builder.CreateInBoundsGEP(Base, Idx, "arrayidx");
} else if (const ObjCInterfaceType *OIT =
dyn_cast<ObjCInterfaceType>(E->getType())) {
llvm::Value *InterfaceSize =
@@ -899,11 +899,11 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) {
Idx = Builder.CreateMul(Idx, InterfaceSize);
llvm::Type *i8PTy = llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
- Address = Builder.CreateGEP(Builder.CreateBitCast(Base, i8PTy),
+ Address = Builder.CreateGEP(Builder.CreateBitCast(Base, i8PTy),
Idx, "arrayidx");
Address = Builder.CreateBitCast(Address, Base->getType());
} else {
- Address = Builder.CreateGEP(Base, Idx, "arrayidx");
+ Address = Builder.CreateInBoundsGEP(Base, Idx, "arrayidx");
}
QualType T = E->getBase()->getType()->getPointeeType();
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp
index f8fae423015..c0f6335d881 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -724,7 +724,7 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
LV = LValue::MakeAddr(lhs, ValTy.getCVRQualifiers(),
CGF.getContext().getObjCGCAttrKind(ValTy));
} else
- NextVal = Builder.CreateGEP(InVal, Inc, "ptrincdec");
+ NextVal = Builder.CreateInBoundsGEP(InVal, Inc, "ptrincdec");
} else {
const llvm::Type *i8Ty =
llvm::PointerType::getUnqual(llvm::Type::Int8Ty);
@@ -1094,7 +1094,7 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
return Builder.CreateBitCast(Res, Ptr->getType());
}
- return Builder.CreateGEP(Ptr, Idx, "add.ptr");
+ return Builder.CreateInBoundsGEP(Ptr, Idx, "add.ptr");
}
Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) {
@@ -1160,7 +1160,7 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) {
return Builder.CreateBitCast(Res, Ops.LHS->getType());
}
- return Builder.CreateGEP(Ops.LHS, Idx, "sub.ptr");
+ return Builder.CreateInBoundsGEP(Ops.LHS, Idx, "sub.ptr");
} else {
// pointer - pointer
Value *LHS = Ops.LHS;
OpenPOWER on IntegriCloud