[PATCH] D36800: Add rewrite by-reference parameter pass

Tobias Grosser via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 18 13:45:58 PDT 2017


grosser added a comment.

In https://reviews.llvm.org/D36800#844034, @etherzhhb wrote:

> In https://reviews.llvm.org/D36800#844026, @grosser wrote:
>
> > It's certainly not too late. Until now it seemed to me like a very specific optimization for gfortran. I did not see any such examples before. If we can generalize this, we can certainly try to upstream this. Could you share some of the examples you are seeing?
>
>
> "by-reference" is one side, another side is the function return something via a pointer argument (e.g. the opencl sincos function)[1]:
>
>   int *p;
>   a = return_via_p(p);
>
>
> We want to transform it to:
>
>   { a, b } = return_via_p();
>   *p = b;
>
>
> Also, a pointer can be read-modify-write:
>
>   int *p;
>   a = read_modify_write_p(p);
>
>
> we want to transform it to:
>
>   int *p;
>   int pin = *p;
>   {a, b} = read_modify_write_p(pin);
>   *p = b;
>


I see. These all seem to require us to modify the function declarations. Hence, are likely out-of-scope for a function pass, but certainly a good fit for the argument promotion pass. Feel free to add me as a reviewer in case you would like to contribute patches for your two examples.

As the fortran functions are part of an external library the change I committed here likely does not benefit from argpromotion.

Best,
Tobias


Repository:
  rL LLVM

https://reviews.llvm.org/D36800





More information about the llvm-commits mailing list