Save explicit-set bits of i386 target options
GCC now correctly saves explicit-set bits for i386 target options, fixing issues with target attributes.
This commit resolves an issue in GCC where explicit settings for certain i386 target options were not being preserved correctly when function-specific target attributes were applied. Options like -mstack-protector-guard and -mbranch-cost were previously saved only by value, not by their ‘explicit-set’ status. This caused functions with target attributes to revert to default options unexpectedly. By using the Save directive instead of manual copying, both the value and the explicit-set bit are now preserved, ensuring consistent behavior across LTO streaming and function attributes.
In Details
This commit modifies the i386 target option handling in GCC. Previously, options like -mstack-protector-guard, -mstackrealign, and -mbranch-cost were managed using manual TargetSave entries, with their values copied in ix86_function_specific_save/restore. However, this mechanism failed to preserve the explicit-set bits of these options. Consequently, when a function attribute like __attribute__((target("bmi2"))) was used, ix86_option_override_internal would see these options as unset and re-apply target defaults, overriding user settings. By changing these options to use the g…
- target attribute
- A function attribute in GCC that allows specifying different compiler options for a particular function than those used for the rest of the compilation unit. For example,
__attribute__((target("arch=sandybridge"))). - explicit-set bits
- Internal compiler flags that indicate whether a particular compiler option was explicitly set by the user on the command line or in code, as opposed to being a default value or a value inherited from a broader context.
- LTO
- Link-Time Optimization. A compilation technique where optimization is performed across multiple source files during the linking stage, allowing for more global optimizations than traditional whole-program optimization.
- i386
- The original 32-bit x86 instruction set architecture developed by Intel. GCC's i386 backend handles compilation for processors implementing this architecture and its extensions.