[PATCH] D20665: Claim NoAlias if two GEPs index different fields of the same struct

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 17:30:09 PDT 2016


On Wed, Jun 1, 2016 at 5:08 PM, Eli Friedman <eli.friedman at gmail.com> wrote:

> eli.friedman added a subscriber: eli.friedman.
>
> ================
> Comment at: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp:842
> @@ +841,3 @@
> +  // of the same struct, they do not alias.
> +  if (GEP1->isInBounds() && GEP2->isInBounds()) {
> +    auto Opi1 = GEP1->op_begin() + 1;
> ----------------
> You aren't allowed to make aliasing assumptions based on the type of a GEP;



> it's just pointer math.  "inbounds" just means that the result has to be
> in bounds relative to the allocation as a whole.  See
> http://llvm.org/docs/LangRef.html#getelementptr-instruction .
>
>
It's still, AFAIK, proving that that the pointer math comes out different
for those two geps.
That is, those two geps generate different pointers.

It doesn't say the access is illegal in some way, it simply says "field a
and b aren't at the same offset, so this gep and that gep, converted to
pointers to anything, can't be the same pointer".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160601/a4973f2f/attachment.html>


More information about the llvm-commits mailing list