From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95768 invoked by alias); 17 Aug 2015 13:47:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 95758 invoked by uid 89); 17 Aug 2015 13:47:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 17 Aug 2015 13:47:18 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 55722543B19; Mon, 17 Aug 2015 15:47:14 +0200 (CEST) Date: Mon, 17 Aug 2015 13:53:00 -0000 From: Jan Hubicka To: GCC Patches , Jan Hubicka Subject: Re: [PATCH, PR 67133] Always change gimple fntype in cgraph_edge::redirect_call_stmt_to_callee Message-ID: <20150817134714.GA19625@kam.mff.cuni.cz> References: <20150817133857.GY2569@virgil.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150817133857.GY2569@virgil.suse.cz> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-08/txt/msg00903.txt.bz2 > Hi, > > even though PR 67133 has been avoided by a different patch, I believe > the patch below is the correct fix. It modifies the function that > changes call statements according to call graph edges so that it > changes the fntype of the call statements also when > combined_args_to_skip is NULL. This code path is taken for example > when a call is redirected to __builtin_unreachable and then the type > of the callee function is likely to mismatch with fntype of the > statement, which can confuse the compiler later on. > > If we agree it is a good idea, I'd like to also propose a patch > making the gimple verifier check whether fntypes of direct call > statements match the types of the callee (or at least that they have > the same number of same-typed arguments). > > The patch has been bootstrapped and tested on x86_64-linux, the > testcase is already checked in. OK for trunk? > > Thanks, > > Martin > > > 2015-08-17 Martin Jambor > > PR middle-end/67133 > * cgraph.c (redirect_call_stmt_to_callee): Set gimple call fntype also > when redirecting without removing any parameters. This makes sense in the case of __builtin_unreachable. I wonder if we have some problems in cases where LTO or indirect call code places in incompatible declaration. Patch is fine with me, but I would like Richi to have final word on this one. Honza > > diff --git a/gcc/cgraph.c b/gcc/cgraph.c > index 22a9852..5e5b308 100644 > --- a/gcc/cgraph.c > +++ b/gcc/cgraph.c > @@ -1461,6 +1461,7 @@ cgraph_edge::redirect_call_stmt_to_callee (void) > { > new_stmt = e->call_stmt; > gimple_call_set_fndecl (new_stmt, e->callee->decl); > + gimple_call_set_fntype (new_stmt, TREE_TYPE (e->callee->decl)); > update_stmt_fn (DECL_STRUCT_FUNCTION (e->caller->decl), new_stmt); > } >