diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-05-14 09:58:53 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-05-14 09:58:53 +0200 |
commit | 7a50e7087567cffb21e81fff566546b8a8dac270 (patch) | |
tree | 7b4fc05ad96c8d9a07a0d6a62c587b88ce04abcf /gcc/cgraph.c | |
parent | d0fb9ffc1b8f3b86bbdf0e915cec2136141b329b (diff) | |
download | gcc-7a50e7087567cffb21e81fff566546b8a8dac270.zip gcc-7a50e7087567cffb21e81fff566546b8a8dac270.tar.gz gcc-7a50e7087567cffb21e81fff566546b8a8dac270.tar.bz2 |
openmp: cgraph support for late declare variant resolution
This is a new version of the
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-11/msg01493.html
patch. Unlike the previous version, this one actually works properly
except for LTO, bootstrapped/regtested on x86_64-linux and i686-linux
too.
In short, #pragma omp declare variant is a directive which allows
redirection of direct calls to certain function to other calls with a
scoring system and some of those decisions need to be deferred until after
IPA. The patch represents them with calls to an artificial FUNCTION_DECL
with declare_variant_alt in the cgraph_node set.
For LTO, the patch only saves/restores the two cgraph_node bits added in the
patch, but doesn't yet stream out and back in the on the side info for the
declare_variant_alt. For the LTO partitioning, I believe those artificial
FUNCTION_DECLs with declare_variant_alt need to go into partition together
with anything that calls them (possibly duplicated), any way how to achieve
that? Say if declare variant artificial fn foobar is directly
called from all of foo, bar and baz and not from qux and we want 4
partitions, one for each of foo, bar, baz, qux, then foobar is needed in the
first 3 partitions, and the IPA_REF_ADDRs recorded for foobar that right
after IPA the foobar call will be replaced with calls to foobar1, foobar2,
foobar3 or foobar (non-artificial) can of course stay in different
partitions if needed.
2020-05-14 Jakub Jelinek <jakub@redhat.com>
* Makefile.in (GTFILES): Add omp-general.c.
* cgraph.h (struct cgraph_node): Add declare_variant_alt and
calls_declare_variant_alt members and initialize them in the
ctor.
* ipa.c (symbol_table::remove_unreachable_nodes): Handle direct
calls to declare_variant_alt nodes.
* lto-cgraph.c (lto_output_node): Write declare_variant_alt
and calls_declare_variant_alt.
(input_overwrite_node): Read them back.
* omp-simd-clone.c (simd_clone_create): Copy calls_declare_variant_alt
bit.
* tree-inline.c (expand_call_inline): Or in calls_declare_variant_alt
bit.
(tree_function_versioning): Copy calls_declare_variant_alt bit.
* omp-offload.c (execute_omp_device_lower): Call
omp_resolve_declare_variant on direct function calls.
(pass_omp_device_lower::gate): Also enable for
calls_declare_variant_alt functions.
* omp-general.c (omp_maybe_offloaded): Return false after inlining.
(omp_context_selector_matches): Handle the case when
cfun->curr_properties has PROP_gimple_any bit set.
(struct omp_declare_variant_entry): New type.
(struct omp_declare_variant_base_entry): New type.
(struct omp_declare_variant_hasher): New type.
(omp_declare_variant_hasher::hash, omp_declare_variant_hasher::equal):
New methods.
(omp_declare_variants): New variable.
(struct omp_declare_variant_alt_hasher): New type.
(omp_declare_variant_alt_hasher::hash,
omp_declare_variant_alt_hasher::equal): New methods.
(omp_declare_variant_alt): New variables.
(omp_resolve_late_declare_variant): New function.
(omp_resolve_declare_variant): Call omp_resolve_late_declare_variant
when called late. Create a magic declare_variant_alt fndecl and
cgraph node and return that if decision needs to be deferred until
after gimplification.
* cgraph.c (symbol_table::create_edge): Or in calls_declare_variant_alt
bit.
* c-c++-common/gomp/declare-variant-14.c: New test.
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r-- | gcc/cgraph.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 2a9813d..c0b4579 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -915,6 +915,8 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node *callee, caller->decl); else edge->in_polymorphic_cdtor = caller->thunk.thunk_p; + if (callee) + caller->calls_declare_variant_alt |= callee->declare_variant_alt; if (callee && symtab->state != LTO_STREAMING && edge->callee->comdat_local_p ()) |