Patchwork [4.8,branch] PR rtl-optimization/60700: Backport revision 201326

login
register
mail settings
Submitter H.J. Lu
Date March 28, 2014, 9:59 p.m.
Message ID <20140328215933.GA31437@intel.com>
Download mbox | patch
Permalink /patch/334896/
State New
Headers show

Comments

H.J. Lu - March 28, 2014, 9:59 p.m.
Hi,

Revision 201326 fixes a shrink-wrap bug which is also a regression
on 4.8 branch.  This patch backports it to 4.8 branch.  OK for 4.8
branch.

I also include a testcase for PR rtl-optimization/60700.  OK for
trunk and 4.8 branch?

Thanks.


H.J.
--
gcc/

	PR rtl-optimization/60700
	2013-07-30  Zhenqiang Chen  <zhenqiang.chen@linaro.org>

	PR rtl-optimization/57637
	* function.c (move_insn_for_shrink_wrap): Also check the
	GEN set of the LIVE problem for the liveness analysis
	if it exists, otherwise give up.

gcc/testsuite/

	PR rtl-optimization/60700
	2013-07-30  Zhenqiang Chen  <zhenqiang.chen@linaro.org>

	* gcc.target/arm/pr57637.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@201326 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog                          |  11 ++
 gcc/function.c                         |  49 +++++---
 gcc/testsuite/ChangeLog                |   8 ++
 gcc/testsuite/gcc.target/arm/pr57637.c | 206 +++++++++++++++++++++++++++++++++
 4 files changed, 261 insertions(+), 13 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/arm/pr57637.c
Eric Botcazou - March 29, 2014, 8:38 a.m.
> Revision 201326 fixes a shrink-wrap bug which is also a regression
> on 4.8 branch.  This patch backports it to 4.8 branch.  OK for 4.8
> branch.

Yes, thanks.

> I also include a testcase for PR rtl-optimization/60700.  OK for
> trunk and 4.8 branch?

I'd remove #include <stddef.h>.
Jakub Jelinek - March 29, 2014, 8:47 a.m.
On Sat, Mar 29, 2014 at 09:38:38AM +0100, Eric Botcazou wrote:
> > Revision 201326 fixes a shrink-wrap bug which is also a regression
> > on 4.8 branch.  This patch backports it to 4.8 branch.  OK for 4.8
> > branch.
> 
> Yes, thanks.
> 
> > I also include a testcase for PR rtl-optimization/60700.  OK for
> > trunk and 4.8 branch?
> 
> I'd remove #include <stddef.h>.

You'd then have to use __SIZE_TYPE__ in malloc prototype or just drop
the prototype and use __builtin_malloc.

	Jakub

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 63a6c98..557f922 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@ 
+2014-03-28  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR rtl-optimization/60700
+	Backport from mainline
+	2013-07-30  Zhenqiang Chen  <zhenqiang.chen@linaro.org>
+
+	PR rtl-optimization/57637
+	* function.c (move_insn_for_shrink_wrap): Also check the
+	GEN set of the LIVE problem for the liveness analysis
+	if it exists, otherwise give up.
+
 2014-03-26  Martin Jambor  <mjambor@suse.cz>
 
       PR ipa/60419
