From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14173 invoked by alias); 20 Sep 2009 11:18:57 -0000 Received: (qmail 14163 invoked by uid 22791); 20 Sep 2009 11:18:56 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,SPF_FAIL X-Spam-Check-By: sourceware.org Received: from mx20.gnu.org (HELO mx20.gnu.org) (199.232.41.8) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 20 Sep 2009 11:18:52 +0000 Received: from [65.74.133.4] (helo=mail.codesourcery.com) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MpKRN-0005kK-3Q for gcc@gcc.gnu.org; Sun, 20 Sep 2009 07:18:50 -0400 Received: (qmail 539 invoked from network); 20 Sep 2009 11:18:44 -0000 Received: from unknown (HELO mbp.local) (maxim@127.0.0.2) by mail.codesourcery.com with ESMTPA; 20 Sep 2009 11:18:44 -0000 Message-ID: <4AB60F8B.7000009@codesourcery.com> Date: Sun, 20 Sep 2009 11:18:00 -0000 From: Maxim Kuvyrkov User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: Richard Guenther CC: GCC , Jason Merrill Subject: Re: [RFA] dwarf2out.c:eliminate_regs() bug References: <4AB5DBF5.5060104@codesourcery.com> <84fc9c000909200203n26d5a139kf90659acd3039a36@mail.gmail.com> In-Reply-To: <84fc9c000909200203n26d5a139kf90659acd3039a36@mail.gmail.com> Content-Type: multipart/mixed; boundary="------------040806040406070602020401" X-detected-operating-system: by mx20.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-09/txt/msg00373.txt.bz2 This is a multi-part message in MIME format. --------------040806040406070602020401 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1040 Richard Guenther wrote: > On Sun, Sep 20, 2009 at 9:38 AM, Maxim Kuvyrkov wrote: ... >> This code uses eliminate_regs(), which implicitly assumes reload_completed >> as it uses reg_eliminate[], which assumes that frame_pointer_needed is >> properly set, which happens in ira.c. However, in some cases this piece of >> based_loc_descr() can be reached during inlining pass (see backtrace below). >> When called before reload, eliminate_regs() may return an inconsistent >> result which is why the assert in based_loc_descr() fails. In the >> particular testcase I'm investigating, frame_pointer_needed is 0 (initial >> value), but eliminate_regs returns stack_pointer_rtx because it is guided by >> reg_eliminate information from the previous function which had >> frame_pointer_needed set to 1. ... > I think you should avoid calling eliminate_regs for DECL_ABSTRACT > current_function_decl. That should cover the inliner path. Thanks for the insight. Do you mean something like the attached patch? -- Maxim --------------040806040406070602020401 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="dwarf2-abstract.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="dwarf2-abstract.patch" Content-length: 1697 Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 261914) +++ gcc/dwarf2out.c (working copy) @@ -9862,8 +9862,11 @@ based_loc_descr (rtx reg, HOST_WIDE_INT /* We only use "frame base" when we're sure we're talking about the post-prologue local stack frame. We do this by *not* running register elimination until this point, and recognizing the special - argument pointer and soft frame pointer rtx's. */ - if (reg == arg_pointer_rtx || reg == frame_pointer_rtx) + argument pointer and soft frame pointer rtx's. + We might get here during the inlining pass (DECL_ABSTRACT is true then), + so don't try eliminating registers in such a case. */ + if (!DECL_ABSTRACT (current_function_decl) + && (reg == arg_pointer_rtx || reg == frame_pointer_rtx)) { rtx elim = eliminate_regs (reg, VOIDmode, NULL_RTX); @@ -12224,6 +12227,9 @@ compute_frame_pointer_to_fb_displacement offset += ARG_POINTER_CFA_OFFSET (current_function_decl); #endif + /* Make sure we don't try eliminating registers in abstract function. */ + gcc_assert (!DECL_ABSTRACT (current_function_decl)); + elim = eliminate_regs (reg, VOIDmode, NULL_RTX); if (GET_CODE (elim) == PLUS) { Index: gcc/reload1.c =================================================================== --- gcc/reload1.c (revision 261914) +++ gcc/reload1.c (working copy) @@ -2867,6 +2867,7 @@ eliminate_regs_1 (rtx x, enum machine_mo rtx eliminate_regs (rtx x, enum machine_mode mem_mode, rtx insn) { + gcc_assert (reload_in_progress || reload_completed); return eliminate_regs_1 (x, mem_mode, insn, false); } --------------040806040406070602020401--