https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126437
Bug ID: 126437
Summary: Re: openmp: Implicitly add 'declare target' directives
for dynamic initializers in C++
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: openmp
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tschwinge at gcc dot gnu.org
CC: burnus at gcc dot gnu.org, jakub at gcc dot gnu.org
Target Milestone: ---
I was (for other reasons) looking into tree dumps of the
'g++.dg/gomp/declare-target-3.C' test case added in commit
r11-6257-g3af02d32cce2ff1ff11d078cf8094305f57ca179 "openmp: Implicitly add
'declare target' directives for dynamic initializers in C++", and I'm confused.
I see the usual (host-side) dynamic initialization:
void __static_initialization_and_destruction_0 ()
{
_1 = foo ();
a = _1;
_2 = bar ();
b = _2;
_3 = baz ();
c = _3;
_4 = qux ();
e = _4;
e.0_5 = e;
_6 = e.0_5 + 1;
f = _6;
}
void _GLOBAL__sub_I__Z3foov ()
{
__static_initialization_and_destruction_0 ();
}
..., but only "Explicitly marked" 'b' appears to get dynamically initialized in
device code, but not the "Implicitly marked" variables that end up in
'.offload_var_table': 'c', 'e', 'f':
__attribute__((omp declare target nohost, omp declare target))
void __omp_target_static_init_and_destruction_0 ()
{
_1 = __builtin_omp_is_initial_device ();
if (_1 != 1) goto <D.2800>; else goto <D.2801>;
<D.2800>:
_2 = bar ();
b = _2;
goto <D.2802>;
<D.2801>:
<D.2802>:
}
__attribute__((omp declare target nohost, omp declare target))
void _GLOBAL__off_I__Z3foov ()
{
__omp_target_static_init_and_destruction_0 ();
}
Am I rightfully confused about this, or not understanding this correctly?