From 184166da619ac7f14d8460b4b0f8f85bfc601ebc Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Thu, 8 Sep 2011 02:37:07 +0000 Subject: [PATCH] A couple minor corrections to r139276. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139277 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/BasicAliasAnalysis.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 45bc624d83e..4b7d2f5d9dc 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -977,20 +977,20 @@ BasicAliasAnalysis::aliasGEP(const GEPOperator *GEP1, uint64_t V1Size, // Try to distinguish something like &A[i][1] against &A[42][0]. // Grab the least significant bit set in any of the scales. - uint64_t Modulo = 0; - for (unsigned i = 0, e = GEP1VariableIndices.size(); - i != e; ++i) - Modulo |= (uint64_t)GEP1VariableIndices[0].Scale; - Modulo = Modulo ^ (Modulo & (Modulo - 1)); - - // We can compute the difference between the two addresses - // mod Modulo. Check whether that difference guarantees that the - // two locations do not alias. - uint64_t ModOffset = (uint64_t)GEP1BaseOffset & (Modulo - 1); - if (V1Size != UnknownSize && V2Size != UnknownSize && - ModOffset >= V2Size && V1Size <= Modulo - ModOffset) - return NoAlias; + if (!GEP1VariableIndices.empty()) { + uint64_t Modulo = 0; + for (unsigned i = 0, e = GEP1VariableIndices.size(); i != e; ++i) + Modulo |= (uint64_t)GEP1VariableIndices[i].Scale; + Modulo = Modulo ^ (Modulo & (Modulo - 1)); + // We can compute the difference between the two addresses + // mod Modulo. Check whether that difference guarantees that the + // two locations do not alias. + uint64_t ModOffset = (uint64_t)GEP1BaseOffset & (Modulo - 1); + if (V1Size != UnknownSize && V2Size != UnknownSize && + ModOffset >= V2Size && V1Size <= Modulo - ModOffset) + return NoAlias; + } // Statically, we can see that the base objects are the same, but the // pointers have dynamic offsets which we can't resolve. And none of our