diff mbox

Fix pr70061

Message ID 56DB3B3A.2050902@redhat.com
State New
Headers show

Commit Message

Richard Henderson March 5, 2016, 8:02 p.m. UTC
The problem is that we are emitting copy sequences to edges without caring
for deferred popping of arguments.  Thus when we began emitting code for the
first block, which in this case starts with a label, we had 32 bytes of
pending stack adjustment, which emit_label flushed.  The ICE is due to the
label not being the first insn in the BB.

There are two equivalent ways to fix this: we can either save/restore
inhibit_defer_pop around these sequences, or we can manually flush any
pending stack adjustment.

This does the latter.  Ok?


r~
* tree-outofssa.c (emit_partition_copy): Flush pending stack adjust.
	(insert_value_copy_on_edge): Likewise.

	* gcc.c-torture/compile/pr70061.c: New test.

Comments

Jeff Law March 7, 2016, 7:51 a.m. UTC | #1
On 03/05/2016 01:02 PM, Richard Henderson wrote:
> The problem is that we are emitting copy sequences to edges without caring
> for deferred popping of arguments.  Thus when we began emitting code for
> the
> first block, which in this case starts with a label, we had 32 bytes of
> pending stack adjustment, which emit_label flushed.  The ICE is due to the
> label not being the first insn in the BB.
>
> There are two equivalent ways to fix this: we can either save/restore
> inhibit_defer_pop around these sequences, or we can manually flush any
> pending stack adjustment.
>
> This does the latter.  Ok?
>
>
> r~
>
> z
>
>
> 	* tree-outofssa.c (emit_partition_copy): Flush pending stack adjust.
> 	(insert_value_copy_on_edge): Likewise.
>
> 	* gcc.c-torture/compile/pr70061.c: New test.
I was a bit confused trying to figure out how we got a pending stack 
adjust when we were still in the out-of-ssa pass.  But out-of-ssa can 
call emit_block_copy which can, of course, emit a memcpy.

Similarly, I suspect store_expr can do the same for the 
insert_value_copy_on_edge case.

Ok for the trunk.  Thanks for tracking this down.

jeff
diff mbox

Patch

diff --git a/gcc/testsuite/gcc.c-torture/compile/pr70061.c b/gcc/testsuite/gcc.c-torture/compile/pr70061.c
new file mode 100644
index 0000000..a7ebcfc
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr70061.c
@@ -0,0 +1,10 @@ 
+typedef int v8si __attribute__ ((vector_size (32)));
+
+int
+foo(v8si c, v8si d)
+{
+l0:
+  if (c[2])
+    d ^= c;
+  return d[3];
+}
diff --git a/gcc/tree-outof-ssa.c b/gcc/tree-outof-ssa.c
index 25286a2..4125529 100644
--- a/gcc/tree-outof-ssa.c
+++ b/gcc/tree-outof-ssa.c
@@ -41,6 +41,7 @@  along with GCC; see the file COPYING3.  If not see
 #include "tree-ssa-ter.h"
 #include "tree-ssa-coalesce.h"
 #include "tree-outof-ssa.h"
+#include "dojump.h"
 
 /* FIXME: A lot of code here deals with expanding to RTL.  All that code
    should be in cfgexpand.c.  */
@@ -220,6 +221,7 @@  emit_partition_copy (rtx dest, rtx src, int unsignedsrcp, tree sizeexp)
     }
   else
     emit_move_insn (dest, src);
+  do_pending_stack_adjust ();
 
   rtx_insn *seq = get_insns ();
   end_sequence ();
@@ -312,6 +314,8 @@  insert_value_copy_on_edge (edge e, int dest, tree src, source_location locus)
 
   if (x != dest_rtx)
     emit_move_insn (dest_rtx, x);
+  do_pending_stack_adjust ();
+
   seq = get_insns ();
   end_sequence ();