From patchwork Fri Jan 14 12:02:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 78888 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 08B7BB70B3 for ; Fri, 14 Jan 2011 23:03:02 +1100 (EST) Received: (qmail 31318 invoked by alias); 14 Jan 2011 12:02:57 -0000 Received: (qmail 31298 invoked by uid 22791); 14 Jan 2011 12:02:54 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=AWL,BAYES_00,TW_FN 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; Fri, 14 Jan 2011 12:02:45 +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 mx1.suse.de (Postfix) with ESMTP id 9C06994033 for ; Fri, 14 Jan 2011 13:02:42 +0100 (CET) Date: Fri, 14 Jan 2011 13:02:42 +0100 From: Martin Jambor To: GCC Patches Subject: [PATCH, COMMITTED, PR 46823] Get fndecl from cgraph_edge when inlining Message-ID: <20110114120242.GA27582@virgil.arch.suse.de> Mail-Followup-To: GCC Patches 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, based on Honza's approval in bugzilla I have committed the following to fix PR 46823 as revision 168778 (after bootstrapping and testing on x86_64-linux). I'll try again to add a testcase but so far I did not have much luck with it. I will prepare a followup cleanup patch moving the id->dst_node->analyzed check to gimple_expand_calls_inline for 4.7. Thanks, Martin 2011-01-14 Martin Jambor PR middle-end/46823 * tree-inline.c (expand_call_inline): Get fndecl from call graph edge. Index: icln/gcc/tree-inline.c =================================================================== --- icln.orig/gcc/tree-inline.c +++ icln/gcc/tree-inline.c @@ -3783,14 +3783,19 @@ expand_call_inline (basic_block bb, gimp if (gimple_code (stmt) != GIMPLE_CALL) goto egress; + /* Objective C and fortran still calls tree_rest_of_compilation directly. + Kill this check once this is fixed. */ + if (!id->dst_node->analyzed) + goto egress; + + cg_edge = cgraph_edge (id->dst_node, stmt); + gcc_checking_assert (cg_edge); /* First, see if we can figure out what function is being called. If we cannot, then there is no hope of inlining the function. */ - fn = gimple_call_fndecl (stmt); - if (!fn) + if (cg_edge->indirect_unknown_callee) goto egress; - - /* Turn forward declarations into real ones. */ - fn = cgraph_node (fn)->decl; + fn = cg_edge->callee->decl; + gcc_checking_assert (fn); /* If FN is a declaration of a function in a nested scope that was globally declared inline, we don't set its DECL_INITIAL. @@ -3804,13 +3809,6 @@ expand_call_inline (basic_block bb, gimp && gimple_has_body_p (DECL_ABSTRACT_ORIGIN (fn))) fn = DECL_ABSTRACT_ORIGIN (fn); - /* Objective C and fortran still calls tree_rest_of_compilation directly. - Kill this check once this is fixed. */ - if (!id->dst_node->analyzed) - goto egress; - - cg_edge = cgraph_edge (id->dst_node, stmt); - /* First check that inlining isn't simply forbidden in this case. */ if (inline_forbidden_into_p (cg_edge->caller->decl, cg_edge->callee->decl)) goto egress;