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]

PR 11924: Fix mips check for internally-generated symbols


We were checking for internally-generated symbols using:

    if (XSTR (x, 0)[0] == '*'
        && strncmp (XSTR (x, 0) + 1, LOCAL_LABEL_PREFIX,
                    sizeof LOCAL_LABEL_PREFIX - 1) == 0)

which of course fails for non-constant LOCAL_LABEL_PREFIXes.

Since all supported targets use only a single character for the prefix,
and since this code is used fairly often, I thought it would be better
to just check the first character.

Tested on mips-sgi-irix6.5, mips-sgi-irix6.5o32, mips64-linux-gnu
and mipsisa64-elf.  cgd verified that it fixed the PR without
showing testsuite regressions.  OK to install?

Richard


	PR target/11924
	* config/mips/mips.c (INTERNAL_SYMBOL_P): New macro.
	(mips_classify_symbol, m16_usym8_4, m16_usym5_4): Use it.

diff -updr config/mips.5/mips.c config/mips/mips.c
--- config/mips.5/mips.c	Tue Aug 12 22:00:47 2003
+++ config/mips/mips.c	Fri Aug 15 11:57:53 2003
@@ -75,6 +75,9 @@ enum internal_test {
 #define SINGLE_WORD_MODE_P(MODE) \
   ((MODE) != BLKmode && GET_MODE_SIZE (MODE) <= UNITS_PER_WORD)
 
+/* True if the given SYMBOL_REF is for an internally-generated symbol.  */
+#define INTERNAL_SYMBOL_P(SYM) \
+  (XSTR (SYM, 0)[0] == '*' && XSTR (SYM, 0)[1] == LOCAL_LABEL_PREFIX[0])
 
 /* Classifies a non-literal integer constant.
 
@@ -857,9 +860,7 @@ mips_classify_symbol (rtx x)
       return SYMBOL_GENERAL;
     }
 
-  if (XSTR (x, 0)[0] == '*'
-      && strncmp (XSTR (x, 0) + 1, LOCAL_LABEL_PREFIX,
-		  sizeof LOCAL_LABEL_PREFIX - 1) == 0)
+  if (INTERNAL_SYMBOL_P (x))
     {
       /* The symbol is a local label.  For TARGET_MIPS16, SYMBOL_REF_FLAG
 	 will be set if the symbol refers to a string in the current
@@ -2086,9 +2087,7 @@ m16_usym8_4 (rtx op, enum machine_mode m
   if (GET_CODE (op) == SYMBOL_REF
       && SYMBOL_REF_FLAG (op)
       && cfun->machine->insns_len > 0
-      && XSTR (op, 0)[0] == '*'
-      && strncmp (XSTR (op, 0) + 1, LOCAL_LABEL_PREFIX,
-		  sizeof LOCAL_LABEL_PREFIX - 1) == 0
+      && INTERNAL_SYMBOL_P (op)
       && (cfun->machine->insns_len + get_pool_size () + mips_string_length
 	  < 4 * 0x100))
     {
@@ -2111,9 +2110,7 @@ m16_usym5_4 (rtx op, enum machine_mode m
   if (GET_CODE (op) == SYMBOL_REF
       && SYMBOL_REF_FLAG (op)
       && cfun->machine->insns_len > 0
-      && XSTR (op, 0)[0] == '*'
-      && strncmp (XSTR (op, 0) + 1, LOCAL_LABEL_PREFIX,
-		  sizeof LOCAL_LABEL_PREFIX - 1) == 0
+      && INTERNAL_SYMBOL_P (op)
       && (cfun->machine->insns_len + get_pool_size () + mips_string_length
 	  < 4 * 0x20))
     {


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