------- Comment #15 from matz at gcc dot gnu dot org 2008-03-18 15:37 -------
We can either force expanding the call address before the arguments (if
it overlaps with them) or simply validate the thing after the fact.
Validating seems a bit easier (and is in line with what is done already for
the expansion of overlapping arguments). Proof of concept patch:
Index: calls.c
===================================================================
--- calls.c (revision 133304)
+++ calls.c (working copy)
@@ -2756,8 +2756,15 @@ expand_call (tree exp, rtx target, int i
use_reg (&call_fusage, struct_value);
}
- funexp = prepare_call_address (funexp, static_chain_value,
+ {
+ rtx before_arg = get_last_insn ();
+
+ funexp = prepare_call_address (funexp, static_chain_value,
&call_fusage, reg_parm_seen, pass == 0);
+ if (pass == 0
+ && check_sibcall_argument_overlap (before_arg, 0, 0))
+ sibcall_failure = 1;
+ }
load_register_parameters (args, num_actuals, &call_fusage, flags,
pass == 0, &sibcall_failure);
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35616