diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-03-02 19:16:14 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-03-02 19:16:14 +0000 |
commit | 00e3f0953dbe63060105f7e7a38ef836f6b258cb (patch) | |
tree | f57aa687d2dd5488df0e71d98672b1e7b3265350 /gcc/omp-low.c | |
parent | d97ba4cabea6af6617c93f4b8bf099f6aea05607 (diff) | |
download | gcc-00e3f0953dbe63060105f7e7a38ef836f6b258cb.tar.gz |
PR libgomp/69555
* gimplify.c (gimplify_decl_expr): For decls with REFERENCE_TYPE, also
gimplify_type_sizes the type they refer to.
(omp_notice_variable): Handle reference vars to VLAs.
* omp-low.c (lower_omp_target): Emit setup of OMP_CLAUSE_PRIVATE reference
to VLA decls in the second pass instead of first pass.
* testsuite/libgomp.c++/pr69555-1.C: New test.
* testsuite/libgomp.c++/pr69555-2.C: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@233913 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r-- | gcc/omp-low.c | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 989d03ef774..ecbf74ad71b 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -16472,13 +16472,7 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) x = build_fold_addr_expr_loc (clause_loc, x); } else - { - tree atmp - = builtin_decl_explicit (BUILT_IN_ALLOCA_WITH_ALIGN); - tree rtype = TREE_TYPE (TREE_TYPE (new_var)); - tree al = size_int (TYPE_ALIGN (rtype)); - x = build_call_expr_loc (clause_loc, atmp, 2, x, al); - } + break; x = fold_convert_loc (clause_loc, TREE_TYPE (new_var), x); gimplify_expr (&x, &new_body, NULL, is_gimple_val, fb_rvalue); @@ -16545,7 +16539,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) } /* Handle GOMP_MAP_FIRSTPRIVATE_{POINTER,REFERENCE} in second pass, so that firstprivate vars holding OMP_CLAUSE_SIZE if needed - are already handled. */ + are already handled. Similarly OMP_CLAUSE_PRIVATE for VLAs + or references to VLAs. */ for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c)) switch (OMP_CLAUSE_CODE (c)) { @@ -16687,6 +16682,27 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) gimple_seq_add_stmt (&new_body, gimple_build_assign (new_pvar, x)); } + else if (is_reference (var) && !is_gimple_omp_oacc (ctx->stmt)) + { + location_t clause_loc = OMP_CLAUSE_LOCATION (c); + tree new_var = lookup_decl (var, ctx); + tree x = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (new_var))); + if (TREE_CONSTANT (x)) + break; + else + { + tree atmp + = builtin_decl_explicit (BUILT_IN_ALLOCA_WITH_ALIGN); + tree rtype = TREE_TYPE (TREE_TYPE (new_var)); + tree al = size_int (TYPE_ALIGN (rtype)); + x = build_call_expr_loc (clause_loc, atmp, 2, x, al); + } + + x = fold_convert_loc (clause_loc, TREE_TYPE (new_var), x); + gimplify_expr (&x, &new_body, NULL, is_gimple_val, fb_rvalue); + gimple_seq_add_stmt (&new_body, + gimple_build_assign (new_var, x)); + } break; } |