Function to reliably copy insns (repost)

Bernd Schmidt bernds@cygnus.co.uk
Sun Oct 10 05:58:00 GMT 1999


> 
> Hmm, this seems to cause a build fail on powerpc-linux-gnu with 
> --enable-checking:
> 
[...]
> 
> I didn't see this one before, though I believe your patch just reveals the 
> real bug.

No, it's probably caused by the patch; there is some divergence between
copy_rtx and copy_insn_1.  Could you try the patch below (which gets rid
almost entirely of the use of accessor macros in these functions)?

Bernd
         
	* rtl.c (copy_rtx): Don't use accessor macros to copy fields.
	* emit-rtl.c (copy_insn_1): Likewise.

Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/emit-rtl.c,v
retrieving revision 1.92
diff -u -p -r1.92 emit-rtl.c
--- emit-rtl.c	1999/10/10 12:06:33	1.92
+++ emit-rtl.c	1999/10/10 12:33:28
@@ -3473,22 +3473,16 @@ copy_insn_1 (orig)
 
   for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
     {
+      copy->fld[i] = orig->fld[i];
       switch (*format_ptr++)
 	{
 	case 'e':
-	  XEXP (copy, i) = XEXP (orig, i);
 	  if (XEXP (orig, i) != NULL)
 	    XEXP (copy, i) = copy_insn_1 (XEXP (orig, i));
 	  break;
 
-	case '0':
-	case 'u':
-	  XEXP (copy, i) = XEXP (orig, i);
-	  break;
-
 	case 'E':
 	case 'V':
-	  XVEC (copy, i) = XVEC (orig, i);
 	  if (XVEC (orig, i) == orig_asm_constraints_vector)
 	    XVEC (copy, i) = copy_asm_constraints_vector;
 	  else if (XVEC (orig, i) == orig_asm_operands_vector)
@@ -3510,20 +3504,13 @@ copy_insn_1 (orig)
 	  }
 
 	case 't':
-	  XTREE (copy, i) = XTREE (orig, i);
-	  break;
-
 	case 'w':
-	  XWINT (copy, i) = XWINT (orig, i);
-	  break;
-
 	case 'i':
-	  XINT (copy, i) = XINT (orig, i);
-	  break;
-
 	case 's':
 	case 'S':
-	  XSTR (copy, i) = XSTR (orig, i);
+	case 'u':
+	case '0':
+	  /* These are left unchanged.  */
 	  break;
 
 	default:
Index: rtl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtl.c,v
retrieving revision 1.45
diff -u -p -r1.45 rtl.c
--- rtl.c	1999/10/03 16:47:51	1.45
+++ rtl.c	1999/10/10 12:33:30
@@ -418,21 +418,16 @@ copy_rtx (orig)
 
   for (i = 0; i < GET_RTX_LENGTH (GET_CODE (copy)); i++)
     {
+      copy->fld[i] = orig->fld[i];
       switch (*format_ptr++)
 	{
 	case 'e':
-	  XEXP (copy, i) = XEXP (orig, i);
 	  if (XEXP (orig, i) != NULL)
 	    XEXP (copy, i) = copy_rtx (XEXP (orig, i));
 	  break;
 
-	case 'u':
-	  XEXP (copy, i) = XEXP (orig, i);
-	  break;
-
 	case 'E':
 	case 'V':
-	  XVEC (copy, i) = XVEC (orig, i);
 	  if (XVEC (orig, i) != NULL)
 	    {
 	      XVEC (copy, i) = rtvec_alloc (XVECLEN (orig, i));
@@ -450,25 +445,13 @@ copy_rtx (orig)
 	  }
 
 	case 't':
-	  XTREE (copy, i) = XTREE (orig, i);
-	  break;
-
 	case 'w':
-	  XWINT (copy, i) = XWINT (orig, i);
-	  break;
-
 	case 'i':
-	  XINT (copy, i) = XINT (orig, i);
-	  break;
-
 	case 's':
 	case 'S':
-	  XSTR (copy, i) = XSTR (orig, i);
-	  break;
-
+	case 'u':
 	case '0':
-	  /* Copy this through the wide int field; that's safest. */
-	  X0WINT (copy, i) = X0WINT (orig, i);
+	  /* These are left unchanged.  */
 	  break;
 	  
 	default:



More information about the Gcc-patches mailing list