From c39ada0455f7a4037f98ac221f770742d85d8144 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Thu, 5 Apr 2001 16:13:53 -0400 Subject: [PATCH] function.h (virtuals_instantiated): Declare. * function.h (virtuals_instantiated): Declare. * function.c: (virtuals_instantiated): Make global. * calls.c (emit_library_call_value_1): Use virtual_outgoing_args_rtx only if it hasn't been instantiated. Otherwise, use the stack pointer directly. From-SVN: r41127 --- gcc/ChangeLog | 8 ++++++++ gcc/calls.c | 16 ++++++++++++---- gcc/function.c | 6 ++++-- gcc/function.h | 3 +++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f40281a92e0..25682a3181f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2001-04-05 DJ Delorie + + * function.h (virtuals_instantiated): Declare. + * function.c: (virtuals_instantiated): Make global. + * calls.c (emit_library_call_value_1): Use + virtual_outgoing_args_rtx only if it hasn't been instantiated. + Otherwise, use the stack pointer directly. + Thu Apr 5 19:13:33 CEST 2001 Jan Hubicka * i386.c (x86_initialize_trampoline): New global function. diff --git a/gcc/calls.c b/gcc/calls.c index eb54aee2d8a..d0f3a14038a 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -59,6 +59,10 @@ Boston, MA 02111-1307, USA. */ #define PUSH_ARGS_REVERSED 0 #endif +#ifndef STACK_POINTER_OFFSET +#define STACK_POINTER_OFFSET 0 +#endif + /* Like PREFERRED_STACK_BOUNDARY but in units of bytes, not bits. */ #define STACK_BYTES (PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT) @@ -3820,11 +3824,15 @@ emit_library_call_value_1 (retval, orgfun, value, fn_type, outmode, nargs, p) highest_outgoing_arg_in_use - initial_highest_arg_in_use); needed = 0; - /* The address of the outgoing argument list must not be copied to a - register here, because argblock would be left pointing to the - wrong place after the call to allocate_dynamic_stack_space below. */ + /* We must be careful to use virtual regs before they're instantiated, + and real regs afterwards. Loop optimization, for example, can create + new libcalls after we've instantiated the virtual regs, and if we + use virtuals anyway, they won't match the rtl patterns. */ - argblock = virtual_outgoing_args_rtx; + if (virtuals_instantiated) + argblock = plus_constant (stack_pointer_rtx, STACK_POINTER_OFFSET); + else + argblock = virtual_outgoing_args_rtx; } else { diff --git a/gcc/function.c b/gcc/function.c index c31029bc566..ee182580c2a 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -120,8 +120,10 @@ int current_function_sp_is_unchanging; int current_function_uses_only_leaf_regs; /* Nonzero once virtual register instantiation has been done. - assign_stack_local uses frame_pointer_rtx when this is nonzero. */ -static int virtuals_instantiated; + assign_stack_local uses frame_pointer_rtx when this is nonzero. + calls.c:emit_library_call_value_1 uses it to set up + post-instantiation libcalls. */ +int virtuals_instantiated; /* These variables hold pointers to functions to create and destroy target specific, per-function data structures. */ diff --git a/gcc/function.h b/gcc/function.h index 5621c6b581d..f27c2b01846 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -481,6 +481,9 @@ extern struct function *cfun; /* A list of all functions we have compiled so far. */ extern struct function *all_functions; +/* Nonzero if we've already converted virtual regs to hard regs. */ +extern int virtuals_instantiated; + /* For backward compatibility... eventually these should all go away. */ #define current_function_name (cfun->name) #define current_function_pops_args (cfun->pops_args)