From patchwork Wed Mar 9 11:56:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 86103 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 3B335B70D9 for ; Wed, 9 Mar 2011 22:57:08 +1100 (EST) Received: (qmail 5128 invoked by alias); 9 Mar 2011 11:57:06 -0000 Received: (qmail 5118 invoked by uid 22791); 9 Mar 2011 11:57:05 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI X-Spam-Check-By: sourceware.org Received: from cantor.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 09 Mar 2011 11:57:00 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 4C7AE5362F; Wed, 9 Mar 2011 12:56:58 +0100 (CET) Date: Wed, 9 Mar 2011 12:56:57 +0100 From: Martin Jambor To: GCC Patches Cc: Jason Merrill Subject: [c++, PR 47714] Reset the addressable flag of thunk PARM_DECLs Message-ID: <20110309115657.GB10748@virgil.arch.suse.de> Mail-Followup-To: GCC Patches , Jason Merrill MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, the patch below fixes PR 47714. The problem is that as thunk function declarations are built, their PARM_DECLs are copied from the thunked function together with their TREE_ADDRESSABLE flags. This then means the parameters are not considered gimple registers when they are supposed to be converted to SSA which makes the SSA verifier very unhappy later. The solution is to clear the addressable flag for the PARM_DECLs which reflects the reality as their addresses are not taken in thunks. The fix seems to be rather obvious (and Jakub wrote that in bugzilla too) and the bug is a P1 which can potentially postpone the release so my plan is to take the liberty and commit it if no-one stops me in the next few hours. Needless to say, the patch has been successfully bootstrapped and tested on x86_64-linux. Thanks, Martin 2011-03-08 Martin Jambor PR tree-optimization/47714 * cp/method.c (use_thunk): Clear addressable flag of thunk arguments. * testsuite/g++.dg/torture/pr47714.C: New test. Index: src/gcc/cp/method.c =================================================================== --- src.orig/gcc/cp/method.c +++ src/gcc/cp/method.c @@ -372,6 +372,7 @@ use_thunk (tree thunk_fndecl, bool emit_ DECL_CONTEXT (x) = thunk_fndecl; SET_DECL_RTL (x, NULL); DECL_HAS_VALUE_EXPR_P (x) = 0; + TREE_ADDRESSABLE (x) = 0; t = x; } a = nreverse (t); Index: src/gcc/testsuite/g++.dg/torture/pr47714.C =================================================================== --- /dev/null +++ src/gcc/testsuite/g++.dg/torture/pr47714.C @@ -0,0 +1,16 @@ +struct A { virtual ~A () {} }; +struct B { virtual ~B () {} }; +struct C { virtual const A *foo (int) const = 0; }; +struct E : public B, public A { }; +struct F : public C +{ + virtual const E *foo (int) const; +}; +void bar (int &); + +const E * +F::foo (int x) const +{ + bar (x); + return __null; +}