From patchwork Sun Jul 3 09:49:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 103002 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 2FFE7B6EDF for ; Sun, 3 Jul 2011 19:45:08 +1000 (EST) Received: (qmail 2608 invoked by alias); 3 Jul 2011 09:45:06 -0000 Received: (qmail 2582 invoked by uid 22791); 3 Jul 2011 09:45:04 -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; Sun, 03 Jul 2011 09:44:49 +0000 Received: from relay2.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 24B9589994; Sun, 3 Jul 2011 11:44:48 +0200 (CEST) Date: Sun, 3 Jul 2011 11:49:13 +0200 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PATCH, PR 49495] Cgraph verifier must look through aliases Message-ID: <20110703094913.GA2394@alvy.suse.cz> Mail-Followup-To: GCC Patches , Jan Hubicka MIME-Version: 1.0 Content-Disposition: inline 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, 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. 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. */ + && (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:"); + debug_tree (e->callee->decl); + fprintf (stderr," Instead of:"); + debug_tree (decl); + return true; + } + else + return false; +} + /* Verify cgraph nodes of given cgraph node. */ DEBUG_FUNCTION void verify_cgraph_node (struct cgraph_node *node) @@ -702,24 +730,8 @@ 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)) - { - error ("edge points to wrong declaration:"); - debug_tree (e->callee->decl); - fprintf (stderr," Instead of:"); - debug_tree (decl); - error_found = true; - } + if (verify_edge_corresponds_to_fndecl (e, decl)) + error_found = true; } else if (decl) {