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?


On Sat, 2009-08-15 at 13:11 +0200, Thomas Koenig wrote:
> On Sat, 2009-08-15 at 12:11 +0200, Richard Guenther wrote:
> > > To stay within the current, C-centric framework of gcc, we'll need
> > to do
> > > even more copying.
> > 
> > Yes, of course.
> 
> What about the following pseudo-code:  For an scalar argument integer i,
> to the subroutine foo with the corresponding dummy argument i_dummy, we
> can the do (pseudo code)
> 
> if (optimize || ! is_target(i_dummy)) {
>    int i_temp;
>    if (intent_inout(i_dummy) || intent_in(i_dummy) || intent_unpecified(i_dummy))
>       i_temp = i;
>    call foo(&i_temp);
>    if (is_no_active_do_loop_variable(i)
>         && (intent_inout(i_dummy) || intent_out(i_dummy) || intent_unspecified(i_dummy)))
>      i = i_temp;
> }

Actually, pointers must not escape unless i has the target attribute,
and they cannot escape if the dummy argument doesn't have it.

So, the pseudo-code should read

if (optimize && (!has_target_attribute(i) || !has_target_attribute(i_dummy)) && is_gimple_reg_type(i)) {
    int i_temp;
    i_temp = i;
    call foo(&i_temp);
    if (is_no_active_do_loop_variable(i)
          && (intent_inout(i_dummy) || intent_out(i_dummy) || intent_unspecified(i_dummy)))
        i = i_temp;

Sounds reasonable?


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