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]

Fix for c/2728


Some asm statements in the Linux kernel get an "inconsistent constraints"
error from reload.  The problem is that these asms are using in/out
operands, which are handled by translating them into an output and an
input with a matching constraint.  The code in expand_asm_operands
carefully allocates a new constraint string, copies the old one into it,
changes the '+' into a '=', and then discards the new string and puts the
old one into the rtl.  Oops.

Bootstrapped on i686-linux (a useless test in this case).  I also
compiled a linux kernel (but didn't boot it).  I'm installing this
in the mainline and on the 3.0 branch, and if 2.95 supports '+'
constraints it'll go into that branch as well.


Bernd

	* stmt.c (expand_asm_operands): For inout operands, make sure
	the substitution of '=' for '+' makes it into the rtl.

Index: stmt.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/stmt.c,v
retrieving revision 1.195
diff -u -p -r1.195 stmt.c
--- stmt.c	2001/05/02 14:31:45	1.195
+++ stmt.c	2001/05/16 15:18:23
@@ -1328,6 +1328,8 @@ expand_asm_operands (string, outputs, in
   rtx *real_output_rtx = (rtx *) alloca (noutputs * sizeof (rtx));
   enum machine_mode *inout_mode
     = (enum machine_mode *) alloca (noutputs * sizeof (enum machine_mode));
+  const char **output_constraints
+    = alloca (noutputs * sizeof (const char *));
   /* The insn we have emitted.  */
   rtx insn;
   int old_generating_concat_p = generating_concat_p;
@@ -1426,6 +1428,7 @@ expand_asm_operands (string, outputs, in
 	 message.  */

       constraint = TREE_STRING_POINTER (TREE_PURPOSE (tail));
+      output_constraints[i] = constraint;
       c_len = strlen (constraint);

       /* Allow the `=' or `+' to not be at the beginning of the string,
@@ -1455,6 +1458,7 @@ expand_asm_operands (string, outputs, in
 	    memcpy (buf + 1, constraint, j);
 	  memcpy (buf + 1 + j, p + 1, c_len - j);  /* not -j-1 - copy null */
 	  constraint = ggc_alloc_string (buf, c_len);
+	  output_constraints[i] = constraint;

 	  if (j)
 	    warning (
@@ -1823,7 +1827,7 @@ expand_asm_operands (string, outputs, in
   if (noutputs == 1 && nclobbers == 0)
     {
       ASM_OPERANDS_OUTPUT_CONSTRAINT (body)
-	= TREE_STRING_POINTER (TREE_PURPOSE (outputs));
+	= output_constraints[0];
       insn = emit_insn (gen_rtx_SET (VOIDmode, output_rtx[0], body));
     }

@@ -1852,7 +1856,7 @@ expand_asm_operands (string, outputs, in
 			   gen_rtx_ASM_OPERANDS
 			   (GET_MODE (output_rtx[i]),
 			    TREE_STRING_POINTER (string),
-			    TREE_STRING_POINTER (TREE_PURPOSE (tail)),
+			    output_constraints[i],
 			    i, argvec, constraints,
 			    filename, line));



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