diff options
author | Wojciech Matyjewicz <wmatyjewicz@fastmail.fm> | 2008-06-02 17:26:12 +0000 |
---|---|---|
committer | Wojciech Matyjewicz <wmatyjewicz@fastmail.fm> | 2008-06-02 17:26:12 +0000 |
commit | 98e3a6829aaf070a8893a164d6dc8c75f9f9feaa (patch) | |
tree | 9c370b392634c81157b1ea1af941e872f60b3c49 /lib/Analysis/BasicAliasAnalysis.cpp | |
parent | 370a25c16af4394c2e800d63f9c7c0350f868948 (diff) |
Fixes PR2395. Looking for a constant in a GEP tail (when the first GEP
is longer than the second one) should stop after finding one. Added break
instruction guarantees it. It also changes difference between offsets to
absolute value of this difference in the condition.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51875 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r-- | lib/Analysis/BasicAliasAnalysis.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 21108c6453..599a6f650f 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -687,7 +687,7 @@ BasicAliasAnalysis::CheckGEPInstructions( if (isa<ConstantInt>(GEP1Ops[i]) && !cast<ConstantInt>(GEP1Ops[i])->isZero()) { // Yup, there's a constant in the tail. Set all variables to - // constants in the GEP instruction to make it suiteable for + // constants in the GEP instruction to make it suitable for // TargetData::getIndexedOffset. for (i = 0; i != MaxOperands; ++i) if (!isa<ConstantInt>(GEP1Ops[i])) @@ -702,9 +702,15 @@ BasicAliasAnalysis::CheckGEPInstructions( int64_t Offset2 = TD.getIndexedOffset(GEPPointerTy, GEP1Ops, MinOperands); + // Make sure we compare the absolute difference. + if (Offset1 > Offset2) + std::swap(Offset1, Offset2); + // If the tail provided a bit enough offset, return noalias! if ((uint64_t)(Offset2-Offset1) >= SizeMax) return NoAlias; + // Otherwise break - we don't look for another constant in the tail. + break; } } |