From patchwork Wed Nov 23 17:50:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 127360 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 C14771007D4 for ; Thu, 24 Nov 2011 04:50:21 +1100 (EST) Received: (qmail 19353 invoked by alias); 23 Nov 2011 17:50:19 -0000 Received: (qmail 19344 invoked by uid 22791); 23 Nov 2011 17:50:18 -0000 X-SWARE-Spam-Status: No, hits=-3.5 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-yw0-f47.google.com (HELO mail-yw0-f47.google.com) (209.85.213.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Nov 2011 17:50:02 +0000 Received: by ywb20 with SMTP id 20so1672077ywb.20 for ; Wed, 23 Nov 2011 09:50:02 -0800 (PST) Received: by 10.236.155.2 with SMTP id i2mr35555122yhk.115.1322070602054; Wed, 23 Nov 2011 09:50:02 -0800 (PST) MIME-Version: 1.0 Received: by 10.236.155.2 with SMTP id i2mr35554891yhk.115.1322070600519; Wed, 23 Nov 2011 09:50:00 -0800 (PST) Received: by 10.150.195.11 with HTTP; Wed, 23 Nov 2011 09:50:00 -0800 (PST) In-Reply-To: References: Date: Wed, 23 Nov 2011 12:50:00 -0500 Message-ID: Subject: Re: [PATCH] Fix early inliner inlining uninlinable functions From: Diego Novillo To: Iain Sandoe Cc: Richard Guenther , gcc-patches Patches , Jan Hubicka , Eric Botcazou X-System-Of-Record: true 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 On Sat, Nov 5, 2011 at 07:02, Iain Sandoe wrote: > > On 28 Oct 2011, at 13:57, Richard Guenther wrote: > >> >> We fail to keep the cannot-inline flag up-to-date when turning >> indirect to direct calls.  The following patch arranges to do >> this during statement folding (which should always be called >> when that happens).  It also makes sure to copy the updated flag >> to the edge when iterating early inlining. > > This: http://gcc.gnu.org/ml/gcc-cvs/2011-11/msg00046.html > > regresses: > acats/c740203a (x86-64-darwin10) > gnat/aliasing3.adb  (m64 i486-darwin9 and x86-64-darwin10) > ... don't know about other platforms at present. I am also seeing a regression in some C++ code, specifically, this call to gimple_call_set_cannot_inline() is not updating the call_stmt_cannot_inline_p field in the corresponding call graph edge ! if (callee ! && !gimple_check_call_matching_types (stmt, callee)) ! gimple_call_set_cannot_inline (stmt, true); In this code I'm trying to build, we fail the assertion in can_inline_edge_p: /* Be sure that the cannot_inline_p flag is up to date. */ gcc_checking_assert (!e->call_stmt || (gimple_call_cannot_inline_p (e->call_stmt) == e->call_stmt_cannot_inline_p) because gimple_fold_call did not update the inline flag on the edge. I grepped for calls to gimple_call_set_cannot_inline() and we don't always bother to update the corresponding edge. I think the safest approach here would be to make sure that we always do (patch below). Thoughts? Diego. diff --git a/gcc/gimple.c b/gcc/gimple.c index 071c651..e2b082a 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -5558,4 +5558,31 @@ gimple_asm_clobbers_memory_p (const_gimple stmt) return false; } + + +/* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */ + +void +gimple_call_set_cannot_inline (gimple s, bool inlinable_p) +{ + bool prev_inlinable_p; + + GIMPLE_CHECK (s, GIMPLE_CALL); + + prev_inlinable_p = gimple_call_cannot_inline_p (s); + + if (inlinable_p) + s->gsbase.subcode |= GF_CALL_CANNOT_INLINE; + else + s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE; + + if (prev_inlinable_p != inlinable_p) + { + struct cgraph_node *n = cgraph_get_node (current_function_decl); + struct cgraph_edge *e = cgraph_edge (n, s); + if (e) + e->call_stmt_cannot_inline_p = inlinable_p; + } +} + #include "gt-gimple.h" diff --git a/gcc/gimple.h b/gcc/gimple.h index 8536c70..df31bf3 100644 --- a/gcc/gimple.h +++ b/gcc/gimple.h @@ -1035,6 +1035,7 @@ extern bool walk_stmt_load_store_ops (gimple, void *, extern bool gimple_ior_addresses_taken (bitmap, gimple); extern bool gimple_call_builtin_p (gimple, enum built_in_function); extern bool gimple_asm_clobbers_memory_p (const_gimple); +extern void gimple_call_set_cannot_inline (gimple, bool); /* In gimplify.c */ extern tree create_tmp_var_raw (tree, const char *); @@ -2343,19 +2344,6 @@ gimple_call_tail_p (gimple s) } -/* Set the inlinable status of GIMPLE_CALL S to INLINABLE_P. */ - -static inline void -gimple_call_set_cannot_inline (gimple s, bool inlinable_p) -{ - GIMPLE_CHECK (s, GIMPLE_CALL); - if (inlinable_p) - s->gsbase.subcode |= GF_CALL_CANNOT_INLINE; - else - s->gsbase.subcode &= ~GF_CALL_CANNOT_INLINE; -} - - /* Return true if GIMPLE_CALL S cannot be inlined. */ static inline bool