https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81861

--- Comment #6 from Maxim Ostapenko <m.ostapenko at samsung dot com> ---
Created attachment 41990
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41990&action=edit
Untested fix

The problem is that LTO doesn't propagate changed
ix86_stack_protector_guard_reg value:

 6654   /* Save the initial options in case the user does function specific
 6655      options.  */
 6656   if (main_args_p)
 6657     target_option_default_node = target_option_current_node
 6658       = build_target_option_node (opts);         <== save flags
 6659 
...
 6695   ix86_stack_protector_guard_reg = DEFAULT_TLS_SEG_REG;  <== missed
change

Thus ix86_stack_protector_guard_reg becomes left ADDR_SPACE_GENERIC in ltrans
stage that confuses optimizer later (wrong constant propagation in this case).

Moving options saving down fixes the issue, although I'm not sure this is a
correct fix.

Reply via email to