aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-09-07 22:34:43 +0000
committerDan Gohman <gohman@apple.com>2009-09-07 22:34:43 +0000
commit4a7e6b7a15cea1f8ead4d1bb1cf2e3a39a339cb3 (patch)
treeb4b2b816edb261ac3d50622c8ebf616fa2be113c
parentfd54a898be08e8da12cb2e99dbb63015083940a3 (diff)
downloadexternal_llvm-4a7e6b7a15cea1f8ead4d1bb1cf2e3a39a339cb3.zip
external_llvm-4a7e6b7a15cea1f8ead4d1bb1cf2e3a39a339cb3.tar.gz
external_llvm-4a7e6b7a15cea1f8ead4d1bb1cf2e3a39a339cb3.tar.bz2
Preserve the InBounds flag when evaluating a getelementptr instruction
into a getelementptr ConstantExpr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81162 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 594243c..293de6c 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2227,8 +2227,9 @@ static bool EvaluateFunction(Function *F, Constant *&RetVal,
for (User::op_iterator i = GEP->op_begin() + 1, e = GEP->op_end();
i != e; ++i)
GEPOps.push_back(getVal(Values, *i));
- InstResult =
- ConstantExpr::getGetElementPtr(P, &GEPOps[0], GEPOps.size());
+ InstResult = cast<GEPOperator>(GEP)->isInBounds() ?
+ ConstantExpr::getInBoundsGetElementPtr(P, &GEPOps[0], GEPOps.size()) :
+ ConstantExpr::getGetElementPtr(P, &GEPOps[0], GEPOps.size());
} else if (LoadInst *LI = dyn_cast<LoadInst>(CurInst)) {
if (LI->isVolatile()) return false; // no volatile accesses.
InstResult = ComputeLoadResult(getVal(Values, LI->getOperand(0)),