Hi, this is (very likely partial) fix for PR92860 where optimize attribute incorrectly rewrites flag_toplevel_reorder which we handle as global flag. In fact we support per-symbol toplevel reordering for a while so we only need to add the annotation. However we need to inspect all other flags implied by optimize that they have Optimization attribute on them.
Also i think this should be backoported to release branches, but it breaks LTO streaming compaibility. Bootstrapped/regtested x86_64-linux, comitted. PR tree-optimization/92860 * common.opt (fprofile-reorder-functions, ftoplevel-reorder): Add Optimization flag. Index: common.opt =================================================================== --- common.opt (revision 279076) +++ common.opt (working copy) @@ -2181,7 +2181,7 @@ Common Report Var(profile_report) Report on consistency of profile. fprofile-reorder-functions -Common Report Var(flag_profile_reorder_functions) +Common Report Var(flag_profile_reorder_functions) Optimization Enable function reordering that improves code placement. fpatchable-function-entry= @@ -2586,7 +2586,7 @@ EnumValue Enum(tls_model) String(local-exec) Value(TLS_MODEL_LOCAL_EXEC) ftoplevel-reorder -Common Report Var(flag_toplevel_reorder) Init(2) +Common Report Var(flag_toplevel_reorder) Init(2) Optimization Reorder top level functions, variables, and asms. ftracer