https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79432

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Similar testcase a patch I have for the first doesn't fix:

int fn1 (void);
int __attribute__((returns_twice)) vfork (void);
void fn2 ()
{
  int a;
  a = fn1() + 1 + vfork();
}


That patch:

Index: gcc/gimplify.c
===================================================================
--- gcc/gimplify.c      (revision 245299)
+++ gcc/gimplify.c      (working copy)
@@ -12150,7 +12150,15 @@ gimplify_expr (tree *expr_p, gimple_seq
         TMP.  First, make sure that the expression has a type so that
         it can be assigned into a temporary.  */
       gcc_assert (!VOID_TYPE_P (TREE_TYPE (*expr_p)));
-      *expr_p = get_formal_tmp_var (*expr_p, pre_p);
+      /* If we assign the result of a call if that call can make an abnormal
+         goto we can't use an SSA name for the result as uses may not
+        dominate the definition in this case.  */
+      if (gimplify_ctxp->into_ssa
+         && TREE_CODE (*expr_p) == CALL_EXPR
+         && ! (call_expr_flags (*expr_p) & (ECF_LEAF | ECF_CONST | ECF_PURE)))
+       *expr_p = get_initialized_tmp_var (*expr_p, pre_p, NULL, false);
+      else
+       *expr_p = get_formal_tmp_var (*expr_p, pre_p);
     }
   else
     {

but it's not enough to look at calls as with the above testcase and the patch
we still have

  <bb 2> [0.00%]:
  D.1804 = fn1 ();

  <bb 3> [0.00%]:
  D.1802 = D.1804;
  _1 = D.1802 + 1;

  <bb 4> [0.00%]:
  D.1805 = vfork ();
  goto <bb 6>; [0.00%]

  <bb 6> [0.00%]:
  D.1803 = D.1805;
  a = D.1803 + _1;
  return;

so it's really about having _any_ abnormal edge receiver inside an expression.
The idea with SSA at gimplification was that we know we only have single uses
and this use is in the same BB as the definition.  All user var sets do not
get SSA vars.

Eventually looking at calls _is_ enough if we can emit them first, thus,
reorder the GIMPLE from

  D.1802 = fn1 ();
  _1 = D.1802 + 1;
  D.1803 = vfork ();
  a = D.1803 + _1;

to

  D.1802 = fn1 ();
  D.1803 = vfork ();
  _1 = D.1802 + 1;
  a = D.1803 + _1;

...

Reply via email to