[llvm-commits] [llvm] r81163 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
Dan Gohman
gohman at apple.com
Mon Sep 7 15:40:13 PDT 2009
Author: djg
Date: Mon Sep 7 17:40:13 2009
New Revision: 81163
URL: http://llvm.org/viewvc/llvm-project?rev=81163&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=81163&r1=81162&r2=81163&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Sep 7 17:40:13 2009
@@ -2032,7 +2032,8 @@
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C))
// Handle a constantexpr gep.
if (CE->getOpcode() == Instruction::GetElementPtr &&
- isa<GlobalVariable>(CE->getOperand(0))) {
+ isa<GlobalVariable>(CE->getOperand(0)) &&
+ cast<GEPOperator>(CE)->isInBounds()) {
GlobalVariable *GV = cast<GlobalVariable>(CE->getOperand(0));
// Do not allow weak/linkonce/dllimport/dllexport linkage or
// external globals.
More information about the llvm-commits
mailing list