Patchwork Backported patches to 4.4

login
register
mail settings
Submitter Jakub Jelinek
Date Nov. 12, 2010, 11:31 a.m.
Message ID <20101112113151.GP29412@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/70955/
State New
Headers show

Comments

Jakub Jelinek - Nov. 12, 2010, 11:31 a.m.
Hi!

I've backported these 2 patches to 4.4 branch after bootstrap/regtest on
x86_64-linux and i686-linux.

	Jakub
2010-11-12  Jakub Jelinek  <jakub@redhat.com>

	Backport from mainline
	2010-11-03  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/46107
	* cfgloopmanip.c (loop_version): Set irred_flag back into entry->flags
	if cfg_hook_duplicate_loop_to_header_edge failed.

	* gcc.c-torture/compile/pr46107.c: New test.
2010-11-12  Jakub Jelinek  <jakub@redhat.com>

	Backport from mainline
	2010-11-05  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/43690
	* gimplify.c (gimplify_asm_expr): If a "m" input is a
	{pre,post}{in,de}crement, fail.

	* c-c++-common/pr43690.c: New test.

--- gcc/gimplify.c	(revision 166353)
+++ gcc/gimplify.c	(revision 166354)
@@ -5066,6 +5066,13 @@ gimplify_asm_expr (tree *expr_p, gimple_
       /* If the operand is a memory input, it should be an lvalue.  */
       if (!allows_reg && allows_mem)
 	{
+	  tree inputv = TREE_VALUE (link);
+	  STRIP_NOPS (inputv);
+	  if (TREE_CODE (inputv) == PREDECREMENT_EXPR
+	      || TREE_CODE (inputv) == PREINCREMENT_EXPR
+	      || TREE_CODE (inputv) == POSTDECREMENT_EXPR
+	      || TREE_CODE (inputv) == POSTINCREMENT_EXPR)
+	    TREE_VALUE (link) = error_mark_node;
 	  tret = gimplify_expr (&TREE_VALUE (link), pre_p, post_p,
 				is_gimple_lvalue, fb_lvalue | fb_mayfail);
 	  mark_addressable (TREE_VALUE (link));
--- gcc/testsuite/c-c++-common/pr43690.c	(revision 0)
+++ gcc/testsuite/c-c++-common/pr43690.c	(revision 166354)
@@ -0,0 +1,13 @@
+/* PR middle-end/43690 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void
+foo (char *x)
+{
+  asm ("" : : "m" (x++));	/* { dg-error "is not directly addressable" } */
+  asm ("" : : "m" (++x));	/* { dg-error "is not directly addressable" } */
+  asm ("" : : "m" (x--));	/* { dg-error "is not directly addressable" } */
+  asm ("" : : "m" (--x));	/* { dg-error "is not directly addressable" } */
+  asm ("" : : "m" (x + 1));	/* { dg-error "is not directly addressable" } */
+}

Patch

--- gcc/cfgloopmanip.c	(revision 166233)
+++ gcc/cfgloopmanip.c	(revision 166234)
@@ -1538,7 +1538,10 @@  loop_version (struct loop *loop,
   /* Duplicate loop.  */
   if (!cfg_hook_duplicate_loop_to_header_edge (loop, entry, 1,
 					       NULL, NULL, NULL, 0))
-    return NULL;
+    {
+      entry->flags |= irred_flag;
+      return NULL;
+    }
 
   /* After duplication entry edge now points to new loop head block.
      Note down new head as second_head.  */
--- gcc/testsuite/gcc.c-torture/compile/pr46107.c	(revision 0)
+++ gcc/testsuite/gcc.c-torture/compile/pr46107.c	(revision 166234)
@@ -0,0 +1,16 @@ 
+/* PR tree-optimization/46107 */
+
+int foo (void) __attribute__ ((noreturn));
+
+void
+bar (int x, int *y, int z)
+{
+  static void *j[] = { &&l1, &&l2 };
+l1:
+  if (*y)
+    goto *j[z];
+  foo ();
+l2:
+  *y ^= (x & 1) ? -1 : 0;
+  goto *j[x];
+}