From ebd5e86c0f41dc1d692f9b2b68a510b1f6835a3e Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 10 Mar 2021 15:12:31 +0100 Subject: Improve global state for options. gcc/c-family/ChangeLog: PR tree-optimization/92860 PR target/99592 * c-attribs.c (handle_optimize_attribute): Save target node before calling parse_optimize_options and save it in case it changes. * c-pragma.c (handle_pragma_target): Similarly for pragma. (handle_pragma_pop_options): Likewise here. gcc/ChangeLog: PR tree-optimization/92860 PR target/99592 * optc-save-gen.awk: Remove exceptions. --- gcc/c-family/c-pragma.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'gcc/c-family/c-pragma.c') diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index 4f8e8e0..7f658ea 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -918,6 +918,12 @@ handle_pragma_target(cpp_reader *ARG_UNUSED(dummy)) if (targetm.target_option.pragma_parse (args, NULL_TREE)) current_target_pragma = chainon (current_target_pragma, args); + + /* A target pragma can also influence optimization options. */ + tree current_optimize + = build_optimization_node (&global_options, &global_options_set); + if (current_optimize != optimization_current_node) + optimization_current_node = current_optimize; } } @@ -1078,12 +1084,14 @@ handle_pragma_pop_options (cpp_reader *ARG_UNUSED(dummy)) target_option_current_node = p->target_binary; } + /* Always restore optimization options as optimization_current_node is + * overwritten by invoke_set_current_function_hook. */ + cl_optimization_restore (&global_options, &global_options_set, + TREE_OPTIMIZATION (p->optimize_binary)); + if (p->optimize_binary != optimization_current_node) { - tree old_optimize = optimization_current_node; - cl_optimization_restore (&global_options, &global_options_set, - TREE_OPTIMIZATION (p->optimize_binary)); - c_cpp_builtins_optimize_pragma (parse_in, old_optimize, + c_cpp_builtins_optimize_pragma (parse_in, optimization_current_node, p->optimize_binary); optimization_current_node = p->optimize_binary; } -- cgit v1.1