This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFA: Fix builtins/string-asm[12].c failures for __USER_LABEL_PREFIX__ != "" (Was: static-after-extern tests vs. mips explicit relocs)
- From: Joern Rennecke <joern dot rennecke at superh dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Richard Sandiford <rsandifo at redhat dot com>, Richard Henderson <rth at redhat dot com>, Janis Johnson <janis187 at us dot ibm dot com>, "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>, aoliva at redhat dot com
- Date: Wed, 14 May 2003 20:44:58 +0100
- Subject: RFA: Fix builtins/string-asm[12].c failures for __USER_LABEL_PREFIX__ != "" (Was: static-after-extern tests vs. mips explicit relocs)
- Organization: SuperH UK Ltd.
--
--------------------------
SuperH (UK) Ltd.
2410 Aztec West / Almondsbury / BRISTOL / BS32 4QX
T:+44 1454 465658
The split of the string(-opt)-asm-[12].c tests into separate files
has exacerbated a problem with these tests - before the function
calls were just optimized away when optimizing, but now the
actual calls and function definitions remain, and their names
better match.
However, they don't: the asm specifications of the called function names
don't take __USER_LABEL_PREFIX__ into account. So on sh-elf, a call to
a function without a leading underscore is generated, while the definition
has a leading underscore.
To make things more 'interesting', we also have a bug in the compiler
that results in the built-in versions of the functions - that is, the ones
starting with __builtin_ , and the ones called implicitly by structure
copies - to get an extra helping of __USER_LABEL_PREFIX__.
make_decl_rtl already knows that asm names of functions have to be prepended
with a star (except for register names... it barfs when you want to
name a function with a name that is also a register name, alleging
the function is a variable, should we fix that?), but finish-decl does
not.
The following patch fixes 12 regressions per multilib in the builtins
testsuite for sh-elf.
2003-05-14 J"orn Rennecke <joern.rennecke@superh.com>
gcc:
* c-decl.c (finish_decl): When setting the DECL_ASSEMBLER_NAME
of a function using ASMSPEC, prepend a star.
gcc/testsuite:
* gcc.c-torture/execute/builtins/string-asm-1.c: Take
__USER_LABEL_PREFIX__ into account.
* gcc.c-torture/execute/builtins/string-asm-2.c: Likewise.
Index: c-decl.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.387
diff -p -r1.387 c-decl.c
*** c-decl.c 12 May 2003 03:25:35 -0000 1.387
--- c-decl.c 14 May 2003 19:20:37 -0000
*************** finish_decl (decl, init, asmspec_tree)
*** 2865,2889 ****
was a normal built-in. */
if (TREE_CODE (decl) == FUNCTION_DECL && asmspec)
{
if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
{
tree builtin = built_in_decls [DECL_FUNCTION_CODE (decl)];
SET_DECL_RTL (builtin, NULL_RTX);
! SET_DECL_ASSEMBLER_NAME (builtin, get_identifier (asmspec));
#ifdef TARGET_MEM_FUNCTIONS
if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMCPY)
! init_block_move_fn (asmspec);
else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMSET)
! init_block_clear_fn (asmspec);
#else
if (DECL_FUNCTION_CODE (decl) == BUILT_IN_BCOPY)
! init_block_move_fn (asmspec);
else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_BZERO)
! init_block_clear_fn (asmspec);
#endif
}
SET_DECL_RTL (decl, NULL_RTX);
! SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
}
/* Output the assembler code and/or RTL code for variables and functions,
--- 2865,2895 ----
was a normal built-in. */
if (TREE_CODE (decl) == FUNCTION_DECL && asmspec)
{
+ /* ASMSPEC is given, and not the name of a register. Mark the
+ name with a star so assemble_name won't munge it. */
+ char *starred = alloca (strlen (asmspec) + 2);
+ starred[0] = '*';
+ strcpy (starred + 1, asmspec);
+
if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL)
{
tree builtin = built_in_decls [DECL_FUNCTION_CODE (decl)];
SET_DECL_RTL (builtin, NULL_RTX);
! SET_DECL_ASSEMBLER_NAME (builtin, get_identifier (starred));
#ifdef TARGET_MEM_FUNCTIONS
if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMCPY)
! init_block_move_fn (starred);
else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMSET)
! init_block_clear_fn (starred);
#else
if (DECL_FUNCTION_CODE (decl) == BUILT_IN_BCOPY)
! init_block_move_fn (starred);
else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_BZERO)
! init_block_clear_fn (starred);
#endif
}
SET_DECL_RTL (decl, NULL_RTX);
! SET_DECL_ASSEMBLER_NAME (decl, get_identifier (starred));
}
/* Output the assembler code and/or RTL code for variables and functions,
Index: testsuite/gcc.c-torture/execute/builtins/string-asm-1.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/builtins/string-asm-1.c,v
retrieving revision 1.1
diff -p -r1.1 string-asm-1.c
*** testsuite/gcc.c-torture/execute/builtins/string-asm-1.c 11 May 2003 08:20:34 -0000 1.1
--- testsuite/gcc.c-torture/execute/builtins/string-asm-1.c 14 May 2003 19:20:37 -0000
***************
*** 3,12 ****
Ensure all expected transformations of builtin strstr occur and
perform correctly in presence of redirect. */
typedef __SIZE_TYPE__ size_t;
extern void abort (void);
extern char *strstr (const char *, const char *)
! __asm ("my_strstr");
const char *p = "rld", *q = "hello world";
--- 3,16 ----
Ensure all expected transformations of builtin strstr occur and
perform correctly in presence of redirect. */
+ #define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname)
+ #define ASMNAME2(prefix, cname) STRING (prefix) cname
+ #define STRING(x) #x
+
typedef __SIZE_TYPE__ size_t;
extern void abort (void);
extern char *strstr (const char *, const char *)
! __asm (ASMNAME ("my_strstr"));
const char *p = "rld", *q = "hello world";
Index: testsuite/gcc.c-torture/execute/builtins/string-asm-2.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/builtins/string-asm-2.c,v
retrieving revision 1.1
diff -p -r1.1 string-asm-2.c
*** testsuite/gcc.c-torture/execute/builtins/string-asm-2.c 11 May 2003 08:20:34 -0000 1.1
--- testsuite/gcc.c-torture/execute/builtins/string-asm-2.c 14 May 2003 19:20:37 -0000
***************
*** 2,17 ****
Test memcpy and memset in presence of redirect. */
typedef __SIZE_TYPE__ size_t;
extern void abort (void);
extern void *memcpy (void *, const void *, size_t)
! __asm ("my_memcpy");
extern void bcopy (const void *, void *, size_t)
! __asm ("my_bcopy");
extern void *memset (void *, int, size_t)
! __asm ("my_memset");
extern void bzero (void *, size_t)
! __asm ("my_bzero");
extern int memcmp (const void *, const void *, size_t);
struct A { char c[32]; } a = { "foobar" };
--- 2,21 ----
Test memcpy and memset in presence of redirect. */
+ #define ASMNAME(cname) ASMNAME2 (__USER_LABEL_PREFIX__, cname)
+ #define ASMNAME2(prefix, cname) STRING (prefix) cname
+ #define STRING(x) #x
+
typedef __SIZE_TYPE__ size_t;
extern void abort (void);
extern void *memcpy (void *, const void *, size_t)
! __asm (ASMNAME ("my_memcpy"));
extern void bcopy (const void *, void *, size_t)
! __asm (ASMNAME ("my_bcopy"));
extern void *memset (void *, int, size_t)
! __asm (ASMNAME ("my_memset"));
extern void bzero (void *, size_t)
! __asm (ASMNAME ("my_bzero"));
extern int memcmp (const void *, const void *, size_t);
struct A { char c[32]; } a = { "foobar" };