https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83994
Bug ID: 83994 Summary: %ebx is clobbered by stack-clash probing for regparm-3 function in PIC mode Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: fw at gcc dot gnu.org Target Milestone: --- Target: i686 Created attachment 43219 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43219&action=edit regparm-3-pic-probe.c The attached reproducer, when compiled with -O2 -m32 -march=i686 -fpic -fstack-clash-protection, clobbers %ebx in PIC mode due to the probing at the start of the function. (Seen on trunk@25693.) The comment on get_scratch_register_on_entry says: /* Return a short-lived scratch register for use on function entry. In 32-bit mode, it is valid only after the registers are saved in the prologue. This register must be released by means of release_scratch_register_on_entry once it is dead. */ This is called from ix86_adjust_stack_and_probe_stack_clash, but in the reproducer, this happens when int_registers_saved is still false in ix86_expand_prologue. It seems that in this case, ix86_save_reg cannot be used to select a register which is save to clobber.