diff --git a/gcc/function.c b/gcc/function.c
index e673f21..80720cb 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -5509,22 +5509,45 @@  move_insn_for_shrink_wrap (basic_block bb, rtx insn,
 	 except for any part that overlaps SRC (next loop).  */
       bb_uses = &DF_LR_BB_INFO (bb)->use;
       bb_defs = &DF_LR_BB_INFO (bb)->def;
-      for (i = dregno; i < end_dregno; i++)
+      if (df_live)
 	{
-	  if (REGNO_REG_SET_P (bb_uses, i) || REGNO_REG_SET_P (bb_defs, i))
-	    next_block = NULL;
-	  CLEAR_REGNO_REG_SET (live_out, i);
-	  CLEAR_REGNO_REG_SET (live_in, i);
-	}
+	  for (i = dregno; i < end_dregno; i++)
+	    {
+	      if (REGNO_REG_SET_P (bb_uses, i) || REGNO_REG_SET_P (bb_defs, i)
+		  || REGNO_REG_SET_P (&DF_LIVE_BB_INFO (bb)->gen, i))
+		next_block = NULL;
+	      CLEAR_REGNO_REG_SET (live_out, i);
+	      CLEAR_REGNO_REG_SET (live_in, i);
+	    }
 
-      /* Check whether BB clobbers SRC.  We need to add INSN to BB if so.
-	 Either way, SRC is now live on entry.  */
-      for (i = sregno; i < end_sregno; i++)
+	  /* Check whether BB clobbers SRC.  We need to add INSN to BB if so.
+	     Either way, SRC is now live on entry.  */
+	  for (i = sregno; i < end_sregno; i++)
+	    {
+	      if (REGNO_REG_SET_P (bb_defs, i)
+		  || REGNO_REG_SET_P (&DF_LIVE_BB_INFO (bb)->gen, i))
+		next_block = NULL;
+	      SET_REGNO_REG_SET (live_out, i);
+	      SET_REGNO_REG_SET (live_in, i);
+	    }
+	}
+      else
 	{
-	  if (REGNO_REG_SET_P (bb_defs, i))
-	    next_block = NULL;
-	  SET_REGNO_REG_SET (live_out, i);
-	  SET_REGNO_REG_SET (live_in, i);
+	  /* DF_LR_BB_INFO (bb)->def does not comprise the DF_REF_PARTIAL and
+	     DF_REF_CONDITIONAL defs.  So if DF_LIVE doesn't exist, i.e.
+	     at -O1, just give up searching NEXT_BLOCK.  */
+	  next_block = NULL;
+	  for (i = dregno; i < end_dregno; i++)
+	    {
+	      CLEAR_REGNO_REG_SET (live_out, i);
+	      CLEAR_REGNO_REG_SET (live_in, i);
+	    }
+
+	  for (i = sregno; i < end_sregno; i++)
+	    {
+	      SET_REGNO_REG_SET (live_out, i);
+	      SET_REGNO_REG_SET (live_in, i);
+	    }
 	}
 
       /* If we don't need to add the move to BB, look for a single
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f425228..50a33ee 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@ 
+2014-03-28  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR rtl-optimization/60700
+	Backport from mainline
+	2013-07-30  Zhenqiang Chen  <zhenqiang.chen@linaro.org>
+
+	* gcc.target/arm/pr57637.c: New testcase.
+
 2014-04-28  Thomas Koenig  <tkoenig@gcc.gnu.org>
 
 	PR fortran/60522
diff --git a/gcc/testsuite/gcc.target/arm/pr57637.c b/gcc/testsuite/gcc.target/arm/pr57637.c
new file mode 100644
index 0000000..2b9bfdd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/pr57637.c
@@ -0,0 +1,206 @@ 
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline" } */
+
+typedef struct _GtkCssStyleProperty GtkCssStyleProperty;
+
+struct _GtkCssStyleProperty
+{
+  int *initial_value;
+  unsigned int id;
+  unsigned int inherit :1;
+  unsigned int animated :1;
+  unsigned int affects_size :1;
+  unsigned int affects_font :1;
+
+  int * parse_value;
+  int * query_value;
+  int * assign_value;
+};
+
+void
+g_assertion_message_expr (const char *domain,
+			  const char *file,
+			  int line,
+			  const char *func,
+			  const char *expr) __attribute__((__noreturn__));
+
+void
+g_assertion_message_expr (const char *domain,
+			  const char *file,
+			  int line,
+			  const char *func,
+			  const char *expr)
+{
+  __builtin_abort ();
+}
+int
+get_id (GtkCssStyleProperty *property)
+{
+  return 1;
+}
+int
+_gtk_css_style_property_get_type ()
+{
+  return 1;
+}
+
+GtkCssStyleProperty *
+g_object_new (int object_type,
+            const char *first_property_name,
+            ...)
+{
+  return (GtkCssStyleProperty *) __builtin_malloc (sizeof (GtkCssStyleProperty));
+}
+
+typedef enum {
+  INHERIT = (1 << 0),
+  ANIMATED = (1 << 1),
+  RESIZE = (1 << 2),
+  FONT = (1 << 3)
+} GtkStylePropertyFlags;
+
+int t = 0;
+void
+gtk_css_style_property_register (const char * name,
+				 int expected_id,
+				 int value_type,
+				 int flags,
+				 int *parse_value,
+				 int *query_value,
+				 int *assign_value,
+				 int *initial_value)
+{
+  GtkCssStyleProperty *node;
+
+  do
+    {
+      if (__builtin_expect (__extension__ (
+					   {
+					     int _g_boolean_var_;
+					     if (initial_value != ((void *)0))
+					       _g_boolean_var_ = 1;
+					     else
+					       _g_boolean_var_ = 0;
+					     _g_boolean_var_;
+					   }),
+			    1))
+	;
+      else
+        g_assertion_message_expr ("Gtk",
+				  "gtkcssstylepropertyimpl.c",
+				  85,
+				  ((const char*) (__PRETTY_FUNCTION__)),
+				  "initial_value != NULL");
+    } while (0);
+
+  do
+    {
+      if (__builtin_expect (__extension__ (
+					   {
+					     int _g_boolean_var_;
+					     if (parse_value != ((void *)0))
+					       _g_boolean_var_ = 1;
+					     else
+					       _g_boolean_var_ = 0;
+					     _g_boolean_var_;
+					   }),
+			    1))
+	;
+      else
+	g_assertion_message_expr ("Gtk",
+				  "gtkcssstylepropertyimpl.c",
+				  86,
+				  ((const char*) (__PRETTY_FUNCTION__)),
+				  "parse_value != NULL");
+    } while (0);
+
+  do
+    {
+      if (__builtin_expect (__extension__ (
+					   {
+					     int _g_boolean_var_;
+					     if (value_type == ((int) ((1) << (2)))
+						 || query_value != ((void *)0))
+					       _g_boolean_var_ = 1;
+					     else
+					       _g_boolean_var_ = 0;
+					     _g_boolean_var_;
+					   }),
+			    1))
+	;
+      else
+	g_assertion_message_expr ("Gtk",
+				  "gtkcssstylepropertyimpl.c",
+				  87, ((const char*) (__PRETTY_FUNCTION__)),
+				  "value_type == NONE || query_value != NULL");
+    } while (0);
+
+  /* FLAGS is changed in a cond_exec instruction with pr57637.  */
+  if (flags  == 15)
+    t = 15;
+
+  do
+    {
+      if (__builtin_expect (__extension__ (
+					   {
+					     int _g_boolean_var_;
+					     if (value_type == ((1) << (2))
+						 || assign_value != ((void *)0))
+					       _g_boolean_var_ = 1;
+					     else
+					       _g_boolean_var_ = 0;
+					     _g_boolean_var_;
+					   }),
+			    1))
+	;
+      else
+	g_assertion_message_expr ("Gtk",
+				  "gtkcssstylepropertyimpl.c",
+				  88, ((const char*) (__PRETTY_FUNCTION__)),
+				  "value_type == NONE || assign_value != NULL");
+    } while (0);
+
+  node = g_object_new ((_gtk_css_style_property_get_type ()),
+			"value-type", value_type,
+			"affects-size", (flags & RESIZE) ? (0) : (!(0)),
+			"affects-font", (flags & FONT) ? (!(0)) : (0),
+			"animated", (flags & ANIMATED) ? (!(0)) : (0),
+			"inherit", (flags & INHERIT) ? (!(0)) : (0),
+			"initial-value", initial_value,
+			"name", name,
+			((void *)0));
+
+  node->parse_value = parse_value;
+  node->query_value = query_value;
+  node->assign_value = assign_value;
+
+  do
+    {
+      if (__builtin_expect (__extension__ (
+					   {
+					     int _g_boolean_var_;
+					     if (get_id (node) == expected_id)
+					       _g_boolean_var_ = 1;
+					     else
+					       _g_boolean_var_ = 0;
+					     _g_boolean_var_;
+					   }),
+			    1))
+	;
+      else
+	g_assertion_message_expr ("Gtk",
+				  "gtkcssstylepropertyimpl.c",
+				  106,
+				  ((const char*) (__PRETTY_FUNCTION__)),
+				  "get_id (node) == expected_id");
+    } while (0);
+}
+
+int main ()
+{
+  gtk_css_style_property_register ("test", 1, 4, 15, &t, &t, &t, &t);
+
+  if (t != 15)
+    __builtin_abort ();
+  return 0;
+}
-- 
1.8.3.1

