This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR39331, wrong gimple with OMP + RSO
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 1 Mar 2009 21:45:27 +0100 (CET)
- Subject: [PATCH] Fix PR39331, wrong gimple with OMP + RSO
from libgomp.c++/pr27337.C at -O3 we get in 042i.inline
ret.12_15 = &x.8;
.omp_data_o.11.ret ={v} ret.12_15;
__builtin_GOMP_parallel_start (_Z3barv.omp_fn.0, &.omp_data_o.11, 4);
_Z3barv.omp_fn.0 (&.omp_data_o.11);
__builtin_GOMP_parallel_end ();
ret.13_16 = .omp_data_o.11.ret;
&x.8 = ret.13_16;
in main() from inlining foo() here:
<bb 8>:
x.8 ={v} bar (); [return slot optimization]
x ={v} x.8;
where bar () looks like
S bar() ()
{
struct S & ret.5;
struct .omp_data_s.10 .omp_data_o.11;
struct S & ret.12;
struct S & ret.13;
<bb 2>:
ret.5_1 = <retval>;
__comp_ctor (ret.5_1);
ret.12_2 = <retval>;
.omp_data_o.11.ret ={v} ret.12_2;
__builtin_GOMP_parallel_start (_Z3barv.omp_fn.0, &.omp_data_o.11, 4);
_Z3barv.omp_fn.0 (&.omp_data_o.11);
__builtin_GOMP_parallel_end ();
ret.13_3 = .omp_data_o.11.ret;
<retval> ={v} ret.13_3;
return <retval>;
}
which is broken as we assign to <retval> which is DECL_BY_REFERENCE.
Fixed with the following, bootstrapped and tested on
x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2009-03-01 Richard Guenther <rguenther@suse.de>
PR tree-optimization/39331
* omp-low.c (lower_send_shared_vars): Do not receive new
values for the reference of DECL_BY_REFERENCE parms or results.
Index: gcc/omp-low.c
===================================================================
*** gcc/omp-low.c (revision 144492)
--- gcc/omp-low.c (working copy)
*************** lower_send_shared_vars (gimple_seq *ilis
*** 2823,2829 ****
x = build_sender_ref (ovar, ctx);
gimplify_assign (x, var, ilist);
! if (!TREE_READONLY (var))
{
x = build_sender_ref (ovar, ctx);
gimplify_assign (var, x, olist);
--- 2823,2836 ----
x = build_sender_ref (ovar, ctx);
gimplify_assign (x, var, ilist);
! if (!TREE_READONLY (var)
! /* We don't need to receive a new reference to a result
! or parm decl. In fact we may not store to it as we will
! invalidate any pending RSO and generate wrong gimple
! during inlining. */
! && !((TREE_CODE (var) == RESULT_DECL
! || TREE_CODE (var) == PARM_DECL)
! && DECL_BY_REFERENCE (var)))
{
x = build_sender_ref (ovar, ctx);
gimplify_assign (var, x, olist);