[PATCH] D76210: [Attributor] AAReachability : use isPotentiallyReachable in isKnownReachable

Shinji Okumura via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 16 06:26:25 PDT 2020


okura added a comment.

In D76210#1923914 <https://reviews.llvm.org/D76210#1923914>, @uenoku wrote:

>   void use(int *);
>   __attribute__((noinline)) static void f1(int * restrict p, int c1, int c2) {
>     if (c1) {
>       use(p);
>     }
>     if (!c2) {
>       use(p);
>     }
>   }
>   void f2(int * restrict p, int c) { f1(p, c, c); }
>
>
> Could you add this example to test?
>  In this case, c1 and c2 are always same. Because of flow sensitivity,  the first callsite is not reachable to the second callsite. So %p is noalias at both callsites. It can't be deduced with `isPotentiallyReachable` so please add FIXME tag.


This makes sense to me, thank you for your suggestion. I added a slightly different test.
If function `use` does not make any alias of p (such as `only_store` in test), noalias can be deduced with the current implementation. But if we impose any constraints on `use`, noalias should not be deduced.
Therefore, I add a test corresponding to the following C program.

  __attribute__((noinline)) static void test16_sub(int * restrict p, int c1, int c2) {
    if (c1) {
      only_store(p);
      make_alias(p);
    }
    if (!c2) {
      only_store(p);
    }
  }
  void test16_caller(int * restrict p, int c) {
    test16_sub(p, c, c);
  }

Like as your test, %p is noalias at both calllsites of `only_store`. But it is currently not deduced for the second callsite.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76210/new/

https://reviews.llvm.org/D76210





More information about the llvm-commits mailing list