This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix PR44281 (bad RA with global regs)


On 02/29/2016 06:07 PM, Michael Matz wrote:

%rbx would have to be implicitly used/clobbered by the asm.  In addition
it would have to be used by all function entries and exits (so that a
function body where the global reg var is merely visible but not used
doesn't accidentally clobber that register) and of course by calls.

Nearly all this exists as of today. From df-scan.c:

static void
df_get_call_refs (struct df_collection_rec *collection_rec,
[...]
      else if (global_regs[i])
        {
/* Calls to const functions cannot access any global registers and
             calls to pure functions cannot set them.  All other calls may
             reference any of the global registers, so they are recorded as
             used. */
          if (!RTL_CONST_CALL_P (insn_info->insn))

and

static void
df_get_entry_block_def_set (bitmap entry_block_defs)
{
[...]
  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    {
      if (global_regs[i])
        bitmap_set_bit (entry_block_defs, i);

and

  /* Mark all global registers, and all registers used by the
     epilogue as being live at the end of the function since they
     may be referenced by our caller.  */
  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
    if (global_regs[i] || EPILOGUE_USES (i))
      bitmap_set_bit (exit_block_uses, i);

FWIW: signal handlers need no consideration (if they were allowed to
inspect/alter global reg vars we would have lost and no improvement on
fixed_regs[] could be done).  They are explicitely documented to not be
able to access global reg vars.  (They already can't accidentally clobber
the register in question because signal handlers don't do that)

Oh, they can't modify the register in question because the OS would restore it? Hadn't thought of that.

Ok so maybe reopen and apply my patch for gcc-7, with a tweak for asms.


Bernd


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]