[Bug rtl-optimization/38245] [4.4 Regression] stack corruption when a call is removed but not the outgoing argument pushes
jakub at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Fri Dec 19 10:43:00 GMT 2008
------- Comment #17 from jakub at gcc dot gnu dot org 2008-12-19 10:41 -------
Better testcase:
/* PR rtl-optimization/38245 */
/* { dg-do run } */
/* { dg-options "-O2" } */
extern int bar (long, long, long, long, long, long, long, long,
long, long, long, long, long, long, long, long,
long, long, long, long, long, long, long, long,
long, long, long, long, long, long, long, long)
__attribute__((pure));
struct A { int i, j; union { short s[4]; long long l; }; char pad[512]; } a;
void __attribute__((noinline))
foo (void)
{
a.s[2] = bar (6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21);
a.l = 6;
}
int
main (void)
{
char buf[256];
int i;
for (i = 0; i < (int) sizeof buf; i++)
buf[i] = i;
asm volatile ("" : : "r" (buf) : "memory");
foo ();
asm volatile ("" : : "r" (buf) : "memory");
for (i = 0; i < (int) sizeof buf; i++)
if (buf[i] != (char) i)
__builtin_abort ();
return 0;
}
BTW, e.g. on powerpc64-linux or ia64-linux the stack arguments aren't in
CALL_INSN_FUNCTION_USAGE at all, only the register arguments.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38245
More information about the Gcc-bugs
mailing list