[38/40] openacc: fix privatization of by-reference arrays

Message ID 20211215155447.19379-39-frederik@codesourcery.com
State New
Headers
Series OpenACC "kernels" Improvements |

Commit Message

Frederik Harwath Dec. 15, 2021, 3:54 p.m. UTC
  From: Tobias Burnus <tobias@codesourcery.com>

Replacing of a by-reference variable in a private clause by a local variable
makes sense; however, for arrays, the size is not directly known by the type.
This causes an ICE via create_tmp_var which indirectly invokes
force_constant_size in this case - but the latter only handled Ada.

gcc/ChangeLog:

        * gimplify.c (localize_reductions): Do not create local
        variable for privatized arrays.
---
 gcc/gimplify.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--
2.33.0

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
  

Patch

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index a0137089496b..952bc449a7db 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -11982,8 +11982,9 @@  localize_reductions (tree clauses, tree body)

        if (!lang_hooks.decls.omp_privatize_by_reference (var))
          continue;
-
        type = TREE_TYPE (TREE_TYPE (var));
+       if (TREE_CODE (type) == ARRAY_TYPE)
+         continue;
        new_var = create_tmp_var (type, IDENTIFIER_POINTER (DECL_NAME (var)));

        pr.ref_var = var;