re PR libgomp/83590 ([nvptx] openacc reduction C regressions)
authorJakub Jelinek <jakub@redhat.com>
Tue, 16 Jan 2018 15:18:24 +0000 (16:18 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 16 Jan 2018 15:18:24 +0000 (16:18 +0100)
PR libgomp/83590
* gimplify.c (gimplify_one_sizepos): For is_gimple_constant (expr)
return early, inline manually is_gimple_sizepos.  Make sure if we
call gimplify_expr we don't end up with a gimple constant.
* tree.c (variably_modified_type_p): Don't return true for
is_gimple_constant (_t).  Inline manually is_gimple_sizepos.
* gimplify.h (is_gimple_sizepos): Remove.

Co-Authored-By: Richard Biener <rguenther@suse.de>
From-SVN: r256748

gcc/ChangeLog
gcc/gimplify.c
gcc/gimplify.h
gcc/tree.c

index 979f5ae487144845c7f19b6ef8b619d825fa330b..343aefdc0deb4729b3d1ee08107206f989c657f8 100644 (file)
@@ -1,3 +1,14 @@
+2018-01-16  Jakub Jelinek  <jakub@redhat.com>
+           Richard Biener  <rguenth@suse.de>
+
+       PR libgomp/83590
+       * gimplify.c (gimplify_one_sizepos): For is_gimple_constant (expr)
+       return early, inline manually is_gimple_sizepos.  Make sure if we
+       call gimplify_expr we don't end up with a gimple constant.
+       * tree.c (variably_modified_type_p): Don't return true for
+       is_gimple_constant (_t).  Inline manually is_gimple_sizepos.
+       * gimplify.h (is_gimple_sizepos): Remove.
+
 2018-01-16  Richard Sandiford  <richard.sandiford@linaro.org>
 
        PR tree-optimization/83857
index fd0d21ebe4d422a613f396e394c5219bcde8289f..8e86c338fc1f6ff6a4012ac9c377cf1087dca1df 100644 (file)
@@ -12562,7 +12562,10 @@ gimplify_one_sizepos (tree *expr_p, gimple_seq *stmt_p)
      a VAR_DECL.  If it's a VAR_DECL from another function, the gimplifier
      will want to replace it with a new variable, but that will cause problems
      if this type is from outside the function.  It's OK to have that here.  */
-  if (is_gimple_sizepos (expr))
+  if (expr == NULL_TREE
+      || is_gimple_constant (expr)
+      || TREE_CODE (expr) == VAR_DECL
+      || CONTAINS_PLACEHOLDER_P (expr))
     return;
 
   *expr_p = unshare_expr (expr);
@@ -12570,6 +12573,12 @@ gimplify_one_sizepos (tree *expr_p, gimple_seq *stmt_p)
   /* SSA names in decl/type fields are a bad idea - they'll get reclaimed
      if the def vanishes.  */
   gimplify_expr (expr_p, stmt_p, NULL, is_gimple_val, fb_rvalue, false);
+
+  /* If expr wasn't already is_gimple_sizepos or is_gimple_constant from the
+     FE, ensure that it is a VAR_DECL, otherwise we might handle some decls
+     as gimplify_vla_decl even when they would have all sizes INTEGER_CSTs.  */
+  if (is_gimple_constant (*expr_p))
+    *expr_p = get_initialized_tmp_var (*expr_p, stmt_p, NULL, false);
 }
 
 /* Gimplify the body of statements of FNDECL and return a GIMPLE_BIND node
index 2b70d3210592417380a8da4ff1f754697d0519ce..dd0e4c01752bc919cd6b8d3eaf35e8c874409d72 100644 (file)
@@ -85,23 +85,4 @@ extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *,
                                                  gimple_seq *);
 gimple *gimplify_assign (tree, tree, gimple_seq *);
 
-/* Return true if gimplify_one_sizepos doesn't need to gimplify
-   expr (when in TYPE_SIZE{,_UNIT} and similar type/decl size/bitsize
-   fields).  */
-
-static inline bool
-is_gimple_sizepos (tree expr)
-{
-  /* gimplify_one_sizepos doesn't need to do anything if the value isn't there,
-     is constant, or contains A PLACEHOLDER_EXPR.  We also don't want to do
-     anything if it's already a VAR_DECL.  If it's a VAR_DECL from another
-     function, the gimplifier will want to replace it with a new variable,
-     but that will cause problems if this type is from outside the function.
-     It's OK to have that here.  */
-  return (expr == NULL_TREE
-         || TREE_CODE (expr) == INTEGER_CST
-         || TREE_CODE (expr) == VAR_DECL
-         || CONTAINS_PLACEHOLDER_P (expr));
-}                                        
-
 #endif /* GCC_GIMPLIFY_H */
index 3c1403b429a45262b59dfda262c303571d103f38..b3e93b87eb2dc0079b05fc20804531876bd52b90 100644 (file)
@@ -8825,11 +8825,12 @@ variably_modified_type_p (tree type, tree fn)
   do { tree _t = (T);                                                  \
     if (_t != NULL_TREE                                                        \
        && _t != error_mark_node                                        \
-       && TREE_CODE (_t) != INTEGER_CST                                \
+       && !CONSTANT_CLASS_P (_t)                                       \
        && TREE_CODE (_t) != PLACEHOLDER_EXPR                           \
        && (!fn                                                         \
            || (!TYPE_SIZES_GIMPLIFIED (type)                           \
-               && !is_gimple_sizepos (_t))                             \
+               && (TREE_CODE (_t) != VAR_DECL                          \
+                   && !CONTAINS_PLACEHOLDER_P (_t)))                   \
            || walk_tree (&_t, find_var_from_fn, fn, NULL)))            \
       return true;  } while (0)