Index: calls.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/calls.c,v retrieving revision 1.231.4.5 diff -w -u -p -r1.231.4.5 calls.c --- calls.c 20 Sep 2002 01:29:06 -0000 1.231.4.5 +++ calls.c 28 Sep 2002 05:00:02 -0000 @@ -36,10 +36,6 @@ Software Foundation, 59 Temple Place - S #include "langhooks.h" #include "target.h" -#if !defined FUNCTION_OK_FOR_SIBCALL -#define FUNCTION_OK_FOR_SIBCALL(DECL) 1 -#endif - /* Decide whether a function's arguments should be processed from first to last or from last to first. @@ -2443,17 +2439,12 @@ expand_call (exp, target, ignore) It does not seem worth the effort since few optimizable sibling calls will return a structure. */ || structure_value_addr != NULL_RTX - /* If the register holding the address is a callee saved - register, then we lose. We have no way to prevent that, - so we only allow calls to named functions. */ - /* ??? This could be done by having the insn constraints - use a register class that is all call-clobbered. Any - reload insns generated to fix things up would appear - before the sibcall_epilogue. */ - || fndecl == NULL_TREE + /* Check whether the target is able to optimize the call + into a sibcall. */ + || !(*targetm.function_ok_for_sibcall) (fndecl, exp) || (flags & (ECF_RETURNS_TWICE | ECF_LONGJMP)) - || TREE_THIS_VOLATILE (fndecl) - || !FUNCTION_OK_FOR_SIBCALL (fndecl) + /* Functions that do not return may not be sibcall optimized. */ + || TYPE_VOLATILE (TREE_TYPE (TREE_OPERAND (exp, 0))) /* If this function requires more stack slots than the current function, we cannot change it into a sibling call. */ || args_size.constant > current_function_args_size Index: hooks.h =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/hooks.h,v retrieving revision 1.5 diff -w -u -p -r1.5 hooks.h --- hooks.h 21 Aug 2002 02:41:44 -0000 1.5 +++ hooks.h 28 Sep 2002 05:00:03 -0000 @@ -27,5 +27,5 @@ bool hook_tree_bool_false PARAMS ((tree) void hook_tree_int_void PARAMS ((tree, int)); void hook_void_void PARAMS ((void)); void hook_FILEptr_constcharptr_void PARAMS ((FILE *, const char *)); - +bool hook_tree_tree_bool_false PARAMS ((tree, tree)); #endif Index: hooks.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/hooks.c,v retrieving revision 1.5 diff -w -u -p -r1.5 hooks.c --- hooks.c 21 Aug 2002 02:41:44 -0000 1.5 +++ hooks.c 28 Sep 2002 05:00:03 -0000 @@ -62,3 +62,12 @@ hook_FILEptr_constcharptr_void (a, b) const char *b ATTRIBUTE_UNUSED; { } + +/* Hook that takes two trees and returns false. */ +bool +hook_tree_tree_bool_false (a, b) + tree a ATTRIBUTE_UNUSED; + tree b ATTRIBUTE_UNUSED; +{ + return false; +} Index: target.h =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/target.h,v retrieving revision 1.33.2.3 diff -w -u -p -r1.33.2.3 target.h --- target.h 17 Sep 2002 22:58:47 -0000 1.33.2.3 +++ target.h 28 Sep 2002 05:00:04 -0000 @@ -244,6 +244,11 @@ struct gcc_target not, at the current point in the compilation. */ bool (* cannot_modify_jumps_p) PARAMS ((void)); + /* True if it is OK to do sibling call optimization for the specified + call expression EXP. DECL will be the called function, or NULL if + this is an indirect call. */ + bool (*function_ok_for_sibcall) PARAMS ((tree decl, tree exp)); + /* True if EXP should be placed in a "small data" section. */ bool (* in_small_data_p) PARAMS ((tree)); Index: target-def.h =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/target-def.h,v retrieving revision 1.30.2.3 diff -w -u -p -r1.30.2.3 target-def.h --- target-def.h 17 Sep 2002 22:58:47 -0000 1.30.2.3 +++ target-def.h 28 Sep 2002 05:00:05 -0000 @@ -245,6 +245,7 @@ Foundation, 59 Temple Place - Suite 330, /* In hook.c. */ #define TARGET_CANNOT_MODIFY_JUMPS_P hook_void_bool_false +#define TARGET_FUNCTION_OK_FOR_SIBCALL hook_tree_tree_bool_false #ifndef TARGET_IN_SMALL_DATA_P #define TARGET_IN_SMALL_DATA_P hook_tree_bool_false @@ -271,6 +272,7 @@ Foundation, 59 Temple Place - Suite 330, TARGET_EXPAND_BUILTIN, \ TARGET_SECTION_TYPE_FLAGS, \ TARGET_CANNOT_MODIFY_JUMPS_P, \ + TARGET_FUNCTION_OK_FOR_SIBCALL, \ TARGET_IN_SMALL_DATA_P, \ TARGET_BINDS_LOCAL_P, \ TARGET_ENCODE_SECTION_INFO, \