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: -fargument-noalias-global question


[ Happy New Year first of all - hope we don't have too many more of them
  ... Hey, you can recognize a Jimi Hendrix fan, don't you ]

Richard Guenther wrote:

Actually I have two questions.  First, what is the difference between
-fargument-noalias-global and -fargument-noalias-anything (please
provide an example, not cite documentation ;))

svn blame should point to me as the culprit. I invented -fargument-noalias-anything because I ran out of specifics Fortran argument pointers *do not point at*.


The pointers used by the Fortran Front End to implement Fortran's argument association *cannot* point to anything else than the storage of those arguments, because they (those pointers) are generated by the compiler and cannot point to anything else (they cannot be modified).

Whether or not -fargument-noalias-anything is useful for languages other than Fortran is anybody's guess (I'm betting on "none").

Second question.  Does "global memory" include memory that escaped?
Thus, with -fargument-noalias-global:

The "global" in -fargument-noalias-global refers to data in COMMON. Again, it is hard to see how this option could be useful outside Fortran.


Note that COMMON data in Fortran escapes by default, because it can be accessible in any other compilation unit (just by including the COMMON declaration).

int *p;
void foo(int *q)
{
  may *q and *p alias?
}

The canonical Fortran example is:


      SUBROUTINE AAP(P)
      COMMON /NOOT/ Q

P (which is a pointer in the backend sense of the word - it's not a Fortran pointer) cannot point to the memory indicated by Q.

consider

void bar()
{
  int i;
  p = &i;
  foo (&i);
}

does that call to foo invoke undefined behavior if built with
-fargument-noalias-global?

It shouldn't, as 'int i' isn't global. Now a more interesting question (one that I do not know the answer to, because these flags were targeted at Fortran code) is whether this would wreck havoc in case of 'static int i' :-)


Is _that_ the difference vs.
-fargument-noalias-anything (-global would not alias global
decls, -anything would not alias any reachable memory (other than
what the parameter reaches?  or just what it points to?)).

-anything means that it can't point to anything else but its arguments memory.


-global means it cannot point to global memory (but it assumes global memory works like Fortran's COMMON).

Thanks for clarifications.
Richard.

Hope this helps,


--
Toon Moene - e-mail: toon@moene.org (*NEW*) - phone: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
At home: http://moene.org/~toon/
Progress of GNU Fortran: http://gcc.gnu.org/gcc-4.4/changes.html


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