This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to express the fact that arguments don't escape?


Janne Blomqvist wrote:
Tobias Schlüter wrote:

Hi,


I reviewed some old discussions on argument passing, but I found nothing which addressed a seemingly simple optimization for Fortran: what I would like to see is a way to tell the compiler that a function argument (which will be a pointer) will not have escaped after the function has returned. I.e.
call f(i)
i = 1
call g(j) ! won't know about i
if (i != 1) then
can't happen
end if


Is there a way to do this? Unless I'm mistaken, this assumption holds for all non-POINTER arguments.

Shouldn't the recent patch by Michael Matz fix this?


http://gcc.gnu.org/ml/fortran/2009-08/msg00104.html

By marking j as a restricted pointer it should know that it can't escape and alias i.

It's not about j aliasing i, it's about f storing a pointer to i somewhere which then can be used to modify i in a different function call. Sorry if that wasn't clear.


Cheers,
- Tobi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]