[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


Hi Alexey,

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,
  Johannes

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
> 
>       return
> 
>     endif
> 
> 
>     arr1(0) = a
> 
>     call foo(a + 1)
> 
>     arr2(0) = a ! <- redundant load here
> 
>     end subroutine foo
> 
> 
> 
> As per the Fortran 90 standard [1], `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?
> 
> [1] The Fortran 90 standard, section 5.1.2.3
> https://wg5-fortran.org/N001-N1100/N692.pdf
> 
> Best,
> 
> Alexey

> _______________________________________________
> flang-dev mailing list
> flang-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/flang-dev


-- 

Johannes Doerfert
Researcher

Argonne National Laboratory
Lemont, IL 60439, USA

jdoerfert at anl.gov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-dev/attachments/20191202/db0d0f6b/attachment.sig>


More information about the flang-dev mailing list