public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ PATCH] Fix ICE due to Cilk+ related cp_gimplify_expr bug (PR objc++/68511, PR c++/69213)
@ 2016-01-11 17:24 Jakub Jelinek
  2016-01-12 13:32 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2016-01-11 17:24 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

Hi!

If errors are reported in unrelated functions, then due to recent
Cilk+ related change in cp_gimplify_expr basically all gimplification
results in almost no statements to be added to the IL, while returning
SSA_NAMEs set by the missing code, because for INIT_EXPRs cp_gimplify_expr
would just return GS_ERROR if seen_error () instead of actually doing
anything.

Igor has posted a fix for this a month ago:
https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00651.html
but that fix still looks wrong to me, it seems it will just limit
the problems to functions that originally contained at least one
_Cilk_spawn.

The fix limits the GS_ERROR to a) functions that contain _Cilk_spawn
b) if cilk_detect_spawn_and_unwrap fails (that can be for two reasons,
that _Cilk_spawn is not present at all, or if it is present, but used
in incorrect place) c) if _Cilk_spawn is present in the expression.
As cilk_detect_spawn_and_unwrap will already report error if it is present,
but in incorrect place, the c) test is guarded with seen_error (), so there
is no additional compile time cost in correct programs (or functions not
containing _Cilk_spawn at all).

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2016-01-11  Jakub Jelinek  <jakub@redhat.com>

	PR objc++/68511
	PR c++/69213
	* cp-gimplify.c (cp_gimplify_expr) <case INIT_EXPR>: Don't return
	GS_ERROR whenever seen_error (), only if *expr_p contains
	cilk spawn stmt, but cilk_detect_spawn_and_unwrap failed.

	* g++.dg/opt/pr69213.C: New test.

--- gcc/cp/cp-gimplify.c.jj	2016-01-04 14:55:57.000000000 +0100
+++ gcc/cp/cp-gimplify.c	2016-01-11 13:22:36.475552358 +0100
@@ -617,14 +617,17 @@ cp_gimplify_expr (tree *expr_p, gimple_s
 	 LHS of an assignment might also be involved in the RHS, as in bug
 	 25979.  */
     case INIT_EXPR:
-      if (fn_contains_cilk_spawn_p (cfun)
-	  && cilk_detect_spawn_and_unwrap (expr_p))
+      if (fn_contains_cilk_spawn_p (cfun))
 	{
-	  cilk_cp_gimplify_call_params_in_spawned_fn (expr_p, pre_p, post_p);
-	  return (enum gimplify_status) gimplify_cilk_spawn (expr_p);
+	  if (cilk_detect_spawn_and_unwrap (expr_p))
+	    {
+	      cilk_cp_gimplify_call_params_in_spawned_fn (expr_p,
+							  pre_p, post_p);
+	      return (enum gimplify_status) gimplify_cilk_spawn (expr_p);
+	    }
+	  if (seen_error () && contains_cilk_spawn_stmt (*expr_p))
+	    return GS_ERROR;
 	}
-      if (seen_error ())
-	return GS_ERROR;
 
       cp_gimplify_init_expr (expr_p);
       if (TREE_CODE (*expr_p) != INIT_EXPR)
--- gcc/testsuite/g++.dg/opt/pr69213.C.jj	2016-01-11 13:18:05.949292994 +0100
+++ gcc/testsuite/g++.dg/opt/pr69213.C	2016-01-11 13:18:53.276638586 +0100
@@ -0,0 +1,18 @@
+// PR c++/69213
+// { dg-do compile }
+// { dg-options "-O3" }
+
+int a, b;
+
+void
+foo (void)
+{
+  __asm__ ("# %0" : : : "memory");	// { dg-error "operand number out of range" }
+}
+
+int
+main ()
+{
+  for (; a < 0; b++)
+    a = b;
+}


	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [C++ PATCH] Fix ICE due to Cilk+ related cp_gimplify_expr bug (PR objc++/68511, PR c++/69213)
  2016-01-11 17:24 [C++ PATCH] Fix ICE due to Cilk+ related cp_gimplify_expr bug (PR objc++/68511, PR c++/69213) Jakub Jelinek
@ 2016-01-12 13:32 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2016-01-12 13:32 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

OK.

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-12 13:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-11 17:24 [C++ PATCH] Fix ICE due to Cilk+ related cp_gimplify_expr bug (PR objc++/68511, PR c++/69213) Jakub Jelinek
2016-01-12 13:32 ` Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).