[PATCH] D39008: [CodeGen] Propagate may-alias'ness of lvalues with TBAA info

Ivan Kosarev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 25 09:12:40 PDT 2017

kosarev added a comment.

Now that https://reviews.llvm.org/D38796 is comitted and added the tbaa-cast.cpp test case to the mainline, we fail on it with this patch applied. The reason is that we have no special TBAA type node for may-alias accesses, so everything that ever been a potential access to a character type turns into a may-alias access and propagates as such.

The test case reads:

  struct V {
    unsigned n;
  struct S {
    char bytes[4];
  void foo(S *p) {
    ((V*)p->bytes)->n = 5;

Here, p->bytes decays to a pointer to char, meaning the pointee object is considered may-alias and so it is after the explicit cast.

This arises an interesting question: should we introduce a special representation for may-alias accesses to distinct them from character-typed accesses? Or, maybe explicit casts should not derive their may-alias'ness from their source operands? Or, maybe we want to consider all explicit casts of the form ##(T*)E## where ##T*## and ##typeof(E)## point to different types as pointers to may-alias objects?



More information about the cfe-commits mailing list