public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/115574] New: [OpenMP] Nested C function – 'declare target link(var)' leads to "referenced in offloaded code but hasn't been marked to be included in the offloaded code"
@ 2024-06-21 7:18 burnus at gcc dot gnu.org
2024-06-25 14:53 ` [Bug middle-end/115574] " tschwinge at gcc dot gnu.org
2024-06-25 15:35 ` burnus at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2024-06-21 7:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115574
Bug ID: 115574
Summary: [OpenMP] Nested C function – 'declare target
link(var)' leads to "referenced in offloaded code but
hasn't been marked to be included in the offloaded
code"
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: openmp, rejects-valid
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
CC: jakub at gcc dot gnu.org
Target Milestone: ---
C variant for the issue PR 115559.
[Nested functions are a GNU extension - thus, we may decide not to fix this.]
Nonetheless, the following compiles but fails during device LTO:
foo.c:2:13: error: variable 'a' has been referenced in offloaded code but
hasn't been marked to be included in the offloaded code
2 | static int a, b[5];
| ^
foo.c:2:16: error: variable 'b' has been referenced in offloaded code but
hasn't been marked to be included in the offloaded code
2 | static int a, b[5];
void f() {
static int a, b[5];
#pragma declare target link(a,b)
void g() { a = 7; b[3] = 3; }
// #pragma omp declare target enter(g)
#pragma omp target map(tofrom: a, b)
g();
}
The problem is the global-var check in c/c-parser.cc (and cp/parser.cc):
id = get_identifier ("omp declare target link");
std::swap (at1, at2);
}
...
if (!at1)
{
DECL_ATTRIBUTES (t) = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (t));
if (TREE_CODE (t) != FUNCTION_DECL && !is_global_var (t))
continue;
symtab_node *node = symtab_node::get (t);
if (node != NULL)
{
node->offloadable = 1;
...
vec_safe_push (offload_vars, t);
As neither is a global var, it is not added.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/115574] [OpenMP] Nested C function – 'declare target link(var)' leads to "referenced in offloaded code but hasn't been marked to be included in the offloaded code"
2024-06-21 7:18 [Bug middle-end/115574] New: [OpenMP] Nested C function – 'declare target link(var)' leads to "referenced in offloaded code but hasn't been marked to be included in the offloaded code" burnus at gcc dot gnu.org
@ 2024-06-25 14:53 ` tschwinge at gcc dot gnu.org
2024-06-25 15:35 ` burnus at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: tschwinge at gcc dot gnu.org @ 2024-06-25 14:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115574
Thomas Schwinge <tschwinge at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tschwinge at gcc dot gnu.org
--- Comment #1 from Thomas Schwinge <tschwinge at gcc dot gnu.org> ---
(Just noting that fixing the code à la '-Wunknown-pragmas' doesn't seem to make
a difference re the 'error' diagnostics.)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/115574] [OpenMP] Nested C function – 'declare target link(var)' leads to "referenced in offloaded code but hasn't been marked to be included in the offloaded code"
2024-06-21 7:18 [Bug middle-end/115574] New: [OpenMP] Nested C function – 'declare target link(var)' leads to "referenced in offloaded code but hasn't been marked to be included in the offloaded code" burnus at gcc dot gnu.org
2024-06-25 14:53 ` [Bug middle-end/115574] " tschwinge at gcc dot gnu.org
@ 2024-06-25 15:35 ` burnus at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2024-06-25 15:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115574
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
> #pragma declare target link(a,b)
as Thomas pointed out (cf. comment 1), an 'omp' is missing.
It also lacks, e.g. '#pragma omp target enter data map(a, b)' to be valid.
Still, the real issue is '!is_global_var (t)' which is only valid if there is
no nested function which is 'declare target', as that can access the static
variable through the backdoor.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-25 15:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-21 7:18 [Bug middle-end/115574] New: [OpenMP] Nested C function – 'declare target link(var)' leads to "referenced in offloaded code but hasn't been marked to be included in the offloaded code" burnus at gcc dot gnu.org
2024-06-25 14:53 ` [Bug middle-end/115574] " tschwinge at gcc dot gnu.org
2024-06-25 15:35 ` burnus at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).