From patchwork Fri Jan 14 18:15:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 78985 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 08F3DB6F1E for ; Sat, 15 Jan 2011 05:15:42 +1100 (EST) Received: (qmail 1807 invoked by alias); 14 Jan 2011 18:15:39 -0000 Received: (qmail 1793 invoked by uid 22791); 14 Jan 2011 18:15:37 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_FN, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 14 Jan 2011 18:15:32 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0EIFUaq023005 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 14 Jan 2011 13:15:30 -0500 Received: from vishnu.quesejoda.com (vpn-235-78.phx2.redhat.com [10.3.235.78]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0EIFTmq029047; Fri, 14 Jan 2011 13:15:30 -0500 Message-ID: <4D3092C1.8060101@redhat.com> Date: Fri, 14 Jan 2011 12:15:29 -0600 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Thunderbird/3.1.7 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org, Richard Henderson Subject: [trans-mem] PR45940: handle inlining of TM pure functions 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 This patch removes the kludge disabling all TM pure functions from being inlined, and only disables this behavior when the caller is transactionally safe. Richard, your original suggestion is below. Instead I decided to add the code in tree_can_inline_p() which has both callee *AND* caller information. Both function_attribute_inlinable_p() and inline_forbidden_p_stmt() which you suggested get called through the inline parameter pass (compute_inline_parameters) which only has information for the callee, not the caller, so we can't determine if the caller was TM safe. There is no testcase for this patch, as the original tests applicable to this PR test this patch as well. OK for branch? p.s. Oh yeah, this concludes the fix, and we can close the PR. > In function_attribute_inlinable_p, if fndecl is tm_pure and > current_function_decl is tm_safe, deny the inlining. > > This is because tm_pure is the only escape hatch we > have for "do not annotate this". E.g. you want to > add a call to printf for debugging, or there's some > data you know that shouldn't be part of the transaction. > > The fix for this is to implement __tm_waiver. But you > know yourself how tricky getting just the transaction > blocks correct has been. Adding holes within the > region is... nasty. But probably required eventually. > > In inline_forbidden_p_stmt, notice asms and prevent them from > being inlined if current_function_decl is tm_safe. > > This will stop early inlining from breaking tm_safe > functions when dealing with e.g. system header files > that include inline asms. PR/45940 * integrate.c (function_attribute_inlinable_p): Remove temporary TM pure handling. * tree-inline.c (tree_can_inline_p): Do not inline some TM pure functions. Index: tree-inline.c =================================================================== --- tree-inline.c (revision 168743) +++ tree-inline.c (working copy) @@ -5100,6 +5100,17 @@ tree_can_inline_p (struct cgraph_edge *e return false; } + /* TM pure functions should not get inlined if the outer function is + a TM safe function. */ + if (flag_tm + && is_tm_pure (callee) + && is_tm_safe (caller)) + { + e->inline_failed = CIF_UNSPECIFIED; + gimple_call_set_cannot_inline (e->call_stmt, true); + return false; + } + /* Allow the backend to decide if inlining is ok. */ if (!targetm.target_option.can_inline_p (caller, callee)) { Index: integrate.c =================================================================== --- integrate.c (revision 168743) +++ integrate.c (working copy) @@ -72,15 +72,6 @@ static void set_block_abstract_flags (tr bool function_attribute_inlinable_p (const_tree fndecl) { - /* TM pure functions should not get inlined if the outer function is - a TM safe function. - - FIXME: In the meantime, prevent pure functions from being - inlined. */ - if (flag_tm - && is_tm_pure (fndecl)) - return false; - if (targetm.attribute_table) { const_tree a;