public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/PR92860-global-opts-state-improvement)] Improve global state for options.
@ 2021-03-10 14:12 Martin Liska
0 siblings, 0 replies; 4+ messages in thread
From: Martin Liska @ 2021-03-10 14:12 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:507ed09bad40de58fcc58b6d64e095a08689efb0
commit 507ed09bad40de58fcc58b6d64e095a08689efb0
Author: Martin Liska <mliska@suse.cz>
Date: Wed Mar 10 15:12:31 2021 +0100
Improve global state for options.
Diff:
---
gcc/c-family/c-attribs.c | 9 +++++++++
gcc/c-family/c-pragma.c | 16 ++++++++++++----
gcc/optc-save-gen.awk | 8 --------
3 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index c1f652d1dc9..d7ff2f2d1ff 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -5332,6 +5332,8 @@ handle_optimize_attribute (tree *node, tree name, tree args,
/* Save current options. */
cl_optimization_save (&cur_opts, &global_options, &global_options_set);
+ tree prev_target_node = build_target_option_node (&global_options,
+ &global_options_set);
/* If we previously had some optimization options, use them as the
default. */
@@ -5350,10 +5352,17 @@ handle_optimize_attribute (tree *node, tree name, tree args,
parse_optimize_options (args, true);
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node)
= build_optimization_node (&global_options, &global_options_set);
+ tree target_node = build_target_option_node (&global_options,
+ &global_options_set);
+ if (prev_target_node != target_node)
+ DECL_FUNCTION_SPECIFIC_TARGET (*node) = target_node;
/* Restore current options. */
cl_optimization_restore (&global_options, &global_options_set,
&cur_opts);
+ cl_target_option_restore (&global_options, &global_options_set,
+ TREE_TARGET_OPTION (prev_target_node));
+
if (saved_global_options != NULL)
{
cl_optimization_compare (saved_global_options, &global_options);
diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c
index 4f8e8e0128c..7f658ea5646 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;
}
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 14b8d03888e..e2a9a496bfd 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -1438,18 +1438,10 @@ print "{"
checked_options["flag_merge_constants"]++
checked_options["param_max_fields_for_field_sensitive"]++
checked_options["flag_omit_frame_pointer"]++
-checked_options["unroll_only_small_loops"]++
# arc exceptions
checked_options["TARGET_ALIGN_CALL"]++
checked_options["TARGET_CASE_VECTOR_PC_RELATIVE"]++
checked_options["arc_size_opt_level"]++
-# arm exceptions
-checked_options["arm_fp16_format"]++
-# s390 exceptions
-checked_options["param_max_completely_peel_times"]++
-checked_options["param_max_completely_peeled_insns"]++
-checked_options["param_max_unroll_times"]++
-checked_options["param_max_unrolled_insns"]++
for (i = 0; i < n_opts; i++) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gcc(refs/users/marxin/heads/PR92860-global-opts-state-improvement)] Improve global state for options.
@ 2021-04-21 12:42 Martin Liska
0 siblings, 0 replies; 4+ messages in thread
From: Martin Liska @ 2021-04-21 12:42 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:997917c0cb402f5aaf28bd8e9b60ad039c66c92f
commit 997917c0cb402f5aaf28bd8e9b60ad039c66c92f
Author: Martin Liska <mliska@suse.cz>
Date: Wed Mar 10 15:12:31 2021 +0100
Improve global state for options.
Diff:
---
gcc/c-family/c-attribs.c | 9 +++++++++
gcc/c-family/c-pragma.c | 16 ++++++++++++----
gcc/optc-save-gen.awk | 9 ---------
3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index c1f652d1dc9..d7ff2f2d1ff 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -5332,6 +5332,8 @@ handle_optimize_attribute (tree *node, tree name, tree args,
/* Save current options. */
cl_optimization_save (&cur_opts, &global_options, &global_options_set);
+ tree prev_target_node = build_target_option_node (&global_options,
+ &global_options_set);
/* If we previously had some optimization options, use them as the
default. */
@@ -5350,10 +5352,17 @@ handle_optimize_attribute (tree *node, tree name, tree args,
parse_optimize_options (args, true);
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node)
= build_optimization_node (&global_options, &global_options_set);
+ tree target_node = build_target_option_node (&global_options,
+ &global_options_set);
+ if (prev_target_node != target_node)
+ DECL_FUNCTION_SPECIFIC_TARGET (*node) = target_node;
/* Restore current options. */
cl_optimization_restore (&global_options, &global_options_set,
&cur_opts);
+ cl_target_option_restore (&global_options, &global_options_set,
+ TREE_TARGET_OPTION (prev_target_node));
+
if (saved_global_options != NULL)
{
cl_optimization_compare (saved_global_options, &global_options);
diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c
index 4f8e8e0128c..7f658ea5646 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;
}
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 19afa895930..e2a9a496bfd 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -1438,19 +1438,10 @@ print "{"
checked_options["flag_merge_constants"]++
checked_options["param_max_fields_for_field_sensitive"]++
checked_options["flag_omit_frame_pointer"]++
-checked_options["unroll_only_small_loops"]++
# arc exceptions
checked_options["TARGET_ALIGN_CALL"]++
checked_options["TARGET_CASE_VECTOR_PC_RELATIVE"]++
checked_options["arc_size_opt_level"]++
-# arm exceptions
-checked_options["arm_fp16_format"]++
-checked_options["flag_ipa_ra"]++
-# s390 exceptions
-checked_options["param_max_completely_peel_times"]++
-checked_options["param_max_completely_peeled_insns"]++
-checked_options["param_max_unroll_times"]++
-checked_options["param_max_unrolled_insns"]++
for (i = 0; i < n_opts; i++) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gcc(refs/users/marxin/heads/PR92860-global-opts-state-improvement)] Improve global state for options.
@ 2021-04-21 14:35 Martin Liska
0 siblings, 0 replies; 4+ messages in thread
From: Martin Liska @ 2021-04-21 14:35 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:997c348a96cc0ab00deac024d51764b20260852d
commit 997c348a96cc0ab00deac024d51764b20260852d
Author: Martin Liska <mliska@suse.cz>
Date: Wed Mar 10 15:12:31 2021 +0100
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.
Diff:
---
gcc/c-family/c-attribs.c | 9 +++++++++
gcc/c-family/c-pragma.c | 16 ++++++++++++----
gcc/optc-save-gen.awk | 9 ---------
3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index c1f652d1dc9..d7ff2f2d1ff 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -5332,6 +5332,8 @@ handle_optimize_attribute (tree *node, tree name, tree args,
/* Save current options. */
cl_optimization_save (&cur_opts, &global_options, &global_options_set);
+ tree prev_target_node = build_target_option_node (&global_options,
+ &global_options_set);
/* If we previously had some optimization options, use them as the
default. */
@@ -5350,10 +5352,17 @@ handle_optimize_attribute (tree *node, tree name, tree args,
parse_optimize_options (args, true);
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node)
= build_optimization_node (&global_options, &global_options_set);
+ tree target_node = build_target_option_node (&global_options,
+ &global_options_set);
+ if (prev_target_node != target_node)
+ DECL_FUNCTION_SPECIFIC_TARGET (*node) = target_node;
/* Restore current options. */
cl_optimization_restore (&global_options, &global_options_set,
&cur_opts);
+ cl_target_option_restore (&global_options, &global_options_set,
+ TREE_TARGET_OPTION (prev_target_node));
+
if (saved_global_options != NULL)
{
cl_optimization_compare (saved_global_options, &global_options);
diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c
index 4f8e8e0128c..7f658ea5646 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;
}
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 19afa895930..e2a9a496bfd 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -1438,19 +1438,10 @@ print "{"
checked_options["flag_merge_constants"]++
checked_options["param_max_fields_for_field_sensitive"]++
checked_options["flag_omit_frame_pointer"]++
-checked_options["unroll_only_small_loops"]++
# arc exceptions
checked_options["TARGET_ALIGN_CALL"]++
checked_options["TARGET_CASE_VECTOR_PC_RELATIVE"]++
checked_options["arc_size_opt_level"]++
-# arm exceptions
-checked_options["arm_fp16_format"]++
-checked_options["flag_ipa_ra"]++
-# s390 exceptions
-checked_options["param_max_completely_peel_times"]++
-checked_options["param_max_completely_peeled_insns"]++
-checked_options["param_max_unroll_times"]++
-checked_options["param_max_unrolled_insns"]++
for (i = 0; i < n_opts; i++) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gcc(refs/users/marxin/heads/PR92860-global-opts-state-improvement)] Improve global state for options.
@ 2021-05-13 8:57 Martin Liska
0 siblings, 0 replies; 4+ messages in thread
From: Martin Liska @ 2021-05-13 8:57 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:ad05071766c4e7336503e19b06e309a09b726131
commit ad05071766c4e7336503e19b06e309a09b726131
Author: Martin Liska <mliska@suse.cz>
Date: Wed Mar 10 15:12:31 2021 +0100
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.
Diff:
---
gcc/c-family/c-attribs.c | 9 +++++++++
gcc/c-family/c-pragma.c | 16 ++++++++++++----
gcc/optc-save-gen.awk | 9 ---------
3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c
index c1f652d1dc9..d7ff2f2d1ff 100644
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -5332,6 +5332,8 @@ handle_optimize_attribute (tree *node, tree name, tree args,
/* Save current options. */
cl_optimization_save (&cur_opts, &global_options, &global_options_set);
+ tree prev_target_node = build_target_option_node (&global_options,
+ &global_options_set);
/* If we previously had some optimization options, use them as the
default. */
@@ -5350,10 +5352,17 @@ handle_optimize_attribute (tree *node, tree name, tree args,
parse_optimize_options (args, true);
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node)
= build_optimization_node (&global_options, &global_options_set);
+ tree target_node = build_target_option_node (&global_options,
+ &global_options_set);
+ if (prev_target_node != target_node)
+ DECL_FUNCTION_SPECIFIC_TARGET (*node) = target_node;
/* Restore current options. */
cl_optimization_restore (&global_options, &global_options_set,
&cur_opts);
+ cl_target_option_restore (&global_options, &global_options_set,
+ TREE_TARGET_OPTION (prev_target_node));
+
if (saved_global_options != NULL)
{
cl_optimization_compare (saved_global_options, &global_options);
diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c
index 4f8e8e0128c..7f658ea5646 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;
}
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 19afa895930..e2a9a496bfd 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -1438,19 +1438,10 @@ print "{"
checked_options["flag_merge_constants"]++
checked_options["param_max_fields_for_field_sensitive"]++
checked_options["flag_omit_frame_pointer"]++
-checked_options["unroll_only_small_loops"]++
# arc exceptions
checked_options["TARGET_ALIGN_CALL"]++
checked_options["TARGET_CASE_VECTOR_PC_RELATIVE"]++
checked_options["arc_size_opt_level"]++
-# arm exceptions
-checked_options["arm_fp16_format"]++
-checked_options["flag_ipa_ra"]++
-# s390 exceptions
-checked_options["param_max_completely_peel_times"]++
-checked_options["param_max_completely_peeled_insns"]++
-checked_options["param_max_unroll_times"]++
-checked_options["param_max_unrolled_insns"]++
for (i = 0; i < n_opts; i++) {
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-05-13 8:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 14:12 [gcc(refs/users/marxin/heads/PR92860-global-opts-state-improvement)] Improve global state for options Martin Liska
2021-04-21 12:42 Martin Liska
2021-04-21 14:35 Martin Liska
2021-05-13 8:57 Martin Liska
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).