https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92357
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I'll note that GCC doesn't yet implement the OpenMP 5.0 automatic declare target for functions with definitions called from declare target functions or target regions. I've tried to do that this summer, but came up with too many questions for which there are no answers yet, so it is e.g. unclear where the compiler should do it, the implementation I had (will attach) was done quite late, which means e.g. that if it should affect in the end whether some variables will be declare target or not implicitly, it would be too late to change depending on that the implicit mapping or privatization behavior on target constructs, because by the time target is resolved declare variant on some vars still wouldn't be done implicitly. In the #c1 testcase, I see only two templates with their single or so method each wrapped in declare target and nothing else, so I bet the testcase is invalid (dunno if that is in the original RAJA). Anyway, with Honza's help I came up with: --- gcc/ipa-fnsummary.c 2019-12-03 21:45:21.538147319 +0100 +++ gcc/ipa-fnsummary.c 2019-12-13 16:24:14.007917974 +0100 @@ -4372,7 +4372,10 @@ ipa_fn_summary_write (void) { symtab_node *snode = lto_symtab_encoder_deref (encoder, i); cgraph_node *cnode = dyn_cast <cgraph_node *> (snode); - if (cnode && cnode->definition && !cnode->alias) + if (cnode + && cnode->definition + && !cnode->alias + && lto_symtab_encoder_in_partition_p (encoder, cnode)) count++; } streamer_write_uhwi (ob, count); @@ -4381,7 +4384,10 @@ ipa_fn_summary_write (void) { symtab_node *snode = lto_symtab_encoder_deref (encoder, i); cgraph_node *cnode = dyn_cast <cgraph_node *> (snode); - if (cnode && cnode->definition && !cnode->alias) + if (cnode + && cnode->definition + && !cnode->alias + && lto_symtab_encoder_in_partition_p (encoder, cnode)) { class ipa_fn_summary *info = ipa_fn_summaries->get (cnode); class ipa_size_summary *size_info = ipa_size_summaries->get (cnode); patch with which this ICE is gone but there is another later on, so more work is needed.