From patchwork Thu Nov 14 09:52:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Tocar X-Patchwork-Id: 291162 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3890F2C00BC for ; Thu, 14 Nov 2013 20:53:11 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=UqoRdcyikCXQgpOje nLY/DBXvMHl56mmZVebJk8BpiYcbXk7em9Nqn+lQVyGi8hZfz+z3R4XK3RKrjwfm cXnEIkQqjLwfK6ZJElo3V1P+rDj2U0Ml8bFbFPihOyNOZF/swfn6qknnd+PaVW0B SFjLg4oHHsdyzNB/xBwphoIKEU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=q41AR8rQKprOKOeBZXM5hro qZvQ=; b=hNsA2WOom18AN2NKmeNso701PG5zjQ43Lcy0z9Nktyrqh832D+K05VS KKErx8jUe8pqThgVj1f4FC3MK9J7wsJ3vXHztRn7Ban79Fo7By7qQpTT9hAR/dDt TyKjb2mNWX7T/B4g4WBsFfGXjDow7upmsqZ3fjmL2+lnTM0ns2NQ= Received: (qmail 25539 invoked by alias); 14 Nov 2013 09:53:01 -0000 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 Received: (qmail 25528 invoked by uid 89); 14 Nov 2013 09:53:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.0 required=5.0 tests=AWL, BAYES_50, FREEMAIL_FROM, KAM_STOCKGEN, RDNS_NONE, SPF_PASS, T_FRT_BELOW2 autolearn=no version=3.3.2 X-HELO: mail-pb0-f54.google.com Received: from Unknown (HELO mail-pb0-f54.google.com) (209.85.160.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 14 Nov 2013 09:52:59 +0000 Received: by mail-pb0-f54.google.com with SMTP id ro12so1797222pbb.13 for ; Thu, 14 Nov 2013 01:52:51 -0800 (PST) X-Received: by 10.67.4.227 with SMTP id ch3mr587425pad.74.1384422771760; Thu, 14 Nov 2013 01:52:51 -0800 (PST) Received: from msticlxl7.ims.intel.com ([192.55.54.40]) by mx.google.com with ESMTPSA id hi5sm50274233pbb.43.2013.11.14.01.52.48 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Nov 2013 01:52:51 -0800 (PST) Date: Thu, 14 Nov 2013 13:52:26 +0400 From: Ilya Tocar To: Richard Biener , Jakub Jelinek Cc: "Michael V. Zolotukhin" , Kirill Yukhin , gcc , Richard Henderson , Jan Hubicka Subject: Re: Ping Re: [gomp4] Dumping gimple for offload. Message-ID: <20131114095226.GA128413@msticlxl7.ims.intel.com> References: <20130923132951.GA80051@msticlxl7.ims.intel.com> <20130925132924.GA122388@msticlxl7.ims.intel.com> <20130926172127.GA41768@msticlxl7.ims.intel.com> <20131003160507.GA116670@msticlxl7.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes On 18 Oct 13:30, Richard Biener wrote: > Certainly better than the first version. Jakub should decide for the branch > and eventually Honza for the merge to trunk. It still looks somewhat hackish, > but I suppose that's because we don't have a LTO-state object where we > can encapsulate all this. > > Also I still don't like the attribute lookup > > > + /* Ignore non omp target nodes for omp case. */ > > + if (is_omp && !lookup_attribute ("omp declare target", > > + DECL_ATTRIBUTES (node->symbol.decl))) > > + return; > > can we instead please add a flag in cgraph_node? You mean symtab_node (we also need to dump marked variables)? Is patch bellow ok for gomp4 branch? --- gcc/cgraph.h | 3 +++ gcc/cgraphunit.c | 15 +++++++++++++-- gcc/ipa-inline-analysis.c | 2 +- gcc/lto-cgraph.c | 14 ++++++++++++++ gcc/lto-streamer.c | 5 +++-- gcc/lto-streamer.h | 6 ++++++ gcc/lto/lto-partition.c | 3 +++ gcc/passes.c | 6 ++++-- gcc/tree-pass.h | 2 +- 9 files changed, 48 insertions(+), 8 deletions(-) diff --git a/gcc/cgraph.h b/gcc/cgraph.h index fb0fe93..601094a 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -105,6 +105,9 @@ public: /* Set when symbol has address taken. */ unsigned address_taken : 1; + /* Set when symbol needs to be dumped for lto/offloading. */ + unsigned need_dump : 1; + /* Ordering of all symtab entries. */ int order; diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index c3a8967..53cd250 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -2019,7 +2019,18 @@ ipa_passes (void) passes->all_lto_gen_passes); if (!in_lto_p) - ipa_write_summaries (); + { + if (flag_openmp) + { + section_name_prefix = OMP_SECTION_NAME_PREFIX; + ipa_write_summaries (true); + } + if (flag_lto) + { + section_name_prefix = LTO_SECTION_NAME_PREFIX; + ipa_write_summaries (false); + } + } if (flag_generate_lto) targetm.asm_out.lto_end (); @@ -2110,7 +2121,7 @@ compile (void) cgraph_state = CGRAPH_STATE_IPA; /* If LTO is enabled, initialize the streamer hooks needed by GIMPLE. */ - if (flag_lto) + if (flag_lto || flag_openmp) lto_streamer_hooks_init (); /* Don't run the IPA passes if there was any error or sorry messages. */ diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c index 4458723..62faa52 100644 --- a/gcc/ipa-inline-analysis.c +++ b/gcc/ipa-inline-analysis.c @@ -3813,7 +3813,7 @@ inline_generate_summary (void) /* When not optimizing, do not bother to analyze. Inlining is still done because edge redirection needs to happen there. */ - if (!optimize && !flag_lto && !flag_wpa) + if (!optimize && !flag_lto && !flag_wpa && !flag_openmp) return; function_insertion_hook_holder = diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index 6a52da8..697c069 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -238,6 +238,9 @@ void lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t encoder, symtab_node *node) { + /* Ignore not needed nodes. */ + if (!node->need_dump) + return; int index = lto_symtab_encoder_encode (encoder, node); encoder->nodes[index].in_partition = true; } @@ -751,6 +754,17 @@ add_references (lto_symtab_encoder_t encoder, lto_symtab_encoder_encode (encoder, ref->referred); } +/* Select what needs to be dumped. In lto case dump everything. + In omp target case only dump stuff makrked with attribute. */ +void +select_what_to_dump (bool is_omp) +{ + struct symtab_node *snode; + FOR_EACH_SYMBOL(snode) + snode->need_dump = !is_omp || lookup_attribute ("omp declare target", + DECL_ATTRIBUTES (snode->decl)); +} + /* Find all symbols we want to stream into given partition and insert them to encoders. diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c index 1540e4c..ffafb0e 100644 --- a/gcc/lto-streamer.c +++ b/gcc/lto-streamer.c @@ -43,6 +43,7 @@ struct lto_stats_d lto_stats; static bitmap_obstack lto_obstack; static bool lto_obstack_initialized; +const char *section_name_prefix = LTO_SECTION_NAME_PREFIX; /* Return a string representing LTO tag TAG. */ @@ -172,7 +173,7 @@ lto_get_section_name (int section_type, const char *name, struct lto_file_decl_d sprintf (post, "." HOST_WIDE_INT_PRINT_HEX_PURE, f->id); else sprintf (post, "." HOST_WIDE_INT_PRINT_HEX_PURE, get_random_seed (false)); - return concat (LTO_SECTION_NAME_PREFIX, sep, add, post, NULL); + return concat (section_name_prefix, sep, add, post, NULL); } @@ -310,7 +311,7 @@ lto_streamer_init (void) bool gate_lto_out (void) { - return ((flag_generate_lto || in_lto_p) + return ((flag_generate_lto || in_lto_p || flag_openmp) /* Don't bother doing anything if the program has errors. */ && !seen_error ()); } diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index 797e92e..f4c46db 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -139,6 +139,11 @@ along with GCC; see the file COPYING3. If not see name for the functions and static_initializers. For other types of sections a '.' and the section type are appended. */ #define LTO_SECTION_NAME_PREFIX ".gnu.lto_" +#define OMP_SECTION_NAME_PREFIX ".gnu.target_lto_" + +/* Can be either OMP_SECTION_NAME_PREFIX when we stream pragma omp target + stuff, or LTO_SECTION_NAME_PREFIX for lto case. */ +extern const char *section_name_prefix; #define LTO_major_version 2 #define LTO_minor_version 2 @@ -895,6 +900,7 @@ bool referenced_from_this_partition_p (struct ipa_ref_list *, bool reachable_from_this_partition_p (struct cgraph_node *, lto_symtab_encoder_t); lto_symtab_encoder_t compute_ltrans_boundary (lto_symtab_encoder_t encoder); +void select_what_to_dump (bool); /* In lto-symtab.c. */ diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c index 6a3d881..2d2aa63 100644 --- a/gcc/lto/lto-partition.c +++ b/gcc/lto/lto-partition.c @@ -190,6 +190,7 @@ add_symbol_to_partition_1 (ltrans_partition part, symtab_node *node) gcc_assert (c != SYMBOL_EXTERNAL && (c == SYMBOL_DUPLICATE || !symbol_partitioned_p (node))); + node->need_dump = true; lto_set_symtab_encoder_in_partition (part->encoder, node); if (symbol_partitioned_p (node)) @@ -917,6 +918,8 @@ lto_promote_cross_file_statics (void) gcc_assert (flag_wpa); + select_what_to_dump (false); + /* First compute boundaries. */ n_sets = ltrans_partitions.length (); for (i = 0; i < n_sets; i++) diff --git a/gcc/passes.c b/gcc/passes.c index 19e5869..88b1538 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -2335,7 +2335,7 @@ ipa_write_summaries_1 (lto_symtab_encoder_t encoder) /* Write out summaries for all the nodes in the callgraph. */ void -ipa_write_summaries (void) +ipa_write_summaries (bool is_omp) { lto_symtab_encoder_t encoder; int i, order_pos; @@ -2343,9 +2343,11 @@ ipa_write_summaries (void) struct cgraph_node *node; struct cgraph_node **order; - if (!flag_generate_lto || seen_error ()) + if (!(flag_generate_lto || flag_openmp) || seen_error () ) return; + select_what_to_dump (is_omp); + encoder = lto_symtab_encoder_new (false); /* Create the callgraph set in the same order used in diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index fa403c7..8d51d80 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -595,7 +595,7 @@ extern void pass_fini_dump_file (struct opt_pass *); extern const char *get_current_pass_name (void); extern void print_current_pass (FILE *); extern void debug_pass (void); -extern void ipa_write_summaries (void); +extern void ipa_write_summaries (bool is_omp); extern void ipa_write_optimization_summaries (struct lto_symtab_encoder_d *); extern void ipa_read_summaries (void); extern void ipa_read_optimization_summaries (void);