Patchwork [gomp4] Dumping gimple for offload.

login
register
mail settings
Submitter Ilya Tocar
Date Sept. 26, 2013, 5:21 p.m.
Message ID <20130926172127.GA41768@msticlxl7.ims.intel.com>
Download mbox | patch
Permalink /patch/278230/
State New
Headers show

Comments

Ilya Tocar - Sept. 26, 2013, 5:21 p.m.
On 25 Sep 15:48, Richard Biener wrote:
> On Wed, Sep 25, 2013 at 3:29 PM, Ilya Tocar <tocarip.intel@gmail.com> wrote:
> > On 24 Sep 11:02, Richard Biener wrote:
> >> On Mon, Sep 23, 2013 at 3:29 PM, Ilya Tocar <tocarip.intel@gmail.com> wrote:
> >>  thus consider assigning the section
> >> name in a different place.
> >>
> >> Richard.
> >
> > What do you mean  by different place?
> > I can add global dumping_omp_target variable to choose correct name,
> > depending on it's value (patch below). Is it better?
> 
> More like passing down a different abstraction, like for
> 
> > @@ -907,9 +907,15 @@ output_symtab (void)
> >      {
> >        symtab_node node = lto_symtab_encoder_deref (encoder, i);
> >        if (cgraph_node *cnode = dyn_cast <cgraph_node> (node))
> > -        lto_output_node (ob, cnode, encoder);
> > +       {
> > +         if (!dumping_omp_target || lookup_attribute ("omp declare target",
> > +                                         DECL_ATTRIBUTES (node->symbol.decl)))
> > +           lto_output_node (ob, cnode, encoder);
> > +       }
> >        else
> > -        lto_output_varpool_node (ob, varpool (node), encoder);
> > +         if (!dumping_omp_target || lookup_attribute ("omp declare target",
> > +                                         DECL_ATTRIBUTES (node->symbol.decl)))
> > +           lto_output_varpool_node (ob, varpool (node), encoder);
> >
> >      }
> 
> have the symtab encoder already not contain the varpool nodes you
> don't need.
> 
> And instead of looking up attributes, mark the symtab node with a flag.

Good idea!
I've tried creating 2 encoders, and adding only nodes with
"omp declare target" attribute in omp case. There is still some is_omp
passing to control  lto_set_symtab_encoder_in_partition behaivor, 
because i think it's better than global var.
What do you think?

---
 gcc/cgraphunit.c        | 10 +++++++++-
 gcc/lto-cgraph.c        | 15 ++++++++++-----
 gcc/lto-streamer.c      |  3 ++-
 gcc/lto-streamer.h      | 10 ++++++++--
 gcc/lto/lto-partition.c |  4 ++--
 gcc/passes.c            | 10 +++++-----
 gcc/tree-pass.h         |  2 +-
 7 files changed, 37 insertions(+), 17 deletions(-)

Patch

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 1644ca9..9e0fc77 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2016,7 +2016,15 @@  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);
+	}
+      section_name_prefix = LTO_SECTION_NAME_PREFIX;
+      ipa_write_summaries (false);
+    }
 
   if (flag_generate_lto)
     targetm.asm_out.lto_end ();
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 952588d..4a7d179 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -236,8 +236,13 @@  lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t encoder,
 
 void
 lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t encoder,
-				     symtab_node node)
+				     symtab_node node, bool is_omp)
 {
+  /* Ignore non omp target nodes for omp case.  */
+  if (is_omp && !lookup_attribute ("omp declare target",
+				   DECL_ATTRIBUTES (node->symbol.decl)))
+    return;
+
   int index = lto_symtab_encoder_encode (encoder, (symtab_node)node);
   encoder->nodes[index].in_partition = true;
 }
@@ -760,7 +765,7 @@  add_references (lto_symtab_encoder_t encoder,
    ignored by the partitioning logic earlier.  */
 
 lto_symtab_encoder_t 
-compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
+compute_ltrans_boundary (lto_symtab_encoder_t in_encoder, bool is_omp)
 {
   struct cgraph_node *node;
   struct cgraph_edge *edge;
@@ -779,7 +784,7 @@  compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
     {
       node = lsei_cgraph_node (lsei);
       add_node_to (encoder, node, true);
-      lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node);
+      lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node, is_omp);
       add_references (encoder, &node->symbol.ref_list);
       /* For proper debug info, we need to ship the origins, too.  */
       if (DECL_ABSTRACT_ORIGIN (node->symbol.decl))
@@ -794,7 +799,7 @@  compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
     {
       struct varpool_node *vnode = lsei_varpool_node (lsei);
 
-      lto_set_symtab_encoder_in_partition (encoder, (symtab_node)vnode);
+      lto_set_symtab_encoder_in_partition (encoder, (symtab_node)vnode, is_omp);
       lto_set_symtab_encoder_encode_initializer (encoder, vnode);
       add_references (encoder, &vnode->symbol.ref_list);
       /* For proper debug info, we need to ship the origins, too.  */
@@ -802,7 +807,7 @@  compute_ltrans_boundary (lto_symtab_encoder_t in_encoder)
 	{
 	  struct varpool_node *origin_node
 	  = varpool_get_node (DECL_ABSTRACT_ORIGIN (node->symbol.decl));
-	  lto_set_symtab_encoder_in_partition (encoder, (symtab_node)origin_node);
+	  lto_set_symtab_encoder_in_partition (encoder, (symtab_node)origin_node, is_omp);
 	}
     }
   /* Pickle in also the initializer of all referenced readonly variables
diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c
index cdc75de..ecc9b27 100644
--- a/gcc/lto-streamer.c
+++ b/gcc/lto-streamer.c
@@ -44,6 +44,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.  */
 
@@ -173,7 +174,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);
 }
 
 
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
index 13a9593..7cd7514 100644
--- a/gcc/lto-streamer.h
+++ b/gcc/lto-streamer.h
@@ -141,6 +141,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
@@ -882,7 +887,7 @@  bool lto_symtab_encoder_encode_body_p (lto_symtab_encoder_t,
 bool lto_symtab_encoder_in_partition_p (lto_symtab_encoder_t,
 					symtab_node);
 void lto_set_symtab_encoder_in_partition (lto_symtab_encoder_t,
-					  symtab_node);
+					  symtab_node, bool is_omp);
 
 bool lto_symtab_encoder_encode_initializer_p (lto_symtab_encoder_t,
 					      struct varpool_node *);
@@ -896,7 +901,8 @@  bool referenced_from_this_partition_p (struct ipa_ref_list *,
 					lto_symtab_encoder_t);
 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);
+lto_symtab_encoder_t compute_ltrans_boundary (lto_symtab_encoder_t encoder,
+					      bool is_omp);
 
 
 /* In lto-symtab.c.  */
diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c
index e05f805..83b3eba 100644
--- a/gcc/lto/lto-partition.c
+++ b/gcc/lto/lto-partition.c
@@ -189,7 +189,7 @@  add_symbol_to_partition_1 (ltrans_partition part, symtab_node node)
   gcc_assert (c != SYMBOL_EXTERNAL
 	      && (c == SYMBOL_DUPLICATE || !symbol_partitioned_p (node)));
 
-  lto_set_symtab_encoder_in_partition (part->encoder, (symtab_node) node);
+  lto_set_symtab_encoder_in_partition (part->encoder, (symtab_node) node, false);
 
   if (symbol_partitioned_p (node))
     {
@@ -922,7 +922,7 @@  lto_promote_cross_file_statics (void)
     {
       ltrans_partition part
 	= ltrans_partitions[i];
-      part->encoder = compute_ltrans_boundary (part->encoder);
+      part->encoder = compute_ltrans_boundary (part->encoder, false);
     }
 
   /* Look at boundaries and promote symbols as needed.  */
diff --git a/gcc/passes.c b/gcc/passes.c
index f3f85fd..3fd0251 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -2321,7 +2321,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;
@@ -2359,16 +2359,16 @@  ipa_write_summaries (void)
 	  pop_cfun ();
 	}
       if (node->symbol.definition)
-        lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node);
+        lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node, is_omp);
     }
 
   FOR_EACH_DEFINED_FUNCTION (node)
     if (node->symbol.alias)
-      lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node);
+      lto_set_symtab_encoder_in_partition (encoder, (symtab_node)node, is_omp);
   FOR_EACH_DEFINED_VARIABLE (vnode)
-    lto_set_symtab_encoder_in_partition (encoder, (symtab_node)vnode);
+    lto_set_symtab_encoder_in_partition (encoder, (symtab_node)vnode, is_omp);
 
-  ipa_write_summaries_1 (compute_ltrans_boundary (encoder));
+  ipa_write_summaries_1 (compute_ltrans_boundary (encoder, is_omp));
 
   free (order);
 }
diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
index ea1a62f..40e1882 100644
--- a/gcc/tree-pass.h
+++ b/gcc/tree-pass.h
@@ -598,7 +598,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);