Message ID | 56547E60.6010702@arm.com |
---|---|
State | Superseded |
Headers | show |
On 25/11/15 12:45, Bernd Schmidt wrote: > On 11/25/2015 01:41 PM, Bernd Schmidt wrote: >> /* arg.locate doesn't contain the pretend_args_size offset, it's part of >> argblock. Ensure we don't count it in I. */ >> #ifdef STACK_GROWS_DOWNWARD >> i -= crtl->args.pretend_args_size >> #else etc. > > Hmm, yours looks equivalent, just addressing the problem from the other direction, except for the STACK_GROWS_DOWNWARD thing. If you fix that, either approach is OK, but watch formatting here (needs extra parens): Thanks, I'll go with your version, except that for GCC 6 we have removed conditional compilation on STACK_GROWS_DOWNWARD so this would be written as: if (STACK_GROWS_DOWNWARD) i -= crtl->args.pretend_args_size; What should we do when we don't have STACK_GROWS_DOWNWARD? Do we need to write: if (STACK_GROWS_DOWNWARD) i -= crtl->args.pretend_args_size; else i += crtl->args.pretend_args_size; ? Kyrill > >> + int argblock_offset = arg->locate.offset.constant >> + + crtl->args.pretend_args_size; > > and a bit later it looks like there's a linebreak you could eliminate because things now fit into 80 characters. > > > Bernd >
On 25/11/15 14:12, Bernd Schmidt wrote: > On 11/25/2015 03:10 PM, Kyrill Tkachov wrote: > >> What should we do when we don't have STACK_GROWS_DOWNWARD? Do we need to >> write: >> if (STACK_GROWS_DOWNWARD) >> i -= crtl->args.pretend_args_size; >> else >> i += crtl->args.pretend_args_size; > > I think so. I mean, this should mirror this code here, right? > > /* The argument block when performing a sibling call is the > incoming argument block. */ > if (pass == 0) > { > argblock = crtl->args.internal_arg_pointer; > if (STACK_GROWS_DOWNWARD) > argblock > = plus_constant (Pmode, argblock, crtl->args.pretend_args_size); > else > argblock > = plus_constant (Pmode, argblock, -crtl->args.pretend_args_size); > Yes, you're right. I'll send out an updated version of the patch shortly. Kyrill > > Bernd >
commit 28b13fd99664480bfb7f5a606dd89719a0aa0b6f Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com> Date: Mon Nov 23 13:19:57 2015 +0000 PR rtl-optimization/67226: Take into account pretend_args_size when checking stack offsets for sibcall optimisation diff --git a/gcc/calls.c b/gcc/calls.c index b56556a..233e1e6 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -4944,17 +4944,19 @@ store_one_arg (struct arg_data *arg, rtx argblock, int flags, && arg->locate.size.var == 0 && CONST_INT_P (size_rtx)); - if (arg->locate.offset.constant > i) + int argblock_offset = arg->locate.offset.constant + + crtl->args.pretend_args_size; + if (argblock_offset > i) { - if (arg->locate.offset.constant < i + INTVAL (size_rtx)) + if (argblock_offset < i + INTVAL (size_rtx)) sibcall_failure = 1; } - else if (arg->locate.offset.constant < i) + else if (argblock_offset < i) { /* Use arg->locate.size.constant instead of size_rtx because we only care about the part of the argument on the stack. */ - if (i < (arg->locate.offset.constant + if (i < (argblock_offset + arg->locate.size.constant)) sibcall_failure = 1; } diff --git a/gcc/testsuite/gcc.c-torture/execute/pr67226.c b/gcc/testsuite/gcc.c-torture/execute/pr67226.c new file mode 100644 index 0000000..c533496 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr67226.c @@ -0,0 +1,42 @@ +struct assembly_operand +{ + int type, value, symtype, symflags, marker; +}; + +struct assembly_operand to_input, from_input; + +void __attribute__ ((__noinline__, __noclone__)) +assemblez_1 (int internal_number, struct assembly_operand o1) +{ + if (o1.type != from_input.type) + __builtin_abort (); +} + +void __attribute__ ((__noinline__, __noclone__)) +t0 (struct assembly_operand to, struct assembly_operand from) +{ + if (to.value == 0) + assemblez_1 (32, from); + else + __builtin_abort (); +} + +int +main (void) +{ + to_input.value = 0; + to_input.type = 1; + to_input.symtype = 2; + to_input.symflags = 3; + to_input.marker = 4; + + from_input.value = 5; + from_input.type = 6; + from_input.symtype = 7; + from_input.symflags = 8; + from_input.marker = 9; + + t0 (to_input, from_input); + + return 0; +}