Index: config/aarch64/aarch64.h =================================================================== --- config/aarch64/aarch64.h (revision 239944) +++ config/aarch64/aarch64.h (working copy) @@ -806,6 +806,10 @@ typedef struct correctly. */ #define TRAMPOLINE_SECTION text_section +/* Use custom descriptors instead of trampolines when possible, but + TARGET_PTRMEMFUNC_VBIT_LOCATION is defined so use bit #1. */ +#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 2 + /* To start with. */ #define BRANCH_COST(SPEED_P, PREDICTABLE_P) \ (aarch64_branch_cost (SPEED_P, PREDICTABLE_P)) Index: config/alpha/alpha.h =================================================================== --- config/alpha/alpha.h (revision 239944) +++ config/alpha/alpha.h (working copy) @@ -996,3 +996,6 @@ extern long alpha_auto_offset; #define NO_IMPLICIT_EXTERN_C #define TARGET_SUPPORTS_WIDE_INT 1 + +/* Use custom descriptors instead of trampolines when possible if not VMS. */ +#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS (TARGET_ABI_OPEN_VMS ? 0 : 1) Index: config/arm/arm.c =================================================================== --- config/arm/arm.c (revision 239944) +++ config/arm/arm.c (working copy) @@ -6818,6 +6818,29 @@ arm_function_ok_for_sibcall (tree decl, tree exp) && DECL_WEAK (decl)) return false; + /* We cannot do a tailcall for an indirect call by descriptor if all the + argument registers are used because the only register left to load the + address is IP and it will already contain the static chain. */ + if (!decl && CALL_EXPR_BY_DESCRIPTOR (exp) && !flag_trampolines) + { + tree fntype = TREE_TYPE (TREE_TYPE (CALL_EXPR_FN (exp))); + CUMULATIVE_ARGS cum; + cumulative_args_t cum_v; + + arm_init_cumulative_args (&cum, fntype, NULL_RTX, NULL_TREE); + cum_v = pack_cumulative_args (&cum); + + for (tree t = TYPE_ARG_TYPES (fntype); t; t = TREE_CHAIN (t)) + { + tree type = TREE_VALUE (t); + if (!VOID_TYPE_P (type)) + arm_function_arg_advance (cum_v, TYPE_MODE (type), type, true); + } + + if (!arm_function_arg (cum_v, SImode, integer_type_node, true)) + return false; + } + /* Everything else is ok. */ return true; } @@ -30187,7 +30210,9 @@ arm_relayout_function (tree fndecl) callee_tree = target_option_default_node; struct cl_target_option *opts = TREE_TARGET_OPTION (callee_tree); - SET_DECL_ALIGN (fndecl, FUNCTION_BOUNDARY_P (opts->x_target_flags)); + SET_DECL_ALIGN (fndecl, + FUNCTION_ALIGNMENT + (FUNCTION_BOUNDARY_P (opts->x_target_flags))); } /* Inner function to process the attribute((target(...))), take an argument and Index: config/arm/arm.h =================================================================== --- config/arm/arm.h (revision 239944) +++ config/arm/arm.h (working copy) @@ -1645,6 +1645,10 @@ typedef struct /* Alignment required for a trampoline in bits. */ #define TRAMPOLINE_ALIGNMENT 32 + +/* Use custom descriptors instead of trampolines when possible, but + TARGET_PTRMEMFUNC_VBIT_LOCATION is defined so use bit #1. */ +#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 2 /* Addressing modes, and classification of registers for them. */ #define HAVE_POST_INCREMENT 1 Index: config/i386/i386.h =================================================================== --- config/i386/i386.h (revision 239944) +++ config/i386/i386.h (working copy) @@ -2670,6 +2670,9 @@ extern void debug_dispatch_window (int); #define TARGET_SUPPORTS_WIDE_INT 1 +/* Use custom descriptors instead of trampolines when possible. */ +#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 1 + /* Local variables: version-control: t Index: config/ia64/ia64.h =================================================================== --- config/ia64/ia64.h (revision 239944) +++ config/ia64/ia64.h (working copy) @@ -1714,4 +1714,7 @@ struct GTY(()) machine_function /* Switch on code for querying unit reservations. */ #define CPU_UNITS_QUERY 1 +/* IA-64 already uses descriptors for its standard calling sequence. */ +#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 0 + /* End of ia64.h */ Index: config/mips/mips.h =================================================================== --- config/mips/mips.h (revision 239944) +++ config/mips/mips.h (working copy) @@ -3413,3 +3413,7 @@ struct GTY(()) machine_function { #define ENABLE_LD_ST_PAIRS \ (TARGET_LOAD_STORE_PAIRS && (TUNE_P5600 || TUNE_I6400) \ && !TARGET_MICROMIPS && !TARGET_FIX_24K) + +/* Use custom descriptors instead of trampolines when possible, but + TARGET_PTRMEMFUNC_VBIT_LOCATION is defined so use bit #1. */ +#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 2 Index: config/pa/pa.h =================================================================== --- config/pa/pa.h (revision 239944) +++ config/pa/pa.h (working copy) @@ -1313,3 +1313,6 @@ do { \ seven and four instructions, respectively. */ #define MAX_PCREL17F_OFFSET \ (flag_pic ? (TARGET_HPUX ? 198164 : 221312) : 240000) + +/* HP-PA already uses descriptors for its standard calling sequence. */ +#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 0 Index: config/rs6000/rs6000.h =================================================================== --- config/rs6000/rs6000.h (revision 239944) +++ config/rs6000/rs6000.h (working copy) @@ -2914,3 +2914,6 @@ extern GTY(()) tree rs6000_builtin_types[RS6000_BT extern GTY(()) tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT]; #define TARGET_SUPPORTS_WIDE_INT 1 + +/* Use custom descriptors instead of trampolines when possible if not AIX. */ +#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS (DEFAULT_ABI == ABI_AIX ? 0 : 1) Index: config/sparc/sparc.h =================================================================== --- config/sparc/sparc.h (revision 239944) +++ config/sparc/sparc.h (working copy) @@ -1817,3 +1817,6 @@ extern int sparc_indent_opcode; #define SPARC_LOW_FE_EXCEPT_VALUES 0 #define TARGET_SUPPORTS_WIDE_INT 1 + +/* Use custom descriptors instead of trampolines when possible. */ +#define TARGET_CUSTOM_FUNCTION_DESCRIPTORS 1