2014-03-28  H.J. Lu  <hongjiu.lu@intel.com>

	PR rtl-optimization/60700
	* gcc.target/i386/pr60700a.c: New test.
	* gcc.target/i386/pr60700b.c: Likewise.

diff --git a/gcc/testsuite/gcc.target/i386/pr60700a.c b/gcc/testsuite/gcc.target/i386/pr60700a.c
new file mode 100644
index 0000000..1072a33
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr60700a.c
@@ -0,0 +1,43 @@ 
+/* PR rtl-optimization/60700 */
+/* { dg-do run { target ia32 } } */
+/* { dg-options "-O3 -march=i686" } */
+/* { dg-additional-sources pr60700b.c } */
+
+#include <stddef.h>
+
+extern void *malloc (size_t);
+
+extern int foo(void);
+void *g = (void *)1;
+
+struct st {
+  char data[36]; /* must be greater than 32.  */
+};
+
+int
+repro(struct st **out)
+{
+  int status = 0;
+
+  *out = NULL;
+
+  status = foo();
+  if (status != 0) {
+    return status;
+  }
+
+  if (NULL == g) {
+    status = 999;
+    return status;
+  }
+
+  *out = (struct st *)malloc(sizeof(struct st));
+  if (NULL == (*out)) {
+    status = 42;
+    return status;
+  }
+
+  __builtin_memset(*out, 0, sizeof(struct st));
+
+  return status;
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr60700b.c b/gcc/testsuite/gcc.target/i386/pr60700b.c
new file mode 100644
index 0000000..7414cce
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr60700b.c
@@ -0,0 +1,27 @@ 
+/* { dg-do compile } */
+
+int
+foo (void)
+{
+  return 0;
+}
+
+struct st {
+  char data[36]; /* must be greater than 32.  */
+};
+
+extern int repro(struct st **out);
+
+int
+main ()
+{
+  struct st *p;
+  int ret = repro (&p);
+  unsigned int i;
+
+  for (i = 0; i < sizeof (p->data)/sizeof (p->data[0]); i++)
+    if (p->data[i] != 0)
+      __builtin_abort ();
+
+  return ret;
+}