Recog/asm_operands problem with MIPS/gcc3.3

Daniel Jacobowitz drow@mvista.com
Wed Jan 7 21:26:00 GMT 2004


On Wed, Jan 07, 2004 at 01:03:53PM -0800, Richard Henderson wrote:
> On Tue, Jan 06, 2004 at 06:36:10PM -0500, Daniel Jacobowitz wrote:
> > But recog only validates that the inputs match.  Then we call
> > check_asm_operands, which eventually calls constrain_operands because
> > reload_completed is set.  constrain_operands sees the 'm' in the "=m"
> > constraint, sees that this is indeed a mem, and allows it through.
> 
> This is the bug.  If strict > 0, then we should validate the address.
> You'll see that this does happen for other constraints such as 'o'.

I see.  Something like this?  Not regtested yet, but it fixes the
testcase.  Patch against 3.3 but applies to HEAD also.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2003-01-07  Daniel Jacobowitz  <drow@mvista.com>

	* recog.c (constrain_operands): Reject invalid mem operands after
	reload.

Index: recog.c
===================================================================
RCS file: /big/fsf/rsync/gcc-cvs/gcc/gcc/recog.c,v
retrieving revision 1.168.2.3
diff -u -p -r1.168.2.3 recog.c
--- recog.c	2 Dec 2003 04:36:04 -0000	1.168.2.3
+++ recog.c	7 Jan 2004 21:21:48 -0000
@@ -2515,6 +2515,13 @@ constrain_operands (strict)
 		break;
 
 	      case 'm':
+		/* After reload, reject invalid memory addresses.  */
+		if (strict > 0
+		    && (GET_CODE (op) != MEM
+			|| !strict_memory_address_p (recog_data.operand_mode[opno],
+						     XEXP (op, 0))))
+		  break;
+
 		if (GET_CODE (op) == MEM
 		    /* Before reload, accept what reload can turn into mem.  */
 		    || (strict < 0 && CONSTANT_P (op))



More information about the Gcc-patches mailing list