From patchwork Sun Nov 6 03:41:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 123911 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 CEB08B6F7C for ; Sun, 6 Nov 2011 14:41:57 +1100 (EST) Received: (qmail 10634 invoked by alias); 6 Nov 2011 03:41:54 -0000 Received: (qmail 10626 invoked by uid 22791); 6 Nov 2011 03:41:53 -0000 X-SWARE-Spam-Status: No, hits=-7.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_TM 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; Sun, 06 Nov 2011 03:41:36 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pA63faOY028548 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 5 Nov 2011 23:41:36 -0400 Received: from austin.quesejoda.com (vpn-11-135.rdu.redhat.com [10.11.11.135]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pA63fX4a027185; Sat, 5 Nov 2011 23:41:34 -0400 Message-ID: <4EB601ED.2000007@redhat.com> Date: Sat, 05 Nov 2011 20:41:33 -0700 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: Richard Guenther CC: Richard Henderson , gcc-patches , Torvald Riegel Subject: Re: [patch] 19/n: trans-mem: compiler tree/gimple stuff References: <4EB2EACC.8050307@redhat.com> <4EB47B07.7090203@redhat.com> <4EB49E46.2090608@redhat.com> <4EB551BE.9050600@redhat.com> In-Reply-To: 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 > Well - we usually don't grab bits off the tree nodes lightly. Especially if > the cgraph seems to be more fit. > >> If this is a suggestion, I can put it on my laundry list of future things >> todo (after merge, 4.8?, etc). > > There are not many consumers of the flag, so fixing it shouldn't be hard. > For 4.7 definitely. Fair enough. The following patch puts the bit in the cgraph structure. There was a comment originally that we may be able to calculate this bit from the CFG, but I'm not sure whether this applies any more, or how much work it would be. I left the comment in. Tested on x86-64 Linux. OK for branch? * cgraph.c (dump_cgraph_node): Handle tm_clone. * cgraph.h (struct cgraph_node): Add tm_clone field. (decl_is_tm_clone): New. * tree.h (DECL_IS_TM_CLONE): Remove. * trans-mem.c (execute_lower_tm): Rename DECL_IS_TM_CLONE to decl_is_tm_clone. (gate_tm_init): Same. (ipa_tm_create_version_alias): Set tm_clone. (ipa_tm_create_version): Same. (ipa_tm_transform_calls_redirect): Rename DECL_IS_TM_CLONE to decl_is_tm_clone. * calls.c (is_tm_builtin): Same. * tree-cfg.c (dump_function_to_file): Same. * print-tree.c (print_node): Same. * gimple-pretty-print.c (dump_gimple_call): Same. Index: cgraph.c =================================================================== --- cgraph.c (revision 181017) +++ cgraph.c (working copy) @@ -1840,6 +1840,8 @@ dump_cgraph_node (FILE *f, struct cgraph fprintf (f, " only_called_at_exit"); else if (node->alias) fprintf (f, " alias"); + if (node->tm_clone) + fprintf (f, " tm_clone"); fprintf (f, "\n"); Index: cgraph.h =================================================================== --- cgraph.h (revision 181017) +++ cgraph.h (working copy) @@ -248,6 +248,11 @@ struct GTY((chain_next ("%h.next"), chai unsigned only_called_at_startup : 1; /* True when function can only be called at startup (from static dtor). */ unsigned only_called_at_exit : 1; + /* True when function is the transactional clone of a function which + is called only from inside transactions. */ + /* ?? We should be able to remove this. We have enough bits in + cgraph to calculate it. */ + unsigned tm_clone : 1; }; typedef struct cgraph_node *cgraph_node_ptr; @@ -1087,4 +1092,14 @@ cgraph_edge_recursive_p (struct cgraph_e else return e->caller->decl == callee->decl; } + +/* Return true if the TM_CLONE bit is set for a given FNDECL. */ +static inline bool +decl_is_tm_clone (const_tree fndecl) +{ + struct cgraph_node *n = cgraph_get_node (fndecl); + if (n) + return n->tm_clone; + return false; +} #endif /* GCC_CGRAPH_H */ Index: tree.h =================================================================== --- tree.h (revision 181017) +++ tree.h (working copy) @@ -3466,11 +3466,6 @@ struct GTY(()) #define DECL_NO_INLINE_WARNING_P(NODE) \ (FUNCTION_DECL_CHECK (NODE)->function_decl.no_inline_warning_flag) -/* Nonzero in a FUNCTION_DECL means this function is the transactional - clone of a function - called only from inside transactions. */ -#define DECL_IS_TM_CLONE(NODE) \ - (FUNCTION_DECL_CHECK (NODE)->function_decl.tm_clone_flag) - /* Nonzero if a FUNCTION_CODE is a TM load/store. */ #define BUILTIN_TM_LOAD_STORE_P(FN) \ ((FN) >= BUILT_IN_TM_STORE_1 && (FN) <= BUILT_IN_TM_LOAD_RFW_LDOUBLE) Index: gimple-pretty-print.c =================================================================== --- gimple-pretty-print.c (revision 181017) +++ gimple-pretty-print.c (working copy) @@ -701,7 +701,7 @@ dump_gimple_call (pretty_printer *buffer /* Dump the arguments of _ITM_beginTransaction sanely. */ if (TREE_CODE (fn) == ADDR_EXPR) fn = TREE_OPERAND (fn, 0); - if (TREE_CODE (fn) == FUNCTION_DECL && DECL_IS_TM_CLONE (fn)) + if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn)) pp_string (buffer, " [tm-clone]"); if (TREE_CODE (fn) == FUNCTION_DECL && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL Index: trans-mem.c =================================================================== --- trans-mem.c (revision 181017) +++ trans-mem.c (working copy) @@ -1683,7 +1683,7 @@ execute_lower_tm (void) struct walk_stmt_info wi; /* Transactional clones aren't created until a later pass. */ - gcc_assert (!DECL_IS_TM_CLONE (current_function_decl)); + gcc_assert (!decl_is_tm_clone (current_function_decl)); memset (&wi, 0, sizeof (wi)); walk_gimple_seq (gimple_body (current_function_decl), @@ -1901,7 +1901,7 @@ gate_tm_init (void) bitmap_obstack_initialize (&tm_obstack); /* If the function is a TM_CLONE, then the entire function is the region. */ - if (DECL_IS_TM_CLONE (current_function_decl)) + if (decl_is_tm_clone (current_function_decl)) { struct tm_region *region = (struct tm_region *) obstack_alloc (&tm_obstack.obstack, sizeof (struct tm_region)); @@ -4194,11 +4194,8 @@ ipa_tm_create_version_alias (struct cgra if (DECL_COMDAT (new_decl)) DECL_COMDAT_GROUP (new_decl) = tm_mangle (DECL_COMDAT_GROUP (old_decl)); - /* ??? We should be able to remove DECL_IS_TM_CLONE. We have enough - bits in cgraph to calculate all this. */ - DECL_IS_TM_CLONE (new_decl) = 1; - new_node = cgraph_same_body_alias (NULL, new_decl, info->new_decl); + new_node->tm_clone = true; get_cg_data (node)->clone = new_node; record_tm_clone_pair (old_decl, new_decl); @@ -4232,11 +4229,8 @@ ipa_tm_create_version (struct cgraph_nod if (DECL_COMDAT (new_decl)) DECL_COMDAT_GROUP (new_decl) = tm_mangle (DECL_COMDAT_GROUP (old_decl)); - /* ??? We should be able to remove DECL_IS_TM_CLONE. We have enough - bits in cgraph to calculate all this. */ - DECL_IS_TM_CLONE (new_decl) = 1; - new_node = cgraph_copy_node_for_versioning (old_node, new_decl, NULL, NULL); + new_node->tm_clone = 1; get_cg_data (old_node)->clone = new_node; if (cgraph_function_body_availability (old_node) >= AVAIL_OVERWRITABLE) @@ -4418,7 +4412,7 @@ ipa_tm_transform_calls_redirect (struct /* Fixup recursive calls inside clones. */ /* ??? Why did cgraph_copy_node_for_versioning update the call edges for recursion but not update the call statements themselves? */ - if (e->caller == e->callee && DECL_IS_TM_CLONE (current_function_decl)) + if (e->caller == e->callee && decl_is_tm_clone (current_function_decl)) { gimple_call_set_fndecl (stmt, current_function_decl); return; Index: calls.c =================================================================== --- calls.c (revision 181017) +++ calls.c (working copy) @@ -620,7 +620,7 @@ is_tm_builtin (const_tree fndecl) if (fndecl == NULL) return false; - if (DECL_IS_TM_CLONE (fndecl)) + if (decl_is_tm_clone (fndecl)) return true; if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) Index: print-tree.c =================================================================== --- print-tree.c (revision 181017) +++ print-tree.c (working copy) @@ -424,7 +424,7 @@ print_node (FILE *file, const char *pref fputs (" built-in", file); if (code == FUNCTION_DECL && DECL_STATIC_CHAIN (node)) fputs (" static-chain", file); - if (TREE_CODE (node) == FUNCTION_DECL && DECL_IS_TM_CLONE (node)) + if (TREE_CODE (node) == FUNCTION_DECL && decl_is_tm_clone (node)) fputs (" tm-clone", file); if (code == FIELD_DECL && DECL_PACKED (node)) Index: tree-cfg.c =================================================================== --- tree-cfg.c (revision 181017) +++ tree-cfg.c (working copy) @@ -6503,7 +6503,7 @@ dump_function_to_file (tree fn, FILE *fi bool ignore_topmost_bind = false, any_var = false; basic_block bb; tree chain; - bool tmclone = TREE_CODE (fn) == FUNCTION_DECL && DECL_IS_TM_CLONE (fn); + bool tmclone = TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn); fprintf (file, "%s %s(", lang_hooks.decl_printable_name (fn, 2), tmclone ? "[tm-clone] " : "");