https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128960
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Uros Bizjak <[email protected]>: https://gcc.gnu.org/g:b399967afe8eca0690fd073b1d4d2cd684f417c2 commit r17-6629-gb399967afe8eca0690fd073b1d4d2cd684f417c2 Author: Uros Bizjak <[email protected]> Date: Mon Nov 23 22:01:01 2026 +0100 i386: Save explicit-set bits of target options [PR128960] -mstack-protector-guard=, -mstackrealign and -mbranch-cost= were declared as manual TargetSave entries, with hand-written copies in ix86_function_specific_save and ix86_function_specific_restore. That saves and restores their values, but not their explicit-set bits. ix86_valid_target_attribute_p restores the target options into a zeroed func_options_set, so ix86_option_override_internal sees these options as unset and resets them to the target defaults for functions with a target attribute. For example, a function declared with __attribute__((target("bmi2"))) silently loses -mstack-protector-guard=global and uses the TLS guard. Declare the options with Save instead. The generated cl_target_option_save and cl_target_option_restore then preserve both the value and the explicit-set bit, which also keeps them across LTO streaming. Assisted-by: Claude Sonnet 5.5 PR target/128960 gcc/ChangeLog: * config/i386/i386.opt (x_ix86_branch_cost) (x_ix86_force_align_arg_pointer, x_ix86_stack_protector_guard): Remove TargetSave entries. (mbranch-cost=, mstackrealign, mstack-protector-guard=): Add Save. * config/i386/i386-options.cc (ix86_function_specific_save) (ix86_function_specific_restore): Do not copy x_ix86_branch_cost, x_ix86_force_align_arg_pointer and x_ix86_stack_protector_guard. gcc/testsuite/ChangeLog: * gcc.target/i386/pr128960-1.c: New test. * gcc.target/i386/pr128960-2.c: Ditto.
