Use the inbounds variant of getelementptr for common pointer arithmetic.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78756 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 3e9a273..a97f9ad 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -889,7 +889,7 @@
     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 @@
     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();