diff options
author | Dan Gohman <gohman@apple.com> | 2009-09-10 23:37:55 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-09-10 23:37:55 +0000 |
commit | 7190d480758fd7fe2f9d87bee25b97468fcbf39f (patch) | |
tree | dbad9ff5ee1c824d547c5909303d3221c5cbedd6 /llvm/lib/VMCore/ConstantFold.cpp | |
parent | 8ef65fbd49bdcd41583424ef40b4ddbd04d7908a (diff) | |
download | bcm5719-llvm-7190d480758fd7fe2f9d87bee25b97468fcbf39f.tar.gz bcm5719-llvm-7190d480758fd7fe2f9d87bee25b97468fcbf39f.zip |
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
Diffstat (limited to 'llvm/lib/VMCore/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/VMCore/ConstantFold.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
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(); |