[llvm-commits] [llvm] r84079 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/2009-10-13-GEP-BaseNoAlias.ll

Evan Cheng evan.cheng at apple.com
Wed Oct 14 11:10:14 PDT 2009


On Oct 14, 2009, at 6:52 AM, Török Edwin wrote:

> On 2009-10-14 09:41, Evan Cheng wrote:
> 
> Hi Evan,
> 
> This gives MayAlias for a[4] and a[5], right? I think you shouldn't exit
> for a MayAlias return, only for a NoAlias result:
> you should check whether the [index1, index1+size1), and [index2,
> index2+size2)  ranges overlap, which you seem to be doing later.

No. a[4] and a[5] case is caught earlier in if (isGEP(V1) && isGEP(V2)) { .. } Their bases MustAlias.

Evan

> 
> 
>> +    // If V2 is known not to alias GEP base pointer, then the two values
>> +    // cannot alias per GEP semantics: "A pointer value formed from a
>> +    // getelementptr instruction is associated with the addresses associated
>> +    // with the first operand of the getelementptr".
>> +    return R;
>> +
>> +  // If there is at least one non-zero constant index, we know they cannot
>> +  // alias.
>> +  bool ConstantFound = false;
>> +  bool AllZerosFound = true;
>> +  for (unsigned i = 0, e = GEPOperands.size(); i != e; ++i)
>> +    if (const Constant *C = dyn_cast<Constant>(GEPOperands[i])) {
>> +      if (!C->isNullValue()) {
>> +        ConstantFound = true;
>>         AllZerosFound = false;
>> +        break;
>>       }
>> +    } else {
>> +      AllZerosFound = false;
>> +    }
>> 
>> -    // If we have getelementptr <ptr>, 0, 0, 0, 0, ... and V2 must aliases
>> -    // the ptr, the end result is a must alias also.
>> -    if (AllZerosFound)
>> -      return MustAlias;
>> +  // If we have getelementptr <ptr>, 0, 0, 0, 0, ... and V2 must aliases
>> +  // the ptr, the end result is a must alias also.
>> +  if (AllZerosFound)
>> +    return MustAlias;
>> 
>> -    if (ConstantFound) {
>> -      if (V2Size <= 1 && V1Size <= 1)  // Just pointer check?
>> -        return NoAlias;
>> +  if (ConstantFound) {
>> +    if (V2Size <= 1 && V1Size <= 1)  // Just pointer check?
>> +      return NoAlias;
>> 
>> -      // Otherwise we have to check to see that the distance is more than
>> -      // the size of the argument... build an index vector that is equal to
>> -      // the arguments provided, except substitute 0's for any variable
>> -      // indexes we find...
>> -      if (TD &&
>> -          cast<PointerType>(BasePtr->getType())->getElementType()->isSized()) {
>> -        for (unsigned i = 0; i != GEPOperands.size(); ++i)
>> -          if (!isa<ConstantInt>(GEPOperands[i]))
>> -            GEPOperands[i] = Constant::getNullValue(GEPOperands[i]->getType());
>> -        int64_t Offset =
>> -          TD->getIndexedOffset(BasePtr->getType(),
>> -                               &GEPOperands[0],
>> -                               GEPOperands.size());
>> +    // Otherwise we have to check to see that the distance is more than
>> +    // the size of the argument... build an index vector that is equal to
>> +    // the arguments provided, except substitute 0's for any variable
>> +    // indexes we find...
>> 
> 
> However I don't see how this code is reached if the AA returns MayAlias
> for a[4] and a[5], as the manual states:
> The MayAlias response is used whenever the two pointers might refer to
> the same object. If the two memory objects overlap, but do not start at
> the same location, return MayAlias.
> 
> Best regards,
> --Edwin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20091014/04176218/attachment.html>


More information about the llvm-commits mailing list