aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.cc
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2023-10-18 13:05:35 +0200
committerTobias Burnus <tobias@codesourcery.com>2023-10-18 13:05:35 +0200
commitaf4bb221153359f5948da917d5ef2df738bb1e61 (patch)
treef7a1292d513e724e5970fd0187a33f55aad96d9d /gcc/gimplify.cc
parentf1744dd50bb1661c98b694ff907cb0a1be4f6134 (diff)
downloadgcc-af4bb221153359f5948da917d5ef2df738bb1e61.zip
gcc-af4bb221153359f5948da917d5ef2df738bb1e61.tar.gz
gcc-af4bb221153359f5948da917d5ef2df738bb1e61.tar.bz2
OpenMP: Avoid ICE with LTO and 'omp allocate'
gcc/ChangeLog: * gimplify.cc (gimplify_bind_expr): Remove "omp allocate" attribute to avoid that auxillary statement list reaches LTO. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/allocate-13a.f90: New test.
Diffstat (limited to 'gcc/gimplify.cc')
-rw-r--r--gcc/gimplify.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 9c617c2..22ff107 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -1426,7 +1426,8 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
DECL_ATTRIBUTES (v)
= tree_cons (get_identifier ("omp allocate var"),
build_tree_list (NULL_TREE, t),
- DECL_ATTRIBUTES (t));
+ remove_attribute ("omp allocate",
+ DECL_ATTRIBUTES (t)));
tmp = build_fold_indirect_ref (v);
TREE_THIS_NOTRAP (tmp) = 1;
SET_DECL_VALUE_EXPR (t, tmp);
@@ -1473,7 +1474,12 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
at the top, unless an allocator or size expression
requires to put it afterward; note that the size is
always later in generated code; for strings, no
- size expr but still an expr might be available. */
+ size expr but still an expr might be available.
+ As LTO does not handle a statement list, 'sl' has
+ to be removed; done so by removing the attribute. */
+ DECL_ATTRIBUTES (t)
+ = remove_attribute ("omp allocate",
+ DECL_ATTRIBUTES (t));
tree sl = TREE_PURPOSE (TREE_CHAIN (TREE_VALUE (attr)));
tree_stmt_iterator e = tsi_start (sl);
tree needle = NULL_TREE;
@@ -1631,16 +1637,14 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
&& !is_global_var (t)
&& DECL_CONTEXT (t) == current_function_decl)
{
- tree attr;
if (flag_openmp
&& DECL_HAS_VALUE_EXPR_P (t)
&& TREE_USED (t)
- && ((attr = lookup_attribute ("omp allocate",
- DECL_ATTRIBUTES (t))) != NULL_TREE)
- && TREE_CHAIN (TREE_VALUE (attr)) == NULL_TREE)
+ && lookup_attribute ("omp allocate", DECL_ATTRIBUTES (t)))
{
/* For Fortran, TREE_CHAIN (TREE_VALUE (attr)) is set, which
- causes that the GOMP_free call is already added above. */
+ causes that the GOMP_free call is already added above;
+ and "omp allocate" is removed from DECL_ATTRIBUTES. */
tree v = TREE_OPERAND (DECL_VALUE_EXPR (t), 0);
tree tmp = builtin_decl_explicit (BUILT_IN_GOMP_FREE);
tmp = build_call_expr_loc (end_locus, tmp, 2, v,