aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTobias Burnus <tburnus@baylibre.com>2024-08-01 09:06:32 +0200
committerTobias Burnus <tburnus@baylibre.com>2024-08-01 09:06:32 +0200
commitc99cdcab4f1c497a872cf552138fd8ea27e9a5eb (patch)
treebed53376395653556c931ff102aeb24bdf12e9ec /gcc
parent25dba615e3c191f0a7264538b6d260e91ca2624a (diff)
downloadgcc-c99cdcab4f1c497a872cf552138fd8ea27e9a5eb.zip
gcc-c99cdcab4f1c497a872cf552138fd8ea27e9a5eb.tar.gz
gcc-c99cdcab4f1c497a872cf552138fd8ea27e9a5eb.tar.bz2
omp-offload.cc: Fix value-expr handling of 'declare target link' vars [PR115637]
As the PR and included testcase shows, replacing 'arr2' by its value expression '*arr2$13$linkptr' failed for MEM <uint128_t> [(c_char * {ref-all})&arr2] which left 'arr2' in the code as unknown symbol. Now expand the value expression already in pass_omp_target_link::execute's process_link_var_op walk_gimple_stmt walk - and don't rely on gimple_regimplify_operands. PR middle-end/115637 gcc/ChangeLog: * gimplify.cc (gimplify_body): Fix macro name in the comment. * omp-offload.cc (find_link_var_op): Rename to ... (process_link_var_op): ... this. Replace value expr. (pass_omp_target_link::execute): Update walk_gimple_stmt call. libgomp/ChangeLog: * testsuite/libgomp.fortran/declare-target-link.f90: Uncomment now working code. Co-authored-by: Richard Biener <rguenther@suse.de
Diffstat (limited to 'gcc')
-rw-r--r--gcc/gimplify.cc2
-rw-r--r--gcc/omp-offload.cc11
2 files changed, 9 insertions, 4 deletions
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index c77a53bd..30bfecf 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -19423,7 +19423,7 @@ gimplify_body (tree fndecl, bool do_parms)
DECL_SAVED_TREE (fndecl) = NULL_TREE;
/* If we had callee-copies statements, insert them at the beginning
- of the function and clear DECL_VALUE_EXPR_P on the parameters. */
+ of the function and clear DECL_HAS_VALUE_EXPR_P on the parameters. */
if (!gimple_seq_empty_p (parm_stmts))
{
tree parm;
diff --git a/gcc/omp-offload.cc b/gcc/omp-offload.cc
index 35313c2..934fbd8 100644
--- a/gcc/omp-offload.cc
+++ b/gcc/omp-offload.cc
@@ -2884,8 +2884,9 @@ public:
/* Callback for walk_gimple_stmt used to scan for link var operands. */
static tree
-find_link_var_op (tree *tp, int *walk_subtrees, void *)
+process_link_var_op (tree *tp, int *walk_subtrees, void *data)
{
+ struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
tree t = *tp;
if (VAR_P (t)
@@ -2893,8 +2894,9 @@ find_link_var_op (tree *tp, int *walk_subtrees, void *)
&& is_global_var (t)
&& lookup_attribute ("omp declare target link", DECL_ATTRIBUTES (t)))
{
+ wi->info = *tp = unshare_expr (DECL_VALUE_EXPR (t));
*walk_subtrees = 0;
- return t;
+ return NULL_TREE;
}
return NULL_TREE;
@@ -2924,7 +2926,10 @@ pass_omp_target_link::execute (function *fun)
gimple_call_set_arg (gsi_stmt (gsi), 1, null_pointer_node);
update_stmt (gsi_stmt (gsi));
}
- if (walk_gimple_stmt (&gsi, NULL, find_link_var_op, NULL))
+ struct walk_stmt_info wi;
+ memset (&wi, 0, sizeof (wi));
+ walk_gimple_stmt (&gsi, NULL, process_link_var_op, &wi);
+ if (wi.info)
gimple_regimplify_operands (gsi_stmt (gsi), &gsi);
}
}