This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR middle-end/20263
- From: Eric Botcazou <ebotcazou at libertysurf dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 16 Mar 2005 10:32:27 +0100
- Subject: [PATCH] Fix PR middle-end/20263
Hi,
This is a regression present in GCC 4.x: the compiler emits invalid assembly
code on SPARC 64-bit for
register void *tp __asm__("%g7");
void set_tp(void)
{
tp = 0;
}
SPARC 64-bit defines ASM_DECLARE_REGISTER_GLOBAL (like MMIX), so the expected
assembly code is something like (e.g. with GCC 3.4.x):
.file "pr20263.c"
.register %g7, tp
.section ".text"
.align 4
.global set_tp
.type set_tp, #function
.proc 020
set_tp:
!#PROLOGUE# 0
save %sp, -192, %sp
!#PROLOGUE# 1
mov 0, %g7
return %i7+8
nop
Note the syntax of the .register directive. With GCC 4.x, the code starts
with
.register %g7, %g7
and the assembler complains
/usr/ccs/bin/as: "/var/tmp//ccLsIpQg.s", line 2: error: statement syntax
/usr/ccs/bin/as: "/var/tmp//ccLsIpQg.s", line 10: warning: detect global
register use not covered .register pseudo-op
What has changed between 3.4.x and 4.x is the DECL_ASSEMBLER_NAME of register
variables: it formerly was the same IDENTIFIER as the DECL_NAME (and set by
decl_assembler_name), it is now set by set_user_assembler_name to the actual
assembly name.
The proposed fix is to account for the change in make_decl_rtl. Tested on
sparc64-sun-solaris2.9. OK for mainline and 4.0 branch?
2005-03-16 Eric Botcazou <ebotcazou@libertysurf.fr>
PR middle-end/20263
* varasm.c (make_decl_rtl) [ASM_DECLARE_REGISTER_GLOBAL]: Use
the DECL_NAME, not the DECL_ASSEMBLER_NAME.
2005-03-16 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.dg/sparc-reg-1.c: New test.
--
Eric Botcazou
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.481
diff -u -p -r1.481 varasm.c
--- varasm.c 13 Mar 2005 17:56:14 -0000 1.481
+++ varasm.c 16 Mar 2005 09:01:09 -0000
@@ -897,7 +897,6 @@ make_decl_rtl (tree decl)
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
-
if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
{
reg_number = decode_reg_name (name);
@@ -940,6 +939,7 @@ make_decl_rtl (tree decl)
/* Make this register global, so not usable for anything
else. */
#ifdef ASM_DECLARE_REGISTER_GLOBAL
+ name = IDENTIFIER_POINTER (DECL_NAME (decl));
ASM_DECLARE_REGISTER_GLOBAL (asm_out_file, decl, reg_number, name);
#endif
nregs = hard_regno_nregs[reg_number][DECL_MODE (decl)];
/* PR middle-end/20263 */
/* { dg-do assemble { target sparc64-*-* } } */
/* { dg-options "" } */
register void *tp __asm__("%g7");
void set_tp(void)
{
tp = 0;
}