aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-09-10 23:37:55 +0000
committerDan Gohman <gohman@apple.com>2009-09-10 23:37:55 +0000
commite6992f728a94654e43269580a10a667f18dadba9 (patch)
tree5e6c18363d9917d22eec2a3f54d9c9c24dd37aee /lib/VMCore/ConstantFold.cpp
parent83e3c4f9d796a5da223a3ebd5d4ba985c7ecc39d (diff)
Factor out the code for checking that all indices in a getelementptr are
within the notional bounds of the static type of the getelementptr (which is not the same as "inbounds") from GlobalOpt into a utility routine, and use it in ConstantFold.cpp to check whether there are any mis-behaved indices. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81478 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/ConstantFold.cpp')
-rw-r--r--lib/VMCore/ConstantFold.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 701a195f7f..da6c8d4f4b 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -1329,6 +1329,14 @@ static ICmpInst::Predicate evaluateICmpRelation(LLVMContext &Context,
// ordering of the resultant pointers.
unsigned i = 1;
+ // The logic below assumes that the result of the comparison
+ // can be determined by finding the first index that differs.
+ // This doesn't work if there is over-indexing in any
+ // subsequent indices, so check for that case first.
+ if (!CE1->isGEPWithNoNotionalOverIndexing() ||
+ !CE2->isGEPWithNoNotionalOverIndexing())
+ return ICmpInst::BAD_ICMP_PREDICATE; // Might be equal.
+
// Compare all of the operands the GEP's have in common.
gep_type_iterator GTI = gep_type_begin(CE1);
for (;i != CE1->getNumOperands() && i != CE2->getNumOperands();