Patchwork PR62120

login
register
mail settings
Submitter Ilya Tocar
Date Sept. 1, 2014, 10:43 a.m.
Message ID <20140901104314.GB26266@msticlxl7.ims.intel.com>
Download mbox | patch
Permalink /patch/384752/
State New
Headers show

Comments

Ilya Tocar - Sept. 1, 2014, 10:43 a.m.
Hi, this patch adds checks for registers availability, when
alternative/numeric name is used.
Bootstraps/passes make-check on x86-64.
Ok for trunk?

ChangeLog:

gcc/

2014-09-01  Ilya Tocar  <ilya.tocar@intel.com>

	* varasm.c (decode_reg_name_and_count): Check availability for
	registers from ADDITIONAL_REGISTER_NAMES.


---
 gcc/varasm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Jakub Jelinek - Sept. 1, 2014, 10:55 a.m.
On Mon, Sep 01, 2014 at 02:43:14PM +0400, Ilya Tocar wrote:
> Hi, this patch adds checks for registers availability, when
> alternative/numeric name is used.
> Bootstraps/passes make-check on x86-64.
> Ok for trunk?
> 
> ChangeLog:
> 
> gcc/
> 
> 2014-09-01  Ilya Tocar  <ilya.tocar@intel.com>
> 
> 	* varasm.c (decode_reg_name_and_count): Check availability for
> 	registers from ADDITIONAL_REGISTER_NAMES.

Please mention the PR in the ChangeLog entry and add some testcases
(can be gcc.target/i386/, but we should have it tested).
Does this change anything on say register short sil __asm ("sil"); in 32-bit
mode (when it IMHO should be rejected too?)?

	Jakub

Patch

diff --git a/gcc/varasm.c b/gcc/varasm.c
index 9d8602b..1d6f79f 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -888,7 +888,7 @@  decode_reg_name_and_count (const char *asmspec, int *pnregs)
       if (asmspec[0] != 0 && i < 0)
 	{
 	  i = atoi (asmspec);
-	  if (i < FIRST_PSEUDO_REGISTER && i >= 0)
+	  if (i < FIRST_PSEUDO_REGISTER && i >= 0 && reg_names[i][0])
 	    return i;
 	  else
 	    return -2;
@@ -925,7 +925,8 @@  decode_reg_name_and_count (const char *asmspec, int *pnregs)
 
 	for (i = 0; i < (int) ARRAY_SIZE (table); i++)
 	  if (table[i].name[0]
-	      && ! strcmp (asmspec, table[i].name))
+	      && ! strcmp (asmspec, table[i].name)
+	      && reg_names[table[i].number][0])
 	    return table[i].number;
       }
 #endif /* ADDITIONAL_REGISTER_NAMES */