[flang-dev] Passing intent(in) to the midend
Alexey Zhikhartsev via flang-dev
flang-dev at lists.llvm.org
Thu Nov 28 12:55:00 PST 2019
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/flang-dev/attachments/20191128/869c00c8/attachment.html>
More information about the flang-dev
mailing list