[flang-dev] Passing intent(in) to the midend
Doerfert, Johannes via flang-dev
flang-dev at lists.llvm.org
Mon Dec 2 09:53:30 PST 2019
If you mark the argument as
noalias, readonly, nofree, dereferenceable(4)
in LLVM-IR you should see the desired effects, e.g. load coalescing.
The way I understand `intent(in)` the above should be valid.
I hope this helps,
On 11/28, Alexey Zhikhartsev via flang-dev wrote:
> Consider the following code:
> integer :: arr1(42), arr2(42) ! global
> recursive subroutine foo(a)
> integer, intent(in) :: a
> ! first load of "a" here
> if (a > 20) then
> arr1(0) = a
> call foo(a + 1)
> arr2(0) = a ! <- redundant load here
> end subroutine foo
> As per the Fortran 90 standard , `intent(in)` for variable `a`
> "specifies that the dummy argument must not be redefined or become
> undefined during the execution of the procedure". Thus, we can assume that
> the call to `foo()` does not modify `a`, so the redundant load can be
> safely removed (e.g., by the GVN pass in the midend).
> How can we pass the intent(in) information to the midend so we could take
> advantage of it?
>  The Fortran 90 standard, section 184.108.40.206
> flang-dev mailing list
> flang-dev at lists.llvm.org
Argonne National Laboratory
Lemont, IL 60439, USA
jdoerfert at anl.gov
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 228 bytes
Desc: not available
More information about the flang-dev