This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Re: [testsuite] i386 sibcall miscompilation


On Tue, Jul 29, 2036 at 03:28:43PM -0400, Richard Kenner wrote:
>     Some more related information: this worked just fine before Kenner's alias
>     changes, because outgoing arguments were stored into the stack usign alias
>     set 0, which is now no longer true. Maybe they should go to alias set 0
>     again if emiting sibling call arguments...
> 
> Or they should go into the stack in their own alias set.

Maybe I miss something in here, but wouldn't putting them into their own
alias set mean it will not work even more often.
The sibcall argument problem is that the outgoing arguments must be treated
as if they can alias with anything else on the stack.
Patch below fixes the testcase for me by reverting alias set behaviour
change of compute_argument_addresses and emit_push_insn.
I don't think it will make gcc emit worse code, but it could be done for
sibcall arguments only if we propagated that information down to
compute_argument_addresses (its caller knows it, so I could just add
argument, in emit_push_insn it would be two additions) or by checking if the
MEM address is based on virtual_incoming_args_rtx and clear MEM_ALIAS_SET in
that case.
Ideas?

2000-06-22  Jakub Jelinek  <jakub@redhat.com>

	* calls.c (compute_argument_addresses): Force stack slots into
	alias set 0.
	* expr.c (emit_push_insn): Force pushes into alias set 0.

--- gcc/calls.c.jj	Mon Jun 12 09:55:36 2000
+++ gcc/calls.c	Thu Jun 22 15:06:31 2000
@@ -1585,6 +1585,7 @@ compute_argument_addresses (args, argblo
 	  args[i].stack = gen_rtx_MEM (args[i].mode, addr);
 	  set_mem_attributes (args[i].stack,
 			      TREE_TYPE (args[i].tree_value), 1);
+	  MEM_ALIAS_SET (args[i].stack) = 0;
 
 	  if (GET_CODE (slot_offset) == CONST_INT)
 	    addr = plus_constant (arg_reg, INTVAL (slot_offset));
@@ -1595,6 +1596,7 @@ compute_argument_addresses (args, argblo
 	  args[i].stack_slot = gen_rtx_MEM (args[i].mode, addr);
 	  set_mem_attributes (args[i].stack_slot,
 			      TREE_TYPE (args[i].tree_value), 1);
+	  MEM_ALIAS_SET (args[i].stack_slot) = 0;
 	}
     }
 }
--- gcc/expr.c.jj	Wed Jun  7 08:41:05 2000
+++ gcc/expr.c	Thu Jun 22 15:34:46 2000
@@ -3111,7 +3111,10 @@ emit_push_insn (x, mode, type, size, ali
 	      rtx target = gen_rtx_MEM (BLKmode, temp);
 
 	      if (type != 0)
-		set_mem_attributes (target, type, 1);
+		{
+		  set_mem_attributes (target, type, 1);
+		  MEM_ALIAS_SET (target) = 0;
+		}
 
 	      move_by_pieces (gen_rtx_MEM (BLKmode, temp), xinner,
 			      INTVAL (size), align);
@@ -3124,7 +3127,10 @@ emit_push_insn (x, mode, type, size, ali
 	      rtx target = gen_rtx_MEM (BLKmode, temp);
 
 	      if (type != 0)
-		set_mem_attributes (target, type, 1);
+		{
+		  set_mem_attributes (target, type, 1);
+		  MEM_ALIAS_SET (target) = 0;
+		}
 
 	      for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT);
 		   mode != VOIDmode;
@@ -3293,7 +3299,10 @@ emit_push_insn (x, mode, type, size, ali
 
       dest = gen_rtx_MEM (mode, addr);
       if (type != 0)
-	set_mem_attributes (dest, type, 1);
+	{
+	  set_mem_attributes (dest, type, 1);
+	  MEM_ALIAS_SET (dest) = 0;
+	}
 
       emit_move_insn (dest, x);
 

	Jakub

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]