optimization/9226: GCSE breaking argument passing
schwab@suse.de
schwab@suse.de
Mon Jan 13 05:17:00 GMT 2003
>Number: 9226
>Category: optimization
>Synopsis: GCSE breaking argument passing
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Wed Jan 08 06:26:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:
>Release: 3.4 20030107 (experimental)
>Organization:
>Environment:
System: Linux sykes 2.4.19-SMP #1 SMP Wed Dec 11 22:55:37 UTC 2002 ia64 unknown unknown GNU/Linux
Architecture: ia64
host: ia64-unknown-linux-gnu
build: ia64-unknown-linux-gnu
target: m68k-unknown-linux-gnu
configured with: /cvs/gcc/configure --with-gcc-version-trigger=/cvs/gcc/gcc/version.c --host=ia64-unknown-linux --target=m68k-linux --prefix=/usr/local/m68k-linux --enable-languages=c++ --with-ld=/usr/local/m68k-linux/m68k-linux/bin/ld --with-as=/usr/local/m68k-linux/m68k-linux/bin/as --enable-shared
>Description:
GCSE is replacing references to the stack pointer by a different register
during argument passing.
Before GCSE:
(insn 24 23 28 0 0x2000000002410840 (set (reg/v/f:SI 36)
(reg/f:SI 15 %sp)) 29 {*m68k.md:978} (nil)
(nil))
(insn 28 24 29 0 0x2000000002410840 (set (mem/f:SI (pre_dec:SI (reg/f:SI 15 %sp)) [0 S4 A16])
(reg/v:SI 33)) 29 {*m68k.md:978} (nil)
(nil))
(insn 29 28 30 0 0x2000000002410840 (set (mem/f:SI (pre_dec:SI (reg/f:SI 15 %sp)) [0 S4 A16])
(reg/v/f:SI 29)) 29 {*m68k.md:978} (nil)
(nil))
(insn 30 29 31 0 0x2000000002410840 (set (mem/f:SI (pre_dec:SI (reg/f:SI 15 %sp)) [0 S4 A16])
(reg/v/f:SI 36)) 29 {*m68k.md:978} (nil)
(nil))
(insn 31 30 32 0 0x2000000002410840 (set (reg/f:SI 44)
(symbol_ref:SI ("memcpy"))) 29 {*m68k.md:978} (nil)
(expr_list:REG_EQUAL (symbol_ref:SI ("memcpy"))
(nil)))
After GCSE:
(insn 24 23 28 0 0x2000000002410840 (set (reg/v/f:SI 36)
(reg/f:SI 15 %sp)) 29 {*m68k.md:978} (nil)
(nil))
(insn 28 24 29 0 0x2000000002410840 (set (mem/f:SI (pre_dec:SI (reg/f:SI 15 %sp)) [0 S4 A16])
(reg/v:SI 33)) 29 {*m68k.md:978} (nil)
(nil))
(insn 29 28 30 0 0x2000000002410840 (set (mem/f:SI (pre_dec:SI (reg/v/f:SI 36)) [0 S4 A16])
(reg/v/f:SI 29)) 29 {*m68k.md:978} (nil)
(nil))
(insn 30 29 31 0 0x2000000002410840 (set (mem/f:SI (pre_dec:SI (reg/v/f:SI 36)) [0 S4 A16])
(reg/v/f:SI 36)) 29 {*m68k.md:978} (nil)
(nil))
(insn 31 30 32 0 0x2000000002410840 (set (reg/f:SI 44)
(symbol_ref:SI ("memcpy"))) 29 {*m68k.md:978} (nil)
(expr_list:REG_EQUAL (symbol_ref:SI ("memcpy"))
(nil)))
(reg 36) is not a valid replacement for (reg 15).
>How-To-Repeat:
$ cat alloca.c
typedef unsigned int size_t;
void *memcpy (void *__restrict, const void *__restrict, size_t);
size_t strlen (const char *);
int printf (const char *, ...);
# define strdupa(s) \
(__extension__ \
({ \
__const char *__old = (s); \
size_t __len = strlen (__old) + 1; \
char *__new = (char *) __builtin_alloca (__len); \
(char *) memcpy (__new, __old, __len); \
}))
void
foo (const char *x)
{
size_t nx;
char *y = strdupa (x);
nx = 1;
while (*y)
{
if (*y == ':' || *y == ';')
++nx;
y++;
}
printf ("%s %zu", y, nx);
}
$ m68k-linux-gcc -S -O2 alloca.c
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list