From patchwork Sun Jul 24 17:12:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 106534 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 B58ABB6F83 for ; Mon, 25 Jul 2011 03:14:10 +1000 (EST) Received: (qmail 12230 invoked by alias); 24 Jul 2011 17:14:07 -0000 Received: (qmail 12220 invoked by uid 22791); 24 Jul 2011 17:14:06 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 24 Jul 2011 17:13:52 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id E95BECB0232 for ; Sun, 24 Jul 2011 19:13:50 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 61vIZZD3ZtsJ for ; Sun, 24 Jul 2011 19:13:40 +0200 (CEST) Received: from [192.168.1.2] (bon31-9-83-155-120-49.fbx.proxad.net [83.155.120.49]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 95B88CB01EC for ; Sun, 24 Jul 2011 19:13:40 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Fix inlining glitch Date: Sun, 24 Jul 2011 19:12:51 +0200 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Message-Id: <201107241912.51760.ebotcazou@adacore.com> 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, we sometimes get messages like this in Ada: prime-mc2-other.adb: In function 'PRIME.MC2.OTHER.DO_SOMETHING': prime-mc2.adb:2:4: warning: inlining failed in call to 'PRIME.MC2.GET_INPUT_VALUE.PART': non-call exception handling mismatch [-Winline] prime-mc2-other.adb:3:4: warning: called from here [-Winline] Since this is for a pure Ada program, it's unexpected. This stems from virtual cloning: cgraph_create_virtual_clone creates the virtual clone and does: DECL_STRUCT_FUNCTION (new_decl) = NULL; so the can_throw_non_call_exceptions flag isn't preserved and can_inline_edge_p is fooled into thinking that it cannot inline. It's probably better not to fiddle with virtual cloning so the attached patch teaches can_inline_edge_p to look into DECL_STRUCT_FUNCTION of the original nodes if it is dealing with virtual clones. Tested on i586-suse-linux, OK for the mainline? 2011-07-24 Eric Botcazou * ipa-inline.c (can_inline_edge_p): Look into DECL_STRUCT_FUNCTION of original nodes if we are dealing with virtual clones. Index: ipa-inline.c =================================================================== --- ipa-inline.c (revision 176622) +++ ipa-inline.c (working copy) @@ -238,9 +238,20 @@ can_inline_edge_p (struct cgraph_edge *e { bool inlinable = true; enum availability avail; - struct cgraph_node *callee = cgraph_function_or_thunk_node (e->callee, &avail); + struct cgraph_node *callee + = cgraph_function_or_thunk_node (e->callee, &avail); tree caller_tree = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (e->caller->decl); - tree callee_tree = callee ? DECL_FUNCTION_SPECIFIC_OPTIMIZATION (callee->decl) : NULL; + tree callee_tree + = callee ? DECL_FUNCTION_SPECIFIC_OPTIMIZATION (callee->decl) : NULL; + struct function *caller_cfun = DECL_STRUCT_FUNCTION (e->caller->decl); + struct function *callee_cfun + = callee ? DECL_STRUCT_FUNCTION (callee->decl) : NULL; + + if (!caller_cfun && e->caller->clone_of) + caller_cfun = DECL_STRUCT_FUNCTION (e->caller->clone_of->decl); + + if (!callee_cfun && callee && callee->clone_of) + callee_cfun = DECL_STRUCT_FUNCTION (callee->clone_of->decl); gcc_assert (e->inline_failed); @@ -277,12 +288,8 @@ can_inline_edge_p (struct cgraph_edge *e caller cannot. FIXME: this is obviously wrong for LTO where STRUCT_FUNCTION is missing. Move the flag into cgraph node or mirror it in the inline summary. */ - else if (DECL_STRUCT_FUNCTION (callee->decl) - && DECL_STRUCT_FUNCTION - (callee->decl)->can_throw_non_call_exceptions - && !(DECL_STRUCT_FUNCTION (e->caller->decl) - && DECL_STRUCT_FUNCTION - (e->caller->decl)->can_throw_non_call_exceptions)) + else if (callee_cfun && callee_cfun->can_throw_non_call_exceptions + && !(caller_cfun && caller_cfun->can_throw_non_call_exceptions)) { e->inline_failed = CIF_NON_CALL_EXCEPTIONS; inlinable = false;