public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [P1] [PATCH] [PR tree-optimization/80374] Do not try to convert integer_zero_node to undesirable types
@ 2017-04-10 19:20 Jeff Law
  2017-04-11  6:36 ` Markus Trippelsdorf
  2017-04-11  7:34 ` Richard Biener
  0 siblings, 2 replies; 3+ messages in thread
From: Jeff Law @ 2017-04-10 19:20 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 366 bytes --]


fold_convert can fail for certain types.  It can fail either by 
returning a error_mark_node or triggering a gcc_assert depending on the 
exact situation.

Both are problematical.  This patch checks that we can convert 
integer_zero_node to the proper type before calling fold_convert.

Bootstrapped and regression tested on x86_64.  Installing on the trunk.

Jeff

[-- Attachment #2: P --]
[-- Type: text/plain, Size: 1729 bytes --]

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6edad21..7db5359 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2017-04-10  Jeff Law  <law@redhat.com>
+
+	PR tree-optimization/80374
+	* tree-ssa-dom.c (derive_equivalences_from_bit_ior): Do not try to
+	record anything if we can not convert integer_zero_node to the
+	desired type.
+
 2017-04-10  Bin Cheng  <bin.cheng@arm.com>
 
 	PR tree-optimization/80153
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b87d0ee..6ed3c99 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-10  Jeff Law  <law@redhat.com>
+
+	PR tree-optimization/80374
+	* g++.dg/pr80374.c: New test.
+
 2017-04-10  Daniel Santos <daniel.santos@pobox.com>
 
 	PR testsuite/79867
diff --git a/gcc/testsuite/g++.dg/pr80374.C b/gcc/testsuite/g++.dg/pr80374.C
new file mode 100644
index 0000000..b02b656
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr80374.C
@@ -0,0 +1,19 @@
+void a (const char *, const char *, int, const char *)
+  __attribute__ ((__noreturn__));
+template <typename b, int>
+void
+c () try
+  {
+    throw;
+  }
+catch (b d)
+  {
+    if (d)
+      a ("", "", 2, __PRETTY_FUNCTION__);
+  }
+main ()
+{
+  using e = decltype (nullptr);
+  c<volatile e, true> ();
+}
+
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index d2263bb..d9e5942 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -701,7 +701,8 @@ derive_equivalences_from_bit_ior (tree name,
 				  const_and_copies *const_and_copies,
 				  int recursion_limit)
 {
-  if (recursion_limit == 0)
+  if (recursion_limit == 0
+      || !fold_convertible_p (TREE_TYPE (name), integer_zero_node))
     return;
 
   if (TREE_CODE (name) == SSA_NAME)

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

* Re: [P1] [PATCH] [PR tree-optimization/80374] Do not try to convert integer_zero_node to undesirable types
  2017-04-10 19:20 [P1] [PATCH] [PR tree-optimization/80374] Do not try to convert integer_zero_node to undesirable types Jeff Law
@ 2017-04-11  6:36 ` Markus Trippelsdorf
  2017-04-11  7:34 ` Richard Biener
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Trippelsdorf @ 2017-04-11  6:36 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

On 2017.04.10 at 13:20 -0600, Jeff Law wrote:
> 
> fold_convert can fail for certain types.  It can fail either by returning a
> error_mark_node or triggering a gcc_assert depending on the exact situation.
> 
> Both are problematical.  This patch checks that we can convert
> integer_zero_node to the proper type before calling fold_convert.
> 
> Bootstrapped and regression tested on x86_64.  Installing on the trunk.

I've fixed up the testcase:

FAIL: g++.dg/pr80374.C  -std=c++11 (test for excess errors)
FAIL: g++.dg/pr80374.C  -std=c++14 (test for excess errors)
FAIL: g++.dg/pr80374.C  -std=c++98 (test for excess errors)

Committed as obvious.

diff --git a/gcc/testsuite/g++.dg/pr80374.C b/gcc/testsuite/g++.dg/pr80374.C
index b02b65629aef..83f778be638a 100644
--- a/gcc/testsuite/g++.dg/pr80374.C
+++ b/gcc/testsuite/g++.dg/pr80374.C
@@ -1,3 +1,5 @@
+// { dg-do compile }
+// { dg-options "-O1 -std=c++11" }
 void a (const char *, const char *, int, const char *)
   __attribute__ ((__noreturn__));
 template <typename b, int>
@@ -11,7 +13,8 @@ catch (b d)
     if (d)
       a ("", "", 2, __PRETTY_FUNCTION__);
   }
-main ()
+void
+foo ()
 {
   using e = decltype (nullptr);
   c<volatile e, true> ();
-- 
Markus

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

* Re: [P1] [PATCH] [PR tree-optimization/80374] Do not try to convert integer_zero_node to undesirable types
  2017-04-10 19:20 [P1] [PATCH] [PR tree-optimization/80374] Do not try to convert integer_zero_node to undesirable types Jeff Law
  2017-04-11  6:36 ` Markus Trippelsdorf
@ 2017-04-11  7:34 ` Richard Biener
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Biener @ 2017-04-11  7:34 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches

On Mon, Apr 10, 2017 at 9:20 PM, Jeff Law <law@redhat.com> wrote:
>
> fold_convert can fail for certain types.  It can fail either by returning a
> error_mark_node or triggering a gcc_assert depending on the exact situation.
>
> Both are problematical.  This patch checks that we can convert
> integer_zero_node to the proper type before calling fold_convert.
>
> Bootstrapped and regression tested on x86_64.  Installing on the trunk.

I am testing the proper fix below (NULLPTR_TYPE is somewhat special...)

Richard.

Index: gcc/tree-ssa-dom.c
===================================================================
--- gcc/tree-ssa-dom.c  (revision 246832)
+++ gcc/tree-ssa-dom.c  (working copy)
@@ -701,13 +701,12 @@ derive_equivalences_from_bit_ior (tree n
                                  const_and_copies *const_and_copies,
                                  int recursion_limit)
 {
-  if (recursion_limit == 0
-      || !fold_convertible_p (TREE_TYPE (name), integer_zero_node))
+  if (recursion_limit == 0)
     return;

   if (TREE_CODE (name) == SSA_NAME)
     {
-      tree value = fold_convert (TREE_TYPE (name), integer_zero_node);
+      tree value = build_zero_cst (TREE_TYPE (name));

       /* This records the equivalence for the toplevel object.  */
       record_equality (name, value, const_and_copies);


> Jeff
>
> diff --git a/gcc/ChangeLog b/gcc/ChangeLog
> index 6edad21..7db5359 100644
> --- a/gcc/ChangeLog
> +++ b/gcc/ChangeLog
> @@ -1,3 +1,10 @@
> +2017-04-10  Jeff Law  <law@redhat.com>
> +
> +       PR tree-optimization/80374
> +       * tree-ssa-dom.c (derive_equivalences_from_bit_ior): Do not try to
> +       record anything if we can not convert integer_zero_node to the
> +       desired type.
> +
>  2017-04-10  Bin Cheng  <bin.cheng@arm.com>
>
>         PR tree-optimization/80153
> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
> index b87d0ee..6ed3c99 100644
> --- a/gcc/testsuite/ChangeLog
> +++ b/gcc/testsuite/ChangeLog
> @@ -1,3 +1,8 @@
> +2017-04-10  Jeff Law  <law@redhat.com>
> +
> +       PR tree-optimization/80374
> +       * g++.dg/pr80374.c: New test.
> +
>  2017-04-10  Daniel Santos <daniel.santos@pobox.com>
>
>         PR testsuite/79867
> diff --git a/gcc/testsuite/g++.dg/pr80374.C b/gcc/testsuite/g++.dg/pr80374.C
> new file mode 100644
> index 0000000..b02b656
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/pr80374.C
> @@ -0,0 +1,19 @@
> +void a (const char *, const char *, int, const char *)
> +  __attribute__ ((__noreturn__));
> +template <typename b, int>
> +void
> +c () try
> +  {
> +    throw;
> +  }
> +catch (b d)
> +  {
> +    if (d)
> +      a ("", "", 2, __PRETTY_FUNCTION__);
> +  }
> +main ()
> +{
> +  using e = decltype (nullptr);
> +  c<volatile e, true> ();
> +}
> +
> diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
> index d2263bb..d9e5942 100644
> --- a/gcc/tree-ssa-dom.c
> +++ b/gcc/tree-ssa-dom.c
> @@ -701,7 +701,8 @@ derive_equivalences_from_bit_ior (tree name,
>                                   const_and_copies *const_and_copies,
>                                   int recursion_limit)
>  {
> -  if (recursion_limit == 0)
> +  if (recursion_limit == 0
> +      || !fold_convertible_p (TREE_TYPE (name), integer_zero_node))
>      return;
>
>    if (TREE_CODE (name) == SSA_NAME)
>

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

end of thread, other threads:[~2017-04-11  7:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-10 19:20 [P1] [PATCH] [PR tree-optimization/80374] Do not try to convert integer_zero_node to undesirable types Jeff Law
2017-04-11  6:36 ` Markus Trippelsdorf
2017-04-11  7:34 ` Richard Biener

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