[Patch, Fortran] PR 41907 - regression fix; wrong-code involving optional arguments

Tobias Burnus burnus@net-b.de
Tue Nov 3 07:31:00 GMT 2009


(Next try - sourceware.org didn't like the email before.)

Hello all,

my previous patch* somehow got it wrong with regards to when a
  tmp = argument == NULL ? NULL : argument(.0)
  proc (tmp)
check is needed and when not.

The result was that Tonto (and thus CPU SPEC 2006) was crashing -> PR 41907


Cases and changes:

a) If one passes a non-array-descriptor optional dummy to as actual
argument to a non-array-descriptor dummy, no check is needed.  (missed
optimization)

b) If one passes an array-descriptor optional dummy to an
array-descriptor dummy, a check is needed (see below why).  (wrong-code
-> segfault)

c) If one dummy needs an array descriptor and the other doesn't, either
an array copying is involved or a reference of the type "argument.0[0]"
and thus one needs a check. (Unchanged, was working before)

I added a couple of tests to make sure that no wrong-code gets
introduced and that the optimizations indeed happen for (a) and for scalars.

 * * *

Regarding b: In principle, one would not need such a check as one could
directly pass the descriptor on. However, this does not work as the
current procedure is:

1. Convert the dummy argument such that the lower bounds start at "1"
(or some value) instead of the lbound of the actual argument. This
produces a handful of variables, but no array descriptor.

2. Create an array descriptor out of those variables

There is one unnecessary step involved. One could either pass the dummy
argument directly (though to grab it is difficult and there might be
issues with regards to using to restricted pointers pointing to the same
object). Or one uses already an array descriptor in step 1. I think
doing the latter is a sensible approach. There is now a
missed-optimization PR 41911.

 * * *

Build and regtested on x86-64-linux.
OK for the trunk?  (4.4 is not affected.)

Tobias

PS: Sorry for the breakage.

* http://gcc.gnu.org/ml/fortran/2009-10/msg00246.html ·
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41850
<http://gcc.gnu.org/ml/fortran/2009-10/msg00246.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: missing-opt.diff
Type: text/x-patch
Size: 3816 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20091103/fcfb470f/attachment.bin>


More information about the Gcc-patches mailing list