From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11916 invoked by alias); 1 Feb 2011 14:41:25 -0000 Received: (qmail 11833 invoked by uid 22791); 1 Feb 2011 14:41:23 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 01 Feb 2011 14:41:19 +0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/47564] [4.6 Regression] internal compiler error in memory_address_addr_space, at explow.c:504 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.6.0 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Tue, 01 Feb 2011 14:41:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-02/txt/msg00092.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47564 --- Comment #6 from Jakub Jelinek 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.