From b213bf24db8517136eb1553c43b9f7784d50be0d Mon Sep 17 00:00:00 2001 From: jsm28 Date: Thu, 25 Nov 2010 13:16:03 +0000 Subject: [PATCH] * target.def (supports_split_stack, except_unwind_info): Take gcc_options parameters. * targhooks.c (default_except_unwind_info, dwarf2_except_unwind_info, sjlj_except_unwind_info): Take gcc_options parameters. * targhooks.h (default_except_unwind_info, dwarf2_except_unwind_info, sjlj_except_unwind_info): Update prototypes. * doc/tm.texi.in (TARGET_IRA_COVER_CLASSES, TARGET_HAVE_NAMED_SECTIONS, TARGET_UNWIND_TABLES_DEFAULT): Document that hooks must not be modified. (TARGET_EXCEPT_UNWIND_INFO): Refer to opts argument. * doc/tm.texi: Regenerate. * defaults.h (STACK_OLD_CHECK_PROTECT, STACK_CHECK_PROTECT): Pass &global_options to targetm.except_unwind_info. * dwarf2out.c (dwarf2out_do_frame, dwarf2out_do_cfi_asm, dwarf2out_begin_prologue, dwarf2out_frame_init, dwarf2out_frame_finish, dwarf2out_assembly_start): Pass &global_options to targetm.except_unwind_info. * except.c (init_eh, finish_eh_generation, gate_convert_to_eh_region_ranges, output_one_function_exception_table): Pass &global_options to targetm.except_unwind_info. * expr.c (build_personality_function): Pass &global_options to targetm.except_unwind_info. * function.c (expand_function_end): Pass &global_options to targetm.except_unwind_info. * hooks.c (hook_bool_bool_gcc_optionsp_false): New. * hooks.h (hook_bool_bool_gcc_optionsp_false): Declare. * opts.c (finish_options): Pass opts to targetm.except_unwind_info and targetm.supports_split_stack. Remove assertions about opts and opts_set. (common_handle_option): Remove assertions about opts, opts_set and dc. * tree-tailcall.c (suitable_for_tail_call_opt_p): Pass &global_options to targetm.except_unwind_info. * tree.c (build_common_builtin_nodes: Pass &global_options to targetm.except_unwind_info. * config/arm/arm.c (arm_except_unwind_info): Add gcc_options parameter. (arm_compute_func_type, arm_expand_prologue, thumb_pushpop, thumb1_expand_prologue, thumb1_output_function_prologue, arm_unwind_emit, arm_output_fn_unwind): Update calls to arm_except_unwind_info. * config/i386/i386.c (ix86_supports_split_stack): Add gcc_options parameter. * config/ia64/ia64.c (ia64_except_unwind_info): Add gcc_options parameter. (ia64_output_function_prologue, ia64_add_bundle_selector_before, ia64_reorg, ia64_asm_unwind_emit): Update calls to ia64_except_unwind_info. * config/pa/pa.c (pa_option_override): Pass &global_options to targetm.except_unwind_info. * config/picochip/picochip-protos.h (picochip_except_unwind_info): Remove prototype. c-family: * c-cppbuiltin.c (c_cpp_builtins): Pass &global_options to targetm.except_unwind_info. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@167145 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 58 +++++++++++++++++++++++++++++++++++ gcc/c-family/ChangeLog | 5 +++ gcc/c-family/c-cppbuiltin.c | 2 +- gcc/config/arm/arm.c | 23 +++++++------- gcc/config/i386/i386.c | 3 +- gcc/config/ia64/ia64.c | 16 +++++----- gcc/config/pa/pa.c | 3 +- gcc/config/picochip/picochip-protos.h | 2 -- gcc/defaults.h | 12 +++++--- gcc/doc/tm.texi | 20 ++++++++---- gcc/doc/tm.texi.in | 14 +++++++-- gcc/dwarf2out.c | 12 ++++---- gcc/except.c | 14 ++++----- gcc/expr.c | 2 +- gcc/function.c | 4 +-- gcc/hooks.c | 8 +++++ gcc/hooks.h | 1 + gcc/opts.c | 13 ++------ gcc/target.def | 9 +++--- gcc/targhooks.c | 6 ++-- gcc/targhooks.h | 6 ++-- gcc/tree-tailcall.c | 2 +- gcc/tree.c | 3 +- 23 files changed, 162 insertions(+), 76 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c5d09798f4f..8c5473b4f88 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,61 @@ +2010-11-25 Joseph Myers + + * target.def (supports_split_stack, except_unwind_info): Take + gcc_options parameters. + * targhooks.c (default_except_unwind_info, + dwarf2_except_unwind_info, sjlj_except_unwind_info): Take + gcc_options parameters. + * targhooks.h (default_except_unwind_info, + dwarf2_except_unwind_info, sjlj_except_unwind_info): Update + prototypes. + * doc/tm.texi.in (TARGET_IRA_COVER_CLASSES, + TARGET_HAVE_NAMED_SECTIONS, TARGET_UNWIND_TABLES_DEFAULT): + Document that hooks must not be modified. + (TARGET_EXCEPT_UNWIND_INFO): Refer to opts argument. + * doc/tm.texi: Regenerate. + * defaults.h (STACK_OLD_CHECK_PROTECT, STACK_CHECK_PROTECT): Pass + &global_options to targetm.except_unwind_info. + * dwarf2out.c (dwarf2out_do_frame, dwarf2out_do_cfi_asm, + dwarf2out_begin_prologue, dwarf2out_frame_init, + dwarf2out_frame_finish, dwarf2out_assembly_start): Pass + &global_options to targetm.except_unwind_info. + * except.c (init_eh, finish_eh_generation, + gate_convert_to_eh_region_ranges, + output_one_function_exception_table): Pass &global_options to + targetm.except_unwind_info. + * expr.c (build_personality_function): Pass &global_options to + targetm.except_unwind_info. + * function.c (expand_function_end): Pass &global_options to + targetm.except_unwind_info. + * hooks.c (hook_bool_bool_gcc_optionsp_false): New. + * hooks.h (hook_bool_bool_gcc_optionsp_false): Declare. + * opts.c (finish_options): Pass opts to targetm.except_unwind_info + and targetm.supports_split_stack. Remove assertions about opts + and opts_set. + (common_handle_option): Remove assertions about opts, opts_set and + dc. + * tree-tailcall.c (suitable_for_tail_call_opt_p): Pass + &global_options to targetm.except_unwind_info. + * tree.c (build_common_builtin_nodes: Pass &global_options to + targetm.except_unwind_info. + * config/arm/arm.c (arm_except_unwind_info): Add gcc_options + parameter. + (arm_compute_func_type, arm_expand_prologue, thumb_pushpop, + thumb1_expand_prologue, thumb1_output_function_prologue, + arm_unwind_emit, arm_output_fn_unwind): Update calls to + arm_except_unwind_info. + * config/i386/i386.c (ix86_supports_split_stack): Add gcc_options + parameter. + * config/ia64/ia64.c (ia64_except_unwind_info): Add gcc_options + parameter. + (ia64_output_function_prologue, ia64_add_bundle_selector_before, + ia64_reorg, ia64_asm_unwind_emit): Update calls to + ia64_except_unwind_info. + * config/pa/pa.c (pa_option_override): Pass &global_options to + targetm.except_unwind_info. + * config/picochip/picochip-protos.h (picochip_except_unwind_info): + Remove prototype. + 2010-11-25 Kai Tietz * cgraphunit.c (process_function_and_variable_attributes): diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 1b14b0ebbbe..41ae904d66c 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2010-11-25 Joseph Myers + + * c-cppbuiltin.c (c_cpp_builtins): Pass &global_options to + targetm.except_unwind_info. + 2010-11-23 Joseph Myers * c-opts.c (c_common_handle_option): Pass location to diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index ca779648b20..50dced35b56 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -627,7 +627,7 @@ c_cpp_builtins (cpp_reader *pfile) 1000 + flag_abi_version); /* libgcc needs to know this. */ - if (targetm.except_unwind_info () == UI_SJLJ) + if (targetm.except_unwind_info (&global_options) == UI_SJLJ) cpp_define (pfile, "__USING_SJLJ_EXCEPTIONS__"); /* limits.h and stdint.h need to know these. */ diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index b195dbdfa5e..ef42e45c57f 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -201,7 +201,7 @@ static bool arm_output_ttype (rtx); static void arm_asm_emit_except_personality (rtx); static void arm_asm_init_sections (void); #endif -static enum unwind_info_type arm_except_unwind_info (void); +static enum unwind_info_type arm_except_unwind_info (struct gcc_options *); static void arm_dwarf_handle_frame_unspec (const char *, rtx, int); static rtx arm_dwarf_register_span (rtx); @@ -2071,7 +2071,8 @@ arm_compute_func_type (void) if (optimize > 0 && (TREE_NOTHROW (current_function_decl) || !(flag_unwind_tables - || (flag_exceptions && arm_except_unwind_info () != UI_SJLJ))) + || (flag_exceptions + && arm_except_unwind_info (&global_options) != UI_SJLJ))) && TREE_THIS_VOLATILE (current_function_decl)) type |= ARM_FT_VOLATILE; @@ -15773,7 +15774,7 @@ arm_expand_prologue (void) using the EABI unwinder, to prevent faulting instructions from being swapped with a stack adjustment. */ if (crtl->profile || !TARGET_SCHED_PROLOG - || (arm_except_unwind_info () == UI_TARGET + || (arm_except_unwind_info (&global_options) == UI_TARGET && cfun->can_throw_non_call_exceptions)) emit_insn (gen_blockage ()); @@ -19656,7 +19657,7 @@ thumb_pushpop (FILE *f, unsigned long mask, int push, int *cfa_offset, return; } - if (push && arm_except_unwind_info () == UI_TARGET) + if (push && arm_except_unwind_info (&global_options) == UI_TARGET) { fprintf (f, "\t.save\t{"); for (regno = 0; regno < 15; regno++) @@ -20596,7 +20597,7 @@ thumb1_expand_prologue (void) using the EABI unwinder, to prevent faulting instructions from being swapped with a stack adjustment. */ if (crtl->profile || !TARGET_SCHED_PROLOG - || (arm_except_unwind_info () == UI_TARGET + || (arm_except_unwind_info (&global_options) == UI_TARGET && cfun->can_throw_non_call_exceptions)) emit_insn (gen_blockage ()); @@ -20710,7 +20711,7 @@ thumb1_output_function_prologue (FILE *f, HOST_WIDE_INT size ATTRIBUTE_UNUSED) if (crtl->args.pretend_args_size) { /* Output unwind directive for the stack adjustment. */ - if (arm_except_unwind_info () == UI_TARGET) + if (arm_except_unwind_info (&global_options) == UI_TARGET) fprintf (f, "\t.pad #%d\n", crtl->args.pretend_args_size); @@ -20780,7 +20781,7 @@ thumb1_output_function_prologue (FILE *f, HOST_WIDE_INT size ATTRIBUTE_UNUSED) work_register = thumb_find_work_register (live_regs_mask); - if (arm_except_unwind_info () == UI_TARGET) + if (arm_except_unwind_info (&global_options) == UI_TARGET) asm_fprintf (f, "\t.pad #16\n"); asm_fprintf @@ -22388,7 +22389,7 @@ arm_unwind_emit (FILE * asm_out_file, rtx insn) { rtx pat; - if (arm_except_unwind_info () != UI_TARGET) + if (arm_except_unwind_info (&global_options) != UI_TARGET) return; if (!(flag_unwind_tables || crtl->uses_eh_lsda) @@ -22462,7 +22463,7 @@ arm_asm_init_sections (void) /* Implement TARGET_EXCEPT_UNWIND_INFO. */ static enum unwind_info_type -arm_except_unwind_info (void) +arm_except_unwind_info (struct gcc_options *opts) { /* Honor the --enable-sjlj-exceptions configure switch. */ #ifdef CONFIG_SJLJ_EXCEPTIONS @@ -22475,7 +22476,7 @@ arm_except_unwind_info (void) { /* For simplicity elsewhere in this file, indicate that all unwind info is disabled if we're not emitting unwind tables. */ - if (!flag_exceptions && !flag_unwind_tables) + if (!opts->x_flag_exceptions && !opts->x_flag_unwind_tables) return UI_NONE; else return UI_TARGET; @@ -22515,7 +22516,7 @@ arm_dwarf_handle_frame_unspec (const char *label, rtx pattern, int index) void arm_output_fn_unwind (FILE * f, bool prologue) { - if (arm_except_unwind_info () != UI_TARGET) + if (arm_except_unwind_info (&global_options) != UI_TARGET) return; if (prologue) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 4e2e6e1db80..a66a0c4778b 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -9037,7 +9037,8 @@ ix86_builtin_setjmp_frame_value (void) field in the TCB, so they can not be used together. */ static bool -ix86_supports_split_stack (bool report ATTRIBUTE_UNUSED) +ix86_supports_split_stack (bool report ATTRIBUTE_UNUSED, + struct gcc_options *opts ATTRIBUTE_UNUSED) { bool ret = true; diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index bd42f2b6328..878cd72a652 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -262,7 +262,7 @@ static void ia64_asm_emit_except_personality (rtx); static void ia64_asm_init_sections (void); static enum unwind_info_type ia64_debug_unwind_info (void); -static enum unwind_info_type ia64_except_unwind_info (void); +static enum unwind_info_type ia64_except_unwind_info (struct gcc_options *); static struct bundle_state *get_free_bundle_state (void); static void free_bundle_state (struct bundle_state *); @@ -4020,7 +4020,7 @@ ia64_output_function_prologue (FILE *file, HOST_WIDE_INT size ATTRIBUTE_UNUSED) current_frame_info.n_output_regs, current_frame_info.n_rotate_regs); - if (ia64_except_unwind_info () != UI_TARGET) + if (ia64_except_unwind_info (&global_options) != UI_TARGET) return; /* Emit the .prologue directive. */ @@ -4078,7 +4078,7 @@ ia64_output_function_prologue (FILE *file, HOST_WIDE_INT size ATTRIBUTE_UNUSED) static void ia64_output_function_end_prologue (FILE *file) { - if (ia64_except_unwind_info () != UI_TARGET) + if (ia64_except_unwind_info (&global_options) != UI_TARGET) return; fputs ("\t.body\n", file); @@ -8700,7 +8700,7 @@ ia64_add_bundle_selector_before (int template0, rtx insn) ia64_emit_insn_before (b, insn); #if NR_BUNDLES == 10 if ((template0 == 4 || template0 == 5) - && ia64_except_unwind_info () == UI_TARGET) + && ia64_except_unwind_info (&global_options) == UI_TARGET) { int i; rtx note = NULL_RTX; @@ -9541,7 +9541,7 @@ ia64_reorg (void) /* A call must not be the last instruction in a function, so that the return address is still within the function, so that unwinding works properly. Note that IA-64 differs from dwarf2 on this point. */ - if (ia64_except_unwind_info () == UI_TARGET) + if (ia64_except_unwind_info (&global_options) == UI_TARGET) { rtx insn; int saw_stop = 0; @@ -10007,7 +10007,7 @@ process_cfa_offset (FILE *asm_out_file, rtx pat, bool unwind) static void ia64_asm_unwind_emit (FILE *asm_out_file, rtx insn) { - bool unwind = ia64_except_unwind_info () == UI_TARGET; + bool unwind = ia64_except_unwind_info (&global_options) == UI_TARGET; bool frame = dwarf2out_do_frame (); rtx note, pat; bool handled_one; @@ -10144,7 +10144,7 @@ ia64_debug_unwind_info (void) /* Implement TARGET_EXCEPT_UNWIND_INFO. */ static enum unwind_info_type -ia64_except_unwind_info (void) +ia64_except_unwind_info (struct gcc_options *opts) { /* Honor the --enable-sjlj-exceptions configure switch. */ #ifdef CONFIG_UNWIND_EXCEPTIONS @@ -10154,7 +10154,7 @@ ia64_except_unwind_info (void) /* For simplicity elsewhere in this file, indicate that all unwind info is disabled if we're not emitting unwind tables. */ - if (!flag_exceptions && !flag_unwind_tables) + if (!opts->x_flag_exceptions && !opts->x_flag_unwind_tables) return UI_NONE; return UI_TARGET; diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index 8b6f5d85418..81d85b9ae64 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -543,7 +543,8 @@ pa_option_override (void) call frame information. There is no benefit in using this optimization on PA8000 and later processors. */ if (pa_cpu >= PROCESSOR_8000 - || (targetm.except_unwind_info () == UI_DWARF2 && flag_exceptions) + || (targetm.except_unwind_info (&global_options) == UI_DWARF2 + && flag_exceptions) || flag_unwind_tables) target_flags &= ~MASK_JUMP_IN_DELAY; diff --git a/gcc/config/picochip/picochip-protos.h b/gcc/config/picochip/picochip-protos.h index b806ea23f74..965098eec45 100644 --- a/gcc/config/picochip/picochip-protos.h +++ b/gcc/config/picochip/picochip-protos.h @@ -120,8 +120,6 @@ extern int picochip_flag_schedule_insns2; extern void picochip_asm_output_anchor (rtx symbol); -extern enum unwind_info_type picochip_except_unwind_info (void); - /* Instruction set capability flags. These are initialised to the appropriate values by picochip_option_override, once the user has selected a CPU type. */ diff --git a/gcc/defaults.h b/gcc/defaults.h index fb4a8284422..77e7685f3b0 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -1292,16 +1292,20 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #ifdef STACK_CHECK_PROTECT #define STACK_OLD_CHECK_PROTECT STACK_CHECK_PROTECT #else -#define STACK_OLD_CHECK_PROTECT \ - (targetm.except_unwind_info () == UI_SJLJ ? 75 * UNITS_PER_WORD : 8 * 1024) +#define STACK_OLD_CHECK_PROTECT \ + (targetm.except_unwind_info (&global_options) == UI_SJLJ \ + ? 75 * UNITS_PER_WORD \ + : 8 * 1024) #endif /* Minimum amount of stack required to recover from an anticipated stack overflow detection. The default value conveys an estimate of the amount of stack required to propagate an exception. */ #ifndef STACK_CHECK_PROTECT -#define STACK_CHECK_PROTECT \ - (targetm.except_unwind_info () == UI_SJLJ ? 75 * UNITS_PER_WORD : 12 * 1024) +#define STACK_CHECK_PROTECT \ + (targetm.except_unwind_info (&global_options) == UI_SJLJ \ + ? 75 * UNITS_PER_WORD \ + : 12 * 1024) #endif /* Make the maximum frame size be the largest we can and still only need diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 6cb25072c13..6bc5f1f17f2 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -2872,6 +2872,9 @@ otherwise there is no default implementation. You must define either this macro or @code{IRA_COVER_CLASSES} in order to use the integrated register allocator with Chaitin-Briggs coloring. If the macro is not defined, the only available coloring algorithm is Chow's priority coloring. + +This hook must not be modified from @code{NULL} to non-@code{NULL} or +vice versa by command-line option processing. @end deftypefn @defmac IRA_COVER_CLASSES @@ -4936,8 +4939,8 @@ The default version of this hook invokes a function called normally defined in @file{libgcc2.c}. @end deftypefn -@deftypefn {Target Hook} bool TARGET_SUPPORTS_SPLIT_STACK (bool) -Whether this target supports splitting the stack. This is called after options have been parsed, so the target may reject splitting the stack in some configurations. The default version of this hook returns false. If @var{report} is true, this function may issue a warning or error; if @var{report} is false, it must simply return a value +@deftypefn {Target Hook} bool TARGET_SUPPORTS_SPLIT_STACK (bool @var{report}, struct gcc_options *@var{opts}) +Whether this target supports splitting the stack when the options described in @var{opts} have been passed. This is called after options have been parsed, so the target may reject splitting the stack in some configurations. The default version of this hook returns false. If @var{report} is true, this function may issue a warning or error; if @var{report} is false, it must simply return a value @end deftypefn @node Varargs @@ -7340,6 +7343,7 @@ Return NULL if function should go to default text section. @deftypevr {Target Hook} bool TARGET_HAVE_NAMED_SECTIONS This flag is true if the target supports @code{TARGET_ASM_NAMED_SECTION}. +It must not be modified by command-line option processing. @end deftypevr @anchor{TARGET_HAVE_SWITCHABLE_BSS_SECTIONS} @@ -8860,7 +8864,7 @@ Otherwise, if your target supports this information (if it defines or @code{OBJECT_FORMAT_ELF}), GCC will provide a default definition of 1. @end defmac -@deftypefn {Target Hook} {enum unwind_info_type} TARGET_EXCEPT_UNWIND_INFO (void) +@deftypefn {Target Hook} {enum unwind_info_type} TARGET_EXCEPT_UNWIND_INFO (struct gcc_options *@var{opts}) This hook defines the mechanism that will be used for exception handling by the target. If the target has ABI specified unwind tables, the hook should return @code{UI_TARGET}. If the target is to use the @@ -8873,19 +8877,23 @@ This may end up simplifying other parts of target-specific code. The default implementation of this hook never returns @code{UI_NONE}. Note that the value returned by this hook should be constant. It should -not depend on anything except command-line switches. In particular, the +not depend on anything except the command-line switches described by +@var{opts}. In particular, the setting @code{UI_SJLJ} must be fixed at compiler start-up as C pre-processor macros and builtin functions related to exception handling are set up depending on this setting. The default implementation of the hook first honors the @option{--enable-sjlj-exceptions} configure option, then -@code{DWARF2_UNWIND_INFO}, and finally defaults to @code{UI_SJLJ}. +@code{DWARF2_UNWIND_INFO}, and finally defaults to @code{UI_SJLJ}. If +@code{DWARF2_UNWIND_INFO} depends on command-line options, the target +must define this hook so that @var{opts} is used correctly. @end deftypefn @deftypevr {Target Hook} bool TARGET_UNWIND_TABLES_DEFAULT This variable should be set to @code{true} if the target ABI requires unwinding -tables even when exceptions are not used. +tables even when exceptions are not used. It must not be modified by +command-line option processing. @end deftypevr @defmac DONT_USE_BUILTIN_SETJMP diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 1e4432bce59..47d5be2980a 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -2862,6 +2862,9 @@ otherwise there is no default implementation. You must define either this macro or @code{IRA_COVER_CLASSES} in order to use the integrated register allocator with Chaitin-Briggs coloring. If the macro is not defined, the only available coloring algorithm is Chow's priority coloring. + +This hook must not be modified from @code{NULL} to non-@code{NULL} or +vice versa by command-line option processing. @end deftypefn @defmac IRA_COVER_CLASSES @@ -7315,6 +7318,7 @@ Return NULL if function should go to default text section. @hook TARGET_HAVE_NAMED_SECTIONS This flag is true if the target supports @code{TARGET_ASM_NAMED_SECTION}. +It must not be modified by command-line option processing. @end deftypevr @anchor{TARGET_HAVE_SWITCHABLE_BSS_SECTIONS} @@ -8843,19 +8847,23 @@ This may end up simplifying other parts of target-specific code. The default implementation of this hook never returns @code{UI_NONE}. Note that the value returned by this hook should be constant. It should -not depend on anything except command-line switches. In particular, the +not depend on anything except the command-line switches described by +@var{opts}. In particular, the setting @code{UI_SJLJ} must be fixed at compiler start-up as C pre-processor macros and builtin functions related to exception handling are set up depending on this setting. The default implementation of the hook first honors the @option{--enable-sjlj-exceptions} configure option, then -@code{DWARF2_UNWIND_INFO}, and finally defaults to @code{UI_SJLJ}. +@code{DWARF2_UNWIND_INFO}, and finally defaults to @code{UI_SJLJ}. If +@code{DWARF2_UNWIND_INFO} depends on command-line options, the target +must define this hook so that @var{opts} is used correctly. @end deftypefn @hook TARGET_UNWIND_TABLES_DEFAULT This variable should be set to @code{true} if the target ABI requires unwinding -tables even when exceptions are not used. +tables even when exceptions are not used. It must not be modified by +command-line option processing. @end deftypevr @defmac DONT_USE_BUILTIN_SETJMP diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 32bb4dc929a..3195a9271c2 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -153,7 +153,7 @@ dwarf2out_do_frame (void) return true; if ((flag_unwind_tables || flag_exceptions) - && targetm.except_unwind_info () == UI_DWARF2) + && targetm.except_unwind_info (&global_options) == UI_DWARF2) return true; return false; @@ -189,7 +189,7 @@ dwarf2out_do_cfi_asm (void) dwarf2 unwind info for exceptions, then emit .debug_frame by hand. */ if (!HAVE_GAS_CFI_SECTIONS_DIRECTIVE && !flag_unwind_tables && !flag_exceptions - && targetm.except_unwind_info () != UI_DWARF2) + && targetm.except_unwind_info (&global_options) != UI_DWARF2) return false; saved_do_cfi_asm = true; @@ -4072,7 +4072,7 @@ dwarf2out_begin_prologue (unsigned int line ATTRIBUTE_UNUSED, call-site information. We must emit this label if it might be used. */ if (!do_frame && (!flag_exceptions - || targetm.except_unwind_info () != UI_TARGET)) + || targetm.except_unwind_info (&global_options) != UI_TARGET)) return; fnsec = function_section (current_function_decl); @@ -4256,7 +4256,7 @@ dwarf2out_frame_init (void) dwarf2out_def_cfa (NULL, STACK_POINTER_REGNUM, INCOMING_FRAME_SP_OFFSET); if (targetm.debug_unwind_info () == UI_DWARF2 - || targetm.except_unwind_info () == UI_DWARF2) + || targetm.except_unwind_info (&global_options) == UI_DWARF2) initial_return_save (INCOMING_RETURN_ADDR_RTX); } @@ -4269,7 +4269,7 @@ dwarf2out_frame_finish (void) /* Output another copy for the unwinder. */ if ((flag_unwind_tables || flag_exceptions) - && targetm.except_unwind_info () == UI_DWARF2) + && targetm.except_unwind_info (&global_options) == UI_DWARF2) output_call_frame_info (1); } @@ -22014,7 +22014,7 @@ dwarf2out_assembly_start (void) if (HAVE_GAS_CFI_SECTIONS_DIRECTIVE && dwarf2out_do_cfi_asm () && (!(flag_unwind_tables || flag_exceptions) - || targetm.except_unwind_info () != UI_DWARF2)) + || targetm.except_unwind_info (&global_options) != UI_DWARF2)) fprintf (asm_out_file, "\t.cfi_sections\t.debug_frame\n"); } diff --git a/gcc/except.c b/gcc/except.c index 5ee9ba3ca48..2912caeaa0d 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -209,7 +209,7 @@ init_eh (void) /* Create the SjLj_Function_Context structure. This should match the definition in unwind-sjlj.c. */ - if (targetm.except_unwind_info () == UI_SJLJ) + if (targetm.except_unwind_info (&global_options) == UI_SJLJ) { tree f_jbuf, f_per, f_lsda, f_prev, f_cs, f_data, tmp; @@ -1375,13 +1375,13 @@ finish_eh_generation (void) basic_block bb; /* Construct the landing pads. */ - if (targetm.except_unwind_info () == UI_SJLJ) + if (targetm.except_unwind_info (&global_options) == UI_SJLJ) sjlj_build_landing_pads (); else dw2_build_landing_pads (); break_superblocks (); - if (targetm.except_unwind_info () == UI_SJLJ + if (targetm.except_unwind_info (&global_options) == UI_SJLJ /* Kludge for Alpha/Tru64 (see alpha_gp_save_rtx). */ || single_succ_edge (ENTRY_BLOCK_PTR)->insns.r) commit_edge_insertions (); @@ -2622,7 +2622,7 @@ gate_convert_to_eh_region_ranges (void) /* Nothing to do for SJLJ exceptions or if no regions created. */ if (cfun->eh->region_tree == NULL) return false; - if (targetm.except_unwind_info () == UI_SJLJ) + if (targetm.except_unwind_info (&global_options) == UI_SJLJ) return false; return true; } @@ -2961,7 +2961,7 @@ output_one_function_exception_table (int section) eh_data_format_name (tt_format)); #ifndef HAVE_AS_LEB128 - if (targetm.except_unwind_info () == UI_SJLJ) + if (targetm.except_unwind_info (&global_options) == UI_SJLJ) call_site_len = sjlj_size_of_call_site_table (); else call_site_len = dw2_size_of_call_site_table (section); @@ -3028,14 +3028,14 @@ output_one_function_exception_table (int section) dw2_asm_output_delta_uleb128 (cs_end_label, cs_after_size_label, "Call-site table length"); ASM_OUTPUT_LABEL (asm_out_file, cs_after_size_label); - if (targetm.except_unwind_info () == UI_SJLJ) + if (targetm.except_unwind_info (&global_options) == UI_SJLJ) sjlj_output_call_site_table (); else dw2_output_call_site_table (cs_format, section); ASM_OUTPUT_LABEL (asm_out_file, cs_end_label); #else dw2_asm_output_data_uleb128 (call_site_len, "Call-site table length"); - if (targetm.except_unwind_info () == UI_SJLJ) + if (targetm.except_unwind_info (&global_options) == UI_SJLJ) sjlj_output_call_site_table (); else dw2_output_call_site_table (cs_format, section); diff --git a/gcc/expr.c b/gcc/expr.c index 889c34ef6d0..56a6249cb50 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -10290,7 +10290,7 @@ build_personality_function (const char *lang) tree decl, type; char *name; - switch (targetm.except_unwind_info ()) + switch (targetm.except_unwind_info (&global_options)) { case UI_NONE: return NULL; diff --git a/gcc/function.c b/gcc/function.c index 0ed674d4b3c..c69a5c55554 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -4900,7 +4900,7 @@ expand_function_end (void) /* Output the label for the actual return from the function. */ emit_label (return_label); - if (targetm.except_unwind_info () == UI_SJLJ) + if (targetm.except_unwind_info (&global_options) == UI_SJLJ) { /* Let except.c know where it should emit the call to unregister the function context for sjlj exceptions. */ @@ -5059,7 +5059,7 @@ expand_function_end (void) may trap are not moved into the epilogue by scheduling, because we don't always emit unwind information for the epilogue. */ if (cfun->can_throw_non_call_exceptions - && targetm.except_unwind_info () != UI_SJLJ) + && targetm.except_unwind_info (&global_options) != UI_SJLJ) emit_insn (gen_blockage ()); /* If stack protection is enabled for this function, check the guard. */ diff --git a/gcc/hooks.c b/gcc/hooks.c index 19e294fcbd2..f859dd96507 100644 --- a/gcc/hooks.c +++ b/gcc/hooks.c @@ -56,6 +56,14 @@ hook_bool_bool_false (bool a ATTRIBUTE_UNUSED) return false; } +/* Generic hook that takes (bool, struct gcc_options *) and returns false. */ +bool +hook_bool_bool_gcc_optionsp_false (bool a ATTRIBUTE_UNUSED, + struct gcc_options *opts ATTRIBUTE_UNUSED) +{ + return false; +} + /* Generic hook that takes const int, const int) and returns true. */ bool hook_bool_const_int_const_int_true (const int a ATTRIBUTE_UNUSED, const int b ATTRIBUTE_UNUSED) diff --git a/gcc/hooks.h b/gcc/hooks.h index 5bfa1ad047e..7962fe818ba 100644 --- a/gcc/hooks.h +++ b/gcc/hooks.h @@ -28,6 +28,7 @@ extern bool hook_bool_void_false (void); extern bool hook_bool_void_true (void); extern bool hook_bool_bool_false (bool); +extern bool hook_bool_bool_gcc_optionsp_false (bool, struct gcc_options *); extern bool hook_bool_const_int_const_int_true (const int, const int); extern bool hook_bool_mode_false (enum machine_mode); extern bool hook_bool_mode_true (enum machine_mode); diff --git a/gcc/opts.c b/gcc/opts.c index fb6e6dc048f..cd69fe1bd9f 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -632,12 +632,6 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, { enum unwind_info_type ui_except; - /* These assertions are because of the use of target hooks that - still access global data rather than being passed an options - structure pointer. */ - gcc_assert (opts == &global_options); - gcc_assert (opts_set = &global_options_set); - if (opts->x_dump_base_name && ! IS_ABSOLUTE_PATH (opts->x_dump_base_name)) { /* First try to make OPTS->X_DUMP_BASE_NAME relative to the @@ -727,7 +721,7 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, generating unwind info. If opts->x_flag_exceptions is turned on we need to turn off the partitioning optimization. */ - ui_except = targetm.except_unwind_info (); + ui_except = targetm.except_unwind_info (opts); if (opts->x_flag_exceptions && opts->x_flag_reorder_blocks_and_partition @@ -827,7 +821,7 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, opts->x_flag_split_stack = 0; else if (opts->x_flag_split_stack) { - if (!targetm.supports_split_stack (true)) + if (!targetm.supports_split_stack (true, opts)) { error_at (loc, "%<-fsplit-stack%> is not supported by " "this compiler configuration"); @@ -1173,9 +1167,6 @@ common_handle_option (struct gcc_options *opts, int value = decoded->value; enum opt_code code = (enum opt_code) scode; - gcc_assert (opts == &global_options); - gcc_assert (opts_set == &global_options_set); - gcc_assert (dc == global_dc); gcc_assert (decoded->canonical_option_num_elements <= 2); switch (code) diff --git a/gcc/target.def b/gcc/target.def index 22d5660b13d..a486ffad485 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -1831,13 +1831,14 @@ DEFHOOK DEFHOOK (supports_split_stack, - "Whether this target supports splitting the stack. This is called\ + "Whether this target supports splitting the stack when the options\ + described in @var{opts} have been passed. This is called\ after options have been parsed, so the target may reject splitting\ the stack in some configurations. The default version of this hook\ returns false. If @var{report} is true, this function may issue a warning\ or error; if @var{report} is false, it must simply return a value", - bool, (bool), - hook_bool_bool_false) + bool, (bool report, struct gcc_options *opts), + hook_bool_bool_gcc_optionsp_false) /* Returns NULL if target supports the insn within a doloop block, otherwise it returns an error message. */ @@ -2576,7 +2577,7 @@ DEFHOOK DEFHOOK (except_unwind_info, "", - enum unwind_info_type, (void), + enum unwind_info_type, (struct gcc_options *opts), default_except_unwind_info) /* Leave the boolean fields at the end. */ diff --git a/gcc/targhooks.c b/gcc/targhooks.c index f55fa8519d8..cdc280981cb 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -1309,7 +1309,7 @@ default_debug_unwind_info (void) /* Determine the exception handling mechanism for the target. */ enum unwind_info_type -default_except_unwind_info (void) +default_except_unwind_info (struct gcc_options *opts ATTRIBUTE_UNUSED) { /* Obey the configure switch to turn on sjlj exceptions. */ #ifdef CONFIG_SJLJ_EXCEPTIONS @@ -1329,7 +1329,7 @@ default_except_unwind_info (void) /* To be used by targets that force dwarf2 unwind enabled. */ enum unwind_info_type -dwarf2_except_unwind_info (void) +dwarf2_except_unwind_info (struct gcc_options *opts ATTRIBUTE_UNUSED) { /* Obey the configure switch to turn on sjlj exceptions. */ #ifdef CONFIG_SJLJ_EXCEPTIONS @@ -1343,7 +1343,7 @@ dwarf2_except_unwind_info (void) /* To be used by targets that force sjlj unwind enabled. */ enum unwind_info_type -sjlj_except_unwind_info (void) +sjlj_except_unwind_info (struct gcc_options *opts ATTRIBUTE_UNUSED) { return UI_SJLJ; } diff --git a/gcc/targhooks.h b/gcc/targhooks.h index aff1b2745ed..ce73f994cb8 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -163,9 +163,9 @@ extern reg_class_t default_preferred_output_reload_class (rtx, reg_class_t); extern bool default_class_likely_spilled_p (reg_class_t); extern enum unwind_info_type default_debug_unwind_info (void); -extern enum unwind_info_type default_except_unwind_info (void); -extern enum unwind_info_type dwarf2_except_unwind_info (void); -extern enum unwind_info_type sjlj_except_unwind_info (void); +extern enum unwind_info_type default_except_unwind_info (struct gcc_options *); +extern enum unwind_info_type dwarf2_except_unwind_info (struct gcc_options *); +extern enum unwind_info_type sjlj_except_unwind_info (struct gcc_options *); extern int default_label_align_after_barrier_max_skip (rtx); extern int default_loop_align_max_skip (rtx); diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c index 10ae450886f..a9bf62835c7 100644 --- a/gcc/tree-tailcall.c +++ b/gcc/tree-tailcall.c @@ -152,7 +152,7 @@ suitable_for_tail_call_opt_p (void) /* If we are using sjlj exceptions, we may need to add a call to _Unwind_SjLj_Unregister at exit of the function. Which means that we cannot do any sibcall transformations. */ - if (targetm.except_unwind_info () == UI_SJLJ + if (targetm.except_unwind_info (&global_options) == UI_SJLJ && current_function_has_exception_handlers ()) return false; diff --git a/gcc/tree.c b/gcc/tree.c index 52df2bef72e..2f8d96ef4a2 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -9343,7 +9343,8 @@ build_common_builtin_nodes (void) ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE); local_define_builtin ("__builtin_unwind_resume", ftype, BUILT_IN_UNWIND_RESUME, - (targetm.except_unwind_info () == UI_SJLJ + ((targetm.except_unwind_info (&global_options) + == UI_SJLJ) ? "_Unwind_SjLj_Resume" : "_Unwind_Resume"), ECF_NORETURN); -- 2.11.0