From patchwork Thu Jul 7 18:21:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 103717 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 0B80AB6F69 for ; Fri, 8 Jul 2011 04:21:58 +1000 (EST) Received: (qmail 22059 invoked by alias); 7 Jul 2011 18:21:56 -0000 Received: (qmail 22048 invoked by uid 22791); 7 Jul 2011 18:21:55 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 07 Jul 2011 18:21:39 +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 mx2.suse.de (Postfix) with ESMTP id B4E398CC2B; Thu, 7 Jul 2011 20:21:37 +0200 (CEST) Date: Thu, 7 Jul 2011 20:21:37 +0200 From: Martin Jambor To: Jan Hubicka Cc: GCC Patches Subject: Re: [PATCH, PR 49495] Cgraph verifier must look through aliases Message-ID: <20110707182136.GA3584@virgil.arch.suse.de> Mail-Followup-To: Jan Hubicka , GCC Patches References: <20110703094913.GA2394@alvy.suse.cz> <20110704091312.GC26368@atrey.karlin.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110704091312.GC26368@atrey.karlin.mff.cuni.cz> User-Agent: Mutt/1.5.21 (2010-09-15) 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, On Mon, Jul 04, 2011 at 11:13:12AM +0200, Jan Hubicka wrote: > > Hi, > > > > PR 49495 is actually a bug in the verifier that does not look through > > aliases at one point. Fixed wit the patch below (created a special > > function, otherwise I just wasn't able to fit the 80 column limit). > > Bootstrapped and tested on x86_64-linux. OK for trunk? > > > > Thanks, > > > > Martin > > > > > > 2011-07-02 Martin Jambor > > > > PR middle-end/49495 > > * cgraphunit.c (verify_edge_corresponds_to_fndecl): New function. > > (verify_cgraph_node): Some functinality moved to > > verify_edge_corresponds_to_fndecl, call it. > > This is OK. > > > > > > Index: src/gcc/cgraphunit.c > > =================================================================== > > --- src.orig/gcc/cgraphunit.c > > +++ src/gcc/cgraphunit.c > > @@ -450,6 +450,34 @@ cgraph_debug_gimple_stmt (struct functio > > debug_gimple_stmt (stmt); > > } > > > > +/* Verify that call graph edge E corresponds to DECL from the associated > > + statement. Return true if the verification should fail. */ > > + > > +static bool > > +verify_edge_corresponds_to_fndecl (struct cgraph_edge *e, tree decl) > > +{ > > + if (!e->callee->global.inlined_to > > + && decl > > + && cgraph_get_node (decl) > > + && (e->callee->former_clone_of > > + != cgraph_function_or_thunk_node (cgraph_get_node (decl), NULL)->decl) > > + /* IPA-CP sometimes redirect edge to clone and then back to the former > > + function. This ping-pong has to go, eventaully. */ BTW, I am having hard time trying to figure out how this comment relates to any of the tests in the conjunction. I'm obvioulsy asking because the new IPA-CP does not do this and so we could get rid of it, whatever the "it" is. > > + && (cgraph_function_or_thunk_node (cgraph_get_node (decl), NULL) > > + != cgraph_function_or_thunk_node (e->callee, NULL)) > > + && !clone_of_p (cgraph_get_node (decl), > > + e->callee)) > > + { > > + error ("edge points to wrong declaration:"); ... > > - error_found = true; > > - } > > + if (verify_edge_corresponds_to_fndecl (e, decl)) > > + error_found = true; > Could you please move the error output here, somehow I like it better when all > the diagnostic is output at single place... > Sure, this is what I have just committed as revision 175998 after a bootstrap and testing on x86_64-linux. Thanks, Martin 2011-07-07 Martin Jambor PR middle-end/49495 * cgraphunit.c (verify_edge_corresponds_to_fndecl): New function. (verify_cgraph_node): Some functinality moved to verify_edge_corresponds_to_fndecl, call it. Index: src/gcc/cgraphunit.c =================================================================== --- src.orig/gcc/cgraphunit.c +++ src/gcc/cgraphunit.c @@ -450,6 +450,28 @@ cgraph_debug_gimple_stmt (struct functio debug_gimple_stmt (stmt); } +/* Verify that call graph edge E corresponds to DECL from the associated + statement. Return true if the verification should fail. */ + +static bool +verify_edge_corresponds_to_fndecl (struct cgraph_edge *e, tree decl) +{ + if (!e->callee->global.inlined_to + && decl + && cgraph_get_node (decl) + && (e->callee->former_clone_of + != cgraph_function_or_thunk_node (cgraph_get_node (decl), NULL)->decl) + /* IPA-CP sometimes redirect edge to clone and then back to the former + function. This ping-pong has to go, eventaully. */ + && (cgraph_function_or_thunk_node (cgraph_get_node (decl), NULL) + != cgraph_function_or_thunk_node (e->callee, NULL)) + && !clone_of_p (cgraph_get_node (decl), + e->callee)) + return true; + else + return false; +} + /* Verify cgraph nodes of given cgraph node. */ DEBUG_FUNCTION void verify_cgraph_node (struct cgraph_node *node) @@ -702,17 +724,7 @@ verify_cgraph_node (struct cgraph_node * } if (!e->indirect_unknown_callee) { - if (!e->callee->global.inlined_to - && decl - && cgraph_get_node (decl) - && (e->callee->former_clone_of - != cgraph_get_node (decl)->decl) - /* IPA-CP sometimes redirect edge to clone and then back to the former - function. This ping-pong has to go, eventaully. */ - && (cgraph_function_or_thunk_node (cgraph_get_node (decl), NULL) - != cgraph_function_or_thunk_node (e->callee, NULL)) - && !clone_of_p (cgraph_get_node (decl), - e->callee)) + if (verify_edge_corresponds_to_fndecl (e, decl)) { error ("edge points to wrong declaration:"); debug_tree (e->callee->decl);