This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/39331] OpenMP and return-slot-optimization generate invalid gimple



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]