[PATCH] D31885: Remove TBAA information from LValues representing union members

Hal Finkel via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 14 11:56:28 PDT 2017


hfinkel added a comment.

In https://reviews.llvm.org/D31885#727371, @efriedma wrote:

> In https://reviews.llvm.org/D31885#727167, @hfinkel wrote:
>
> > I'm not sure this is the right way to do this; I suspect we're lumping together a bunch of different bugs:
> >
> > 1. vector types need to have tbaa which makes them alias with their element types [to be clear, as vector types are an implementation extension, this is our choice; I believe most users expect this to be true, but I'm certainly open to leaving this as-is (i.e. the vector types and scalar types as independent/non-aliasing)].
> > 2. tbaa can't be used for write <-> write queries (only read <-> write queries) because the writes can change the effective type
> > 3. our 'struct' path TBAA for unions is broken (and to fix this we need to invert the tree structure, etc. as discussed on the list)
>
>
> See https://bugs.llvm.org/show_bug.cgi?id=28189 for a testcase for (2) for this which doesn't involve unions.


Yes, this is what I had in mind. However, we may just want to not handle this at all. The demonstration you provide:

  #include <stdio.h>
  #include <string.h>
  #include <stdlib.h>
  int f(int* x, int *y) {
    *x = 10;
    int z = *y;
    *(float*)x = 1.0;
    return z;
  }
  int (*ff)(int*,int*) = f;
  int main() {
    void* x = malloc(4);
    printf("%d\n", ff(x, x));
  }

shows that the problem is more than I implied. To support this, we not only need to ignore the TBAA between the two writes (*x and *(float*)x), but also between the float write and the preceding int read. I wonder how much of TBAA we could keep at all and still support this. Thoughts?


Repository:
  rL LLVM

https://reviews.llvm.org/D31885





More information about the cfe-commits mailing list