public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PR68001, CilkPlus] Fix for PR68001
@ 2015-11-02 20:08 Zamyatin, Igor
  2015-11-02 22:11 ` Jeff Law
  2015-11-24 13:53 ` Andreas Schwab
  0 siblings, 2 replies; 6+ messages in thread
From: Zamyatin, Igor @ 2015-11-02 20:08 UTC (permalink / raw)
  To: GCC Patches (gcc-patches@gcc.gnu.org)
  Cc: Jeff Law (law@redhat.com), Jakub Jelinek (jakub@redhat.com)

Hi!

This patch attempts to enhance error diagnostic in case of CilkPlus and fixes PR68001.

Bootstrapped and regtested for x86_64.
Is it ok for trunk?

Thanks,
Igor

ChangeLog:

c-family

2015-11-02  Igor Zamyatin  <igor.zamyatin@intel.com>

	PR c++/68001
	* c-gimplify.c (c_gimplify_expr): Stop the process if see an error.
	* cilk.c (recognize_spawn): Determine location in a more precise
	way.

cp

2015-11-02  Igor Zamyatin  <igor.zamyatin@intel.com>

	PR c++/68001
	* cp-gimplify.c (cp_gimplify_expr): Stop the process if see an error.

testsuite

2015-11-02  Igor Zamyatin  <igor.zamyatin@intel.com>

	PR c++/68001
	* g++.dg/cilk-plus/CK/pr68001.cc: New test.


diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c
index 92987b5..5b173d5 100644
--- a/gcc/c-family/c-gimplify.c
+++ b/gcc/c-family/c-gimplify.c
@@ -283,15 +283,16 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED,
 
     case CILK_SPAWN_STMT:
       gcc_assert
-	(fn_contains_cilk_spawn_p (cfun)
-	 && cilk_detect_spawn_and_unwrap (expr_p));
+       (fn_contains_cilk_spawn_p (cfun)
+	&& cilk_detect_spawn_and_unwrap (expr_p));
 
-      /* If errors are seen, then just process it as a CALL_EXPR.  */
       if (!seen_error ())
 	{
 	  cilk_gimplify_call_params_in_spawned_fn (expr_p, pre_p, post_p);
 	  return (enum gimplify_status) gimplify_cilk_spawn (expr_p);
 	}
+      return GS_ERROR;
+
     case MODIFY_EXPR:
     case INIT_EXPR:
     case CALL_EXPR:
diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c
index 1c316a4..77cb6e4 100644
--- a/gcc/c-family/cilk.c
+++ b/gcc/c-family/cilk.c
@@ -82,6 +82,8 @@ struct wrapper_data
   tree block;
 };
 
+static tree
+contains_cilk_spawn_stmt_walker (tree *tp, int *, void *);
 static void extract_free_variables (tree, struct wrapper_data *,
 				    enum add_variable_type);
 static HOST_WIDE_INT cilk_wrapper_count;
@@ -241,7 +243,19 @@ recognize_spawn (tree exp, tree *exp0)
     }
   /* _Cilk_spawn can't be wrapped in expression such as PLUS_EXPR.  */
   else if (contains_cilk_spawn_stmt (exp))
-    error_at (EXPR_LOCATION (exp), "invalid use of %<_Cilk_spawn%>");
+    {
+      location_t loc = EXPR_LOCATION (exp);
+      if (loc == UNKNOWN_LOCATION)
+	{
+	  tree stmt = walk_tree (&exp,
+				 contains_cilk_spawn_stmt_walker,
+				 NULL,
+				 NULL);
+	  gcc_assert (stmt != NULL_TREE);
+	  loc = EXPR_LOCATION (stmt);
+	}
+      error_at (loc, "invalid use of %<_Cilk_spawn%>");
+    }
   return spawn_found;
 }
 
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index e37cbc7..6b444d6 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -625,6 +625,9 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
 	  cilk_cp_gimplify_call_params_in_spawned_fn (expr_p, pre_p, post_p);
 	  return (enum gimplify_status) gimplify_cilk_spawn (expr_p);
 	}
+      else if (seen_error ())
+	return GS_ERROR;
+
       cp_gimplify_init_expr (expr_p);
       if (TREE_CODE (*expr_p) != INIT_EXPR)
 	return GS_OK;
@@ -733,16 +736,17 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
       break;
 
     case CILK_SPAWN_STMT:
-      gcc_assert 
-	(fn_contains_cilk_spawn_p (cfun) 
-	 && cilk_detect_spawn_and_unwrap (expr_p));
+      gcc_assert
+       (fn_contains_cilk_spawn_p (cfun)
+	&& cilk_detect_spawn_and_unwrap (expr_p));
 
-      /* If errors are seen, then just process it as a CALL_EXPR.  */
       if (!seen_error ())
 	{
 	  cilk_cp_gimplify_call_params_in_spawned_fn (expr_p, pre_p, post_p);
 	  return (enum gimplify_status) gimplify_cilk_spawn (expr_p);
 	}
+      return GS_ERROR;
+
     case CALL_EXPR:
       if (fn_contains_cilk_spawn_p (cfun)
 	  && cilk_detect_spawn_and_unwrap (expr_p)
diff --git a/gcc/testsuite/g++.dg/cilk-plus/CK/pr68001.cc b/gcc/testsuite/g++.dg/cilk-plus/CK/pr68001.cc
new file mode 100644
index 0000000..6137c07
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cilk-plus/CK/pr68001.cc
@@ -0,0 +1,19 @@
+/* PR middle-end/68001 */
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+#include <cilk/cilk.h>
+#include <vector>
+
+std::vector<double> f() {
+  std::vector<double> v;
+  return v;
+}
+
+int main()
+{
+  std::vector<double> x = cilk_spawn f(); /* { dg-error "invalid use of" } */
+  std::vector<double> y = f();
+  cilk_sync;
+  return 0;
+}

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

* Re: [PR68001, CilkPlus] Fix for PR68001
  2015-11-02 20:08 [PR68001, CilkPlus] Fix for PR68001 Zamyatin, Igor
@ 2015-11-02 22:11 ` Jeff Law
  2015-11-24 13:53 ` Andreas Schwab
  1 sibling, 0 replies; 6+ messages in thread
From: Jeff Law @ 2015-11-02 22:11 UTC (permalink / raw)
  To: Zamyatin, Igor, GCC Patches (gcc-patches@gcc.gnu.org)
  Cc: Jakub Jelinek (jakub@redhat.com)

On 11/02/2015 01:08 PM, Zamyatin, Igor wrote:
> Hi!
>
> This patch attempts to enhance error diagnostic in case of CilkPlus and fixes PR68001.
>
> Bootstrapped and regtested for x86_64.
> Is it ok for trunk?
>
> Thanks,
> Igor
>
> ChangeLog:
>
> c-family
>
> 2015-11-02  Igor Zamyatin  <igor.zamyatin@intel.com>
> k
> 	PR c++/68001
> 	* c-gimplify.c (c_gimplify_expr): Stop the process if see an error.
> 	* cilk.c (recognize_spawn): Determine location in a more precise
> 	way.
>
> cp
>
> 2015-11-02  Igor Zamyatin  <igor.zamyatin@intel.com>
>
> 	PR c++/68001
> 	* cp-gimplify.c (cp_gimplify_expr): Stop the process if see an error.
>
> testsuite
>
> 2015-11-02  Igor Zamyatin  <igor.zamyatin@intel.com>
>
> 	PR c++/68001
> 	* g++.dg/cilk-plus/CK/pr68001.cc: New test.
>
>
> diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c
> index 92987b5..5b173d5 100644
> --- a/gcc/c-family/c-gimplify.c
> +++ b/gcc/c-family/c-gimplify.c
> @@ -283,15 +283,16 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED,
>
>       case CILK_SPAWN_STMT:
>         gcc_assert
> -	(fn_contains_cilk_spawn_p (cfun)
> -	 && cilk_detect_spawn_and_unwrap (expr_p));
> +       (fn_contains_cilk_spawn_p (cfun)
> +	&& cilk_detect_spawn_and_unwrap (expr_p));
If you're trying to fix the formatting here, I think it ought to look like:

       gcc_assert (fn_contains_cilk_spawn_p (cfun)
                   && cilk_detect_spawn_and_unwrap (expr_p));

ie, go ahead and start the expression on the same line as the 
gcc_assert, line break before the &&, and indent the && just inside the 
open-paren.


>
> +static tree
> +contains_cilk_spawn_stmt_walker (tree *tp, int *, void *);
>   static void extract_free_variables (tree, struct wrapper_data *,
>   				    enum add_variable_type);
Please format in the same way the call to extract_free_variables is 
formatted.


>> @@ -733,16 +736,17 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
>         break;
>
>       case CILK_SPAWN_STMT:
> -      gcc_assert
> -	(fn_contains_cilk_spawn_p (cfun)
> -	 && cilk_detect_spawn_and_unwrap (expr_p));
> +      gcc_assert
> +       (fn_contains_cilk_spawn_p (cfun)
> +	&& cilk_detect_spawn_and_unwrap (expr_p));
Same formatting nit as c-gimplify.c


With the formatting nits fixed, this is fine.
jeff

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

* Re: [PR68001, CilkPlus] Fix for PR68001
  2015-11-02 20:08 [PR68001, CilkPlus] Fix for PR68001 Zamyatin, Igor
  2015-11-02 22:11 ` Jeff Law
@ 2015-11-24 13:53 ` Andreas Schwab
  2015-11-30 20:49   ` Zamyatin, Igor
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2015-11-24 13:53 UTC (permalink / raw)
  To: Zamyatin, Igor
  Cc: GCC Patches (gcc-patches@gcc.gnu.org), Jeff Law (law@redhat.com),
	Jakub Jelinek (jakub@redhat.com)

FAIL: obj-c++.dg/property/dotsyntax-11.mm -fgnu-runtime  (test for errors, line 51)
FAIL: obj-c++.dg/property/dotsyntax-11.mm -fgnu-runtime  (test for errors, line 56)
FAIL: obj-c++.dg/property/dotsyntax-11.mm -fgnu-runtime  (test for errors, line 59)

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

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

* RE: [PR68001, CilkPlus] Fix for PR68001
  2015-11-24 13:53 ` Andreas Schwab
@ 2015-11-30 20:49   ` Zamyatin, Igor
  2015-12-02  7:50     ` Tom de Vries
  2015-12-05 10:09     ` Zamyatin, Igor
  0 siblings, 2 replies; 6+ messages in thread
From: Zamyatin, Igor @ 2015-11-30 20:49 UTC (permalink / raw)
  To: 'Andreas Schwab'
  Cc: GCC Patches (gcc-patches@gcc.gnu.org), Jeff Law (law@redhat.com),
	Jakub Jelinek (jakub@redhat.com)

> 
> FAIL: obj-c++.dg/property/dotsyntax-11.mm -fgnu-runtime  (test for errors,
> line 51)
> FAIL: obj-c++.dg/property/dotsyntax-11.mm -fgnu-runtime  (test for errors,
> line 56)
> FAIL: obj-c++.dg/property/dotsyntax-11.mm -fgnu-runtime  (test for errors,
> line 59)
> 
> Andreas.

Here is the patch that properly limits GS_ERROR exit only in case of error in cilk spawn detection.

Bootstrapped and regtested on x86_64, ok for trunk?

Thanks,
Igor

cp/Changelog

2015-11-27  Igor Zamyatin  <igor.zamyatin@intel.com>

	PR c++/68001
	* cp-gimplify.c (cp_gimplify_expr): Limit GS_ERROR only in case of
	error in cilk spawn detection.



diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 09ee5ff..3dbbd7f 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -559,6 +559,7 @@ int
 cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
 {
   int saved_stmts_are_full_exprs_p = 0;
+  bool is_spawn_detected = true;
   enum tree_code code = TREE_CODE (*expr_p);
   enum gimplify_status ret;
 
@@ -614,12 +615,12 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
 	 25979.  */
     case INIT_EXPR:
       if (fn_contains_cilk_spawn_p (cfun)
-	  && cilk_detect_spawn_and_unwrap (expr_p))
+	  && (is_spawn_detected = 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 ())
+      if (!is_spawn_detected && seen_error ())
 	return GS_ERROR;
 
       cp_gimplify_init_expr (expr_p);



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

* Re: [PR68001, CilkPlus] Fix for PR68001
  2015-11-30 20:49   ` Zamyatin, Igor
@ 2015-12-02  7:50     ` Tom de Vries
  2015-12-05 10:09     ` Zamyatin, Igor
  1 sibling, 0 replies; 6+ messages in thread
From: Tom de Vries @ 2015-12-02  7:50 UTC (permalink / raw)
  To: Zamyatin, Igor, 'Andreas Schwab'
  Cc: GCC Patches (gcc-patches@gcc.gnu.org), Jeff Law (law@redhat.com),
	Jakub Jelinek (jakub@redhat.com)

On 30/11/15 21:43, Zamyatin, Igor wrote:
>>
>> FAIL: obj-c++.dg/property/dotsyntax-11.mm -fgnu-runtime  (test for errors,
>> line 51)
>> FAIL: obj-c++.dg/property/dotsyntax-11.mm -fgnu-runtime  (test for errors,
>> line 56)
>> FAIL: obj-c++.dg/property/dotsyntax-11.mm -fgnu-runtime  (test for errors,
>> line 59)
>>
>> Andreas.
>
> Here is the patch that properly limits GS_ERROR exit only in case of error in cilk spawn detection.
>

Please add PR objc++/68511 to the ChangeLog entrie.

Thanks,
- Tom

> Bootstrapped and regtested on x86_64, ok for trunk?
>
> Thanks,
> Igor
>
> cp/Changelog
>
> 2015-11-27  Igor Zamyatin  <igor.zamyatin@intel.com>
>
> 	PR c++/68001
> 	* cp-gimplify.c (cp_gimplify_expr): Limit GS_ERROR only in case of
> 	error in cilk spawn detection.
>
>
>
> diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
> index 09ee5ff..3dbbd7f 100644
> --- a/gcc/cp/cp-gimplify.c
> +++ b/gcc/cp/cp-gimplify.c
> @@ -559,6 +559,7 @@ int
>   cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
>   {
>     int saved_stmts_are_full_exprs_p = 0;
> +  bool is_spawn_detected = true;
>     enum tree_code code = TREE_CODE (*expr_p);
>     enum gimplify_status ret;
>
> @@ -614,12 +615,12 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
>   	 25979.  */
>       case INIT_EXPR:
>         if (fn_contains_cilk_spawn_p (cfun)
> -	  && cilk_detect_spawn_and_unwrap (expr_p))
> +	  && (is_spawn_detected = 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 ())
> +      if (!is_spawn_detected && seen_error ())
>   	return GS_ERROR;
>
>         cp_gimplify_init_expr (expr_p);
>
>
>

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

* RE: [PR68001, CilkPlus] Fix for PR68001
  2015-11-30 20:49   ` Zamyatin, Igor
  2015-12-02  7:50     ` Tom de Vries
@ 2015-12-05 10:09     ` Zamyatin, Igor
  1 sibling, 0 replies; 6+ messages in thread
From: Zamyatin, Igor @ 2015-12-05 10:09 UTC (permalink / raw)
  To: 'Andreas Schwab'
  Cc: GCC Patches (gcc-patches@gcc.gnu.org), Jeff Law (law@redhat.com),
	Jakub Jelinek (jakub@redhat.com)

> 
> >
> > FAIL: obj-c++.dg/property/dotsyntax-11.mm -fgnu-runtime  (test for
> > errors, line 51)
> > FAIL: obj-c++.dg/property/dotsyntax-11.mm -fgnu-runtime  (test for
> > errors, line 56)
> > FAIL: obj-c++.dg/property/dotsyntax-11.mm -fgnu-runtime  (test for
> > errors, line 59)
> >
> > Andreas.
> 
> Here is the patch that properly limits GS_ERROR exit only in case of error in
> cilk spawn detection.
>

Resending with PR68511 mentioned in Changelog 

Bootstrapped and regtested on x86_64, ok for trunk?

Thanks,
Igor


 cp/Changelog

2015-12-04  Igor Zamyatin  <igor.zamyatin@intel.com>

	PR objc++/68511
	PR c++/68001
	* cp-gimplify.c (cp_gimplify_expr): Limit GS_ERROR only in case of
	error in cilk spawn detection.

diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 09ee5ff..3dbbd7f 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -559,6 +559,7 @@ int
 cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
 {
   int saved_stmts_are_full_exprs_p = 0;
+  bool is_spawn_detected = true;
   enum tree_code code = TREE_CODE (*expr_p);
   enum gimplify_status ret;
 
@@ -614,12 +615,12 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
 	 25979.  */
     case INIT_EXPR:
       if (fn_contains_cilk_spawn_p (cfun)
-	  && cilk_detect_spawn_and_unwrap (expr_p))
+	  && (is_spawn_detected = 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 ())
+      if (!is_spawn_detected && seen_error ())
 	return GS_ERROR;
 
       cp_gimplify_init_expr (expr_p);

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

end of thread, other threads:[~2015-12-05 10:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-02 20:08 [PR68001, CilkPlus] Fix for PR68001 Zamyatin, Igor
2015-11-02 22:11 ` Jeff Law
2015-11-24 13:53 ` Andreas Schwab
2015-11-30 20:49   ` Zamyatin, Igor
2015-12-02  7:50     ` Tom de Vries
2015-12-05 10:09     ` Zamyatin, Igor

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