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]
Other format: [Raw text]

Make genattrtab.c create unique symbol_refs


rtx_equal_p uses:

    case SYMBOL_REF:
      return XSTR (x, 0) == XSTR (y, 0);

to check whether two symbol_refs are equal.  This means that genattrtab,
which uses rtx_equal_p, must create unique strings for them.

attr_rtx has code to create unique strings, and I think it originally
handled symbol_refs.  However, it still assumes that only "s" rtxes are
of interest, whereas symbol_ref is now "s00" (decl and flags).

Fixed with the patch below.  The attr_string patch ensures that we
preserve #line information for the unique strings.  (We'll effectively
pick the first occurence, which should be OK for most cases.)

As explained in the next patch, this doesn't actually bring any
benefit on its own, but it is needed by that patch.

Tested on x86_64-linux-gnu and mips64-linux-gnu.  OK to install?

Richard



gcc/
	* genattrtab.c (attr_rtx_1): Hash SYMBOL_REFs.
	(attr_string): Use copy_md_ptr_loc.

Index: gcc/genattrtab.c
===================================================================
--- gcc/genattrtab.c	2011-07-23 10:03:35.000000000 +0100
+++ gcc/genattrtab.c	2011-07-23 10:34:20.000000000 +0100
@@ -433,8 +433,9 @@ attr_rtx_1 (enum rtx_code code, va_list
 	  XEXP (rt_val, 1) = arg1;
 	}
     }
-  else if (GET_RTX_LENGTH (code) == 1
-	   && GET_RTX_FORMAT (code)[0] == 's')
+  else if (code == SYMBOL_REF
+	   || (GET_RTX_LENGTH (code) == 1
+	       && GET_RTX_FORMAT (code)[0] == 's'))
     {
       char *arg0 = va_arg (p, char *);
 
@@ -452,6 +453,11 @@ attr_rtx_1 (enum rtx_code code, va_list
 	  rtl_obstack = hash_obstack;
 	  rt_val = rtx_alloc (code);
 	  XSTR (rt_val, 0) = arg0;
+	  if (code == SYMBOL_REF)
+	    {
+	      X0EXP (rt_val, 1) = NULL_RTX;
+	      X0EXP (rt_val, 2) = NULL_RTX;
+	    }
 	}
     }
   else if (GET_RTX_LENGTH (code) == 2
@@ -610,6 +616,7 @@ attr_string (const char *str, int len)
   memcpy (new_str, str, len);
   new_str[len] = '\0';
   attr_hash_add_string (hashcode, new_str);
+  copy_md_ptr_loc (new_str, str);
 
   return new_str;			/* Return the new string.  */
 }


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