[Bug target/47564] [4.6 Regression] internal compiler error in memory_address_addr_space, at explow.c:504

2011-02-03 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47564

--- Comment #9 from Jakub Jelinek jakub at gcc dot gnu.org 2011-02-03 
08:29:07 UTC ---
Author: jakub
Date: Thu Feb  3 08:29:03 2011
New Revision: 169784

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=169784
Log:
PR target/47564
* toplev.c (target_reinit): Save and restore *crtl and regno_reg_rtx
around backend_init_target and lang_dependent_init_target calls.
* cgraphunit.c (cgraph_debug_gimple_stmt): New function.
(verify_cgraph_node): Don't call set_cfun here.  Use
cgraph_debug_gimple_stmt instead of debug_gimple_stmt.
Set error_found for incorrectly represented calls to thunks.

* gcc.target/i386/pr47564.c: New test.

Added:
trunk/gcc/testsuite/gcc.target/i386/pr47564.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/cgraphunit.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/toplev.c


[Bug target/47564] [4.6 Regression] internal compiler error in memory_address_addr_space, at explow.c:504

2011-02-03 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47564

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution||FIXED

--- Comment #10 from Jakub Jelinek jakub at gcc dot gnu.org 2011-02-03 
08:32:44 UTC ---
Fixed.


[Bug target/47564] [4.6 Regression] internal compiler error in memory_address_addr_space, at explow.c:504

2011-02-02 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47564

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 AssignedTo|unassigned at gcc dot   |jakub at gcc dot gnu.org
   |gnu.org |

--- Comment #8 from Jakub Jelinek jakub at gcc dot gnu.org 2011-02-02 
10:00:11 UTC ---
Created attachment 23211
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=23211
gcc46-pr47564.patch

Updated fix.  For 4.7 I'd say we want to split this reinitialization up, into
reinitializations that matter for tree optimizations (ideally those could be
saved into (and restored from) some save area pointed to from
TARGET_OPTION_NODE, e.g. init_set_costs can be saved into target_cfgloop
structure), and initializations that only matter from expand_gimple_cfg entry
till free_after_compilation (there we could remember the last
TARGET_OPTION_NODE (or global) and if current TARGET_OPTION_NODE (or global) is
different from it, call the init_* calls at the beginning of expand_gimple_cfg.


[Bug target/47564] [4.6 Regression] internal compiler error in memory_address_addr_space, at explow.c:504

2011-02-01 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47564

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

Summary|internal compiler error in  |[4.6 Regression] internal
   |memory_address_addr_space,  |compiler error in
   |at explow.c:504 |memory_address_addr_space,
   ||at explow.c:504

--- Comment #5 from Jakub Jelinek jakub at gcc dot gnu.org 2011-02-01 
12:32:51 UTC ---
I get the ICE on x86_64-linux -m64 -O2 too, so that's not it.
Started failing with
http://gcc.gnu.org/viewcvs?root=gccview=revrev=167964


[Bug target/47564] [4.6 Regression] internal compiler error in memory_address_addr_space, at explow.c:504

2011-02-01 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47564

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2011.02.01 14:18:55
   Target Milestone|--- |4.6.0
 Ever Confirmed|0   |1


[Bug target/47564] [4.6 Regression] internal compiler error in memory_address_addr_space, at explow.c:504

2011-02-01 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47564

--- Comment #6 from Jakub Jelinek jakub at gcc dot gnu.org 2011-02-01 
14:40:50 UTC ---
Created attachment 23198
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=23198
gcc46-pr47564.patch

Ugh, this is ugly.
The problem is that tree_rest_of_compilation calls init_emit and lots of other
init* functions and assumes x_rtl will stay initialized until expansion.
But if during any of the following optimization passes set_cfun is called to
some other function which has different target options, target_reinit is
called, which calls free_after_compilation which will clear x_rtl.
Among other things it clears reg_rtx_no, which means when expanding E pseudo
allocation starts from 0 instead of first pseudo (i.e. allocates various
hard/virtual registers first, which of course can't lead to anything sane).

Most of the set_cfun calls actually came from cgraph verification, where it is
not really needed - IMHO we can set_cfun there just when we are about to
diagnose an issue and when we do that, we will internal_error at the end of
function anyway and thus don't have to worry about restoring it at all.  The
attached patch fixes that.

On the testcase there is another set_cfun call after tree_rest_of_compilation
has been called though, in particular from cgraph_release_function_body during
inlining (called from cgraph_release_node).  I guess in such a case we don't
actually need target reinit, perhaps we could just change cfun after saving the
previous value, instead of using push_cfun/pop_cfun.

Or perhaps target_reinit could save x_rtl copy before it and restore it
afterwards, so that it doesn't clear it if it wasn't all 0's before.


[Bug target/47564] [4.6 Regression] internal compiler error in memory_address_addr_space, at explow.c:504

2011-02-01 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47564

--- Comment #7 from Jakub Jelinek jakub at gcc dot gnu.org 2011-02-01 
15:47:07 UTC ---
Following works by not doing target_reinit once tree_rest_of_compilation calls
init_function_start, until final.
--- function.c.jj 2011-01-25 18:40:08.0 +0100
+++ function.c 2011-02-01 16:33:48.0 +0100
@@ -4294,7 +4294,10 @@ invoke_set_current_function_hook (tree f
   cl_optimization_restore (global_options, TREE_OPTIMIZATION (opts));
 }

-  targetm.set_current_function (fndecl);
+  /* Don't call targetm.set_current_function in between
+ prepare_function_start and following free_after_compilation.  */
+  if (regno_reg_rtx == NULL)
+targetm.set_current_function (fndecl);
 }
 }