This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC 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]

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


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.


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