From 7190d480758fd7fe2f9d87bee25b97468fcbf39f Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 10 Sep 2009 23:37:55 +0000 Subject: 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. llvm-svn: 81478 --- llvm/lib/VMCore/ConstantFold.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'llvm/lib/VMCore/ConstantFold.cpp') diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp index 701a195f7fd..da6c8d4f4bc 100644 --- a/llvm/lib/VMCore/ConstantFold.cpp +++ b/llvm/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(); -- cgit v1.2.3