diff options
author | Ilya Verbin <ilya.verbin@intel.com> | 2014-11-13 13:37:38 +0000 |
---|---|---|
committer | Kirill Yukhin <kyukhin@gcc.gnu.org> | 2014-11-13 13:37:38 +0000 |
commit | 1f6be68256cac22721f42085e014ad0c26e6dbb9 (patch) | |
tree | 43f38178c7cf5aad2c04113110efd75a815996be /gcc/lto-cgraph.c | |
parent | 85c64bbee96e9a877a0138a509c42ad6feb4d189 (diff) | |
download | gcc-1f6be68256cac22721f42085e014ad0c26e6dbb9.zip gcc-1f6be68256cac22721f42085e014ad0c26e6dbb9.tar.gz gcc-1f6be68256cac22721f42085e014ad0c26e6dbb9.tar.bz2 |
[PATCH 2/7] OpenMP 4.0 offloading infrastructure: LTO streaming.
gcc/
* cgraph.c: Include context.h.
(cgraph_node::create): Set node->offloadable and g->have_offload if
decl have "omp declare target" attribute.
* cgraph.h (symtab_node): Add need_lto_streaming and offloadable flags.
* cgraphunit.c: Include lto-section-names.h.
(ipa_passes): Call ipa_write_summaries if there is something to write to
OFFLOAD_SECTION_NAME_PREFIX sections.
(symbol_table::compile): Set flag_generate_lto if there is something to
offload.
Replace flag_lto with flag_generate_lto before lto_streamer_hooks_init.
* context.c (gcc::context::context): Initialize have_offload with false.
* context.h (class context): Add have_offload flag.
* ipa-inline-analysis.c (inline_generate_summary): Do not exit under
flag_generate_lto.
(inline_free_summary): Always remove hooks.
* lto-cgraph.c (referenced_from_other_partition_p): Ignore references
from non-offloadable nodes while streaming a node into offload section.
(reachable_from_other_partition_p): Likewise.
(select_what_to_stream): New function.
(compute_ltrans_boundary): Do not call
lto_set_symtab_encoder_in_partition if the node should not be streamed.
* lto-section-names.h (OFFLOAD_SECTION_NAME_PREFIX): Define.
(section_name_prefix): Declare.
* lto-streamer.c (section_name_prefix): New variable.
(lto_get_section_name): Use section_name_prefix instead of
LTO_SECTION_NAME_PREFIX.
* lto-streamer.h (select_what_to_stream): Declare.
* omp-low.c: Include context.h.
(is_targetreg_ctx): New function.
(scan_sharing_clauses): Use offloadable flag, instead of an attribute.
(create_omp_child_function, check_omp_nesting_restrictions): Use new
is_targetreg_ctx function. Replace usage of "omp declare target"
attribute with a cgraph_node flag offloadable.
(expand_omp_target): Set mark_force_output for offloadable functions.
(lower_omp_critical): Set offloadable flag for omp critical symbol.
* passes.c (ipa_write_summaries): New argument offload_lto_mode. Call
select_what_to_stream. Do not call lto_set_symtab_encoder_in_partition
if the node should not be streamed out.
* tree-pass.h (ipa_write_summaries): New bool argument.
* varpool.c: Include context.h.
(varpool_node::get_create): Set node->offloadable and g->have_offload if
decl have "omp declare target" attribute.
gcc/lto/
* lto-object.c (lto_obj_add_section): Use section_name_prefix instead of
LTO_SECTION_NAME_PREFIX.
* lto-partition.c (lto_promote_cross_file_statics): Call
select_what_to_stream.
* lto.c (lto_section_with_id): Use section_name_prefix instead of
LTO_SECTION_NAME_PREFIX.
(read_cgraph_and_symbols): Read OFFLOAD_SECTION_NAME_PREFIX sections, if
being built as an offload compiler.
Co-Authored-By: Andrey Turetskiy <andrey.turetskiy@intel.com>
Co-Authored-By: Bernd Schmidt <bernds@codesourcery.com>
Co-Authored-By: Michael Zolotukhin <michael.v.zolotukhin@intel.com>
From-SVN: r217486
Diffstat (limited to 'gcc/lto-cgraph.c')
-rw-r--r-- | gcc/lto-cgraph.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c index da1f0e4..fc8410c 100644 --- a/gcc/lto-cgraph.c +++ b/gcc/lto-cgraph.c @@ -330,6 +330,11 @@ referenced_from_other_partition_p (symtab_node *node, lto_symtab_encoder_t encod for (i = 0; node->iterate_referring (i, ref); i++) { + /* Ignore references from non-offloadable nodes while streaming NODE into + offload LTO section. */ + if (!ref->referring->need_lto_streaming) + continue; + if (ref->referring->in_other_partition || !lto_symtab_encoder_in_partition_p (encoder, ref->referring)) return true; @@ -348,9 +353,16 @@ reachable_from_other_partition_p (struct cgraph_node *node, lto_symtab_encoder_t if (node->global.inlined_to) return false; for (e = node->callers; e; e = e->next_caller) - if (e->caller->in_other_partition - || !lto_symtab_encoder_in_partition_p (encoder, e->caller)) - return true; + { + /* Ignore references from non-offloadable nodes while streaming NODE into + offload LTO section. */ + if (!e->caller->need_lto_streaming) + continue; + + if (e->caller->in_other_partition + || !lto_symtab_encoder_in_partition_p (encoder, e->caller)) + return true; + } return false; } @@ -818,6 +830,16 @@ create_references (lto_symtab_encoder_t encoder, symtab_node *node) lto_symtab_encoder_encode (encoder, ref->referred); } +/* Select what needs to be streamed out. In regular lto mode stream everything. + In offload lto mode stream only nodes marked as offloadable. */ +void +select_what_to_stream (bool offload_lto_mode) +{ + struct symtab_node *snode; + FOR_EACH_SYMBOL (snode) + snode->need_lto_streaming = !offload_lto_mode || snode->offloadable; +} + /* Find all symbols we want to stream into given partition and insert them to encoders. @@ -844,6 +866,8 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder) !lsei_end_p (lsei); lsei_next_function_in_partition (&lsei)) { struct cgraph_node *node = lsei_cgraph_node (lsei); + if (!node->need_lto_streaming) + continue; add_node_to (encoder, node, true); lto_set_symtab_encoder_in_partition (encoder, node); create_references (encoder, node); @@ -860,6 +884,8 @@ compute_ltrans_boundary (lto_symtab_encoder_t in_encoder) { varpool_node *vnode = lsei_varpool_node (lsei); + if (!vnode->need_lto_streaming) + continue; lto_set_symtab_encoder_in_partition (encoder, vnode); lto_set_symtab_encoder_encode_initializer (encoder, vnode); create_references (encoder, vnode); |