[Bug fortran/30720] runtime: check for empty array slices before allocating a negative amount of memory

2007-02-09 Thread fxcoudert at gcc dot gnu dot org


--- Comment #8 from fxcoudert at gcc dot gnu dot org  2007-02-09 20:31 
---
Subject: Bug 30720

Author: fxcoudert
Date: Fri Feb  9 20:31:18 2007
New Revision: 121773

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=121773
Log:
PR fortran/30720

* trans-array.c (gfc_trans_create_temp_array): Remove use of the
function argument. Always generate code for negative extent.
Simplify said code.
* trans-array.h (gfc_trans_create_temp_array): Change prototype.
* trans-expr.c (gfc_conv_function_call): Remove use of last argument
of gfc_trans_create_temp_array.
* trans-intrinsic.c (gfc_conv_intrinsic_array_transfer): Likewise.
* trans-stmt.c (gfc_conv_elemental_dependencies): Likewise.

* gfortran.dg/array_function_1.f90: New test.

Added:
trunk/gcc/testsuite/gfortran.dg/array_function_1.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/trans-array.c
trunk/gcc/fortran/trans-array.h
trunk/gcc/fortran/trans-expr.c
trunk/gcc/fortran/trans-intrinsic.c
trunk/gcc/fortran/trans-stmt.c
trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30720



[Bug fortran/30720] runtime: check for empty array slices before allocating a negative amount of memory

2007-02-07 Thread tkoenig at gcc dot gnu dot org


--- Comment #5 from tkoenig at gcc dot gnu dot org  2007-02-07 17:52 ---
Hi FX,


 do you remember why always performing that check (ie, turn function to be
 always true) is not the right thing to do?

When working on this, I hit numerous testsuite regressions
when always checking for negative extents, and I couldn't find
out why.  So I only fixed the code path for the particular PR.

If you find something that works without that argument (which is
a bit of a kudge), so much the better.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30720



[Bug fortran/30720] runtime: check for empty array slices before allocating a negative amount of memory

2007-02-07 Thread fxcoudert at gcc dot gnu dot org


--- Comment #6 from fxcoudert at gcc dot gnu dot org  2007-02-07 19:10 
---
(In reply to comment #5)
 If you find something that works without that argument (which is
 a bit of a kudge), so much the better.

The patch I attached removes this argument, and it gives no regression on the
testsuite. I also simplified the conditional expression by using a COND_EXPR
instead of generating different blocks. Would you mind looking at it to see if
you spot anything odd?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30720



[Bug fortran/30720] runtime: check for empty array slices before allocating a negative amount of memory

2007-02-07 Thread tkoenig at gcc dot gnu dot org


--- Comment #7 from tkoenig at gcc dot gnu dot org  2007-02-07 20:49 ---
(In reply to comment #6)

 The patch I attached removes this argument, and it gives no regression on the
 testsuite. I also simplified the conditional expression by using a COND_EXPR
 instead of generating different blocks. Would you mind looking at it to see if
 you spot anything odd?

From eyballing the patch, it looks OK.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30720



[Bug fortran/30720] runtime: check for empty array slices before allocating a negative amount of memory

2007-02-06 Thread fxcoudert at gcc dot gnu dot org


--- Comment #1 from fxcoudert at gcc dot gnu dot org  2007-02-06 20:34 
---
Confirming this bug (both of them, actually).

For the missed-optimization, I think there's no reason to keep a library
function _gfortran_internal_free(x) that is equivalent to if(x) free(x);, we
should generate that code directly.


-- 

fxcoudert at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
 Ever Confirmed|0   |1
   Keywords||missed-optimization, wrong-
   ||code
  Known to fail||4.3.0
   Last reconfirmed|-00-00 00:00:00 |2007-02-06 20:34:23
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30720



[Bug fortran/30720] runtime: check for empty array slices before allocating a negative amount of memory

2007-02-06 Thread fxcoudert at gcc dot gnu dot org


--- Comment #2 from fxcoudert at gcc dot gnu dot org  2007-02-06 21:00 
---
The wrong-code bug happens in gfc_trans_create_temp_array. For some reason, the
function argument to that function is false, and the code present to take care
of negative extent is not triggered. Thomas, you're the one who introduced this
argument:

2006-06-15  Thomas Koenig [EMAIL PROTECTED]

* trans-array.h (gfc_trans_create_temp_array):  Add bool
argument.
* trans-arrray.c (gfc_trans_create_temp_array): Add extra
argument function to show if we are translating a function.
If we are translating a function, perform checks whether
the size along any argument is negative.  In that case,
allocate size 0.

do you remember why always performing that check (ie, turn function to be
always true) is not the right thing to do?


-- 

fxcoudert at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||tkoenig at gcc dot gnu dot
   ||org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30720



[Bug fortran/30720] runtime: check for empty array slices before allocating a negative amount of memory

2007-02-06 Thread fxcoudert at gcc dot gnu dot org


--- Comment #3 from fxcoudert at gcc dot gnu dot org  2007-02-06 23:13 
---
To keep things separate, I filed PR30723 for the missed optimization.


-- 

fxcoudert at gcc dot gnu dot org changed:

   What|Removed |Added

   Keywords|missed-optimization |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30720



[Bug fortran/30720] runtime: check for empty array slices before allocating a negative amount of memory

2007-02-06 Thread fxcoudert at gcc dot gnu dot org


--- Comment #4 from fxcoudert at gcc dot gnu dot org  2007-02-06 23:16 
---
Created an attachment (id=13018)
 -- (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13018action=view)
Patch for this bug

Here's the patch I propose. It makes the code simpler by using a cond_expr
instead of using different statement blocks. Regtested in an earlier version on
i686-linux, regtesting of the current version in progress.


-- 

fxcoudert at gcc dot gnu dot org changed:

   What|Removed |Added

 AssignedTo|unassigned at gcc dot gnu   |fxcoudert at gcc dot gnu dot
   |dot org |org
 Status|NEW |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30720