This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/39331] OpenMP and return-slot-optimization generate invalid gimple
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Mar 2009 17:26:38 -0000
- Subject: [Bug tree-optimization/39331] OpenMP and return-slot-optimization generate invalid gimple
- References: <bug-39331-10053@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from rguenth at gcc dot gnu dot org 2009-03-01 17:26 -------
omp-lower introduces the store to <retval> which seems useless as with
a pass-by-reference retval we will never change the address itself.
ret.12 = <retval>;
.omp_data_o.11.ret = ret.12;
{
#pragma omp parallel num_threads(4) shared(<retval>) [child fn:
_Z3barv.omp_fn.0 (.omp_data_o.11)]
...
}
ret.13 = .omp_data_o.11.ret;
<retval> = ret.13;
The following seems to fix it:
Index: omp-low.c
===================================================================
--- omp-low.c (revision 144492)
+++ omp-low.c (working copy)
@@ -2823,7 +2823,14 @@ lower_send_shared_vars (gimple_seq *ilis
x = build_sender_ref (ovar, ctx);
gimplify_assign (x, var, ilist);
- if (!TREE_READONLY (var))
+ 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);
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39331