From c62482d4edecd416e6529e31427fa6fd8a9b7ece Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 7 Sep 2009 22:40:13 +0000 Subject: [PATCH] Fix GlobalOpt to avoid committing a store if the address getelementptr is missing the inbounds flag. This is slightly conservative, but it avoids problems with two constants pointing to the same address but getting distinct entries in the Memory DenseMap. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81163 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/GlobalOpt.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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.