diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 293de6c7f4e..71eeb75310d 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -2032,7 +2032,8 @@ static bool isSimpleEnoughPointerToCommit(Constant *C, LLVMContext &Context) { if (ConstantExpr *CE = dyn_cast(C)) // Handle a constantexpr gep. if (CE->getOpcode() == Instruction::GetElementPtr && - isa(CE->getOperand(0))) { + isa(CE->getOperand(0)) && + cast(CE)->isInBounds()) { GlobalVariable *GV = cast(CE->getOperand(0)); // Do not allow weak/linkonce/dllimport/dllexport linkage or // external globals.