[PATCH] Don't caller-save pseudos across calls that may throw (PR rtl-optimization/23478)

Michael Matz matz@suse.de
Thu Sep 1 15:40:00 GMT 2005


Hi Jakub,

On Mon, 22 Aug 2005, Jakub Jelinek wrote:

> The testcase below is miscompiled on gcc-3_4-branch (but a different
> one could very well be miscompiled by 4.0 or HEAD).  The problem is
> that if global alloc decides to put a pseudo that crosses a call
> that can throw into a call used register, caller-save.c will save
> it to the stack and restore it after the call, but not on the
> EH edge as well.  For non-critical edge we perhaps could put it
> into the EH pad, but for critical abnormal edge we can't.

Hmm.  You deactivated allocating pseudos live over abnormal calls at all.  
Now they aren't even allocated to callee saved regs.  The question is, why
the code in global_conflicts() doesn't prevent this.  It already creates
conflicts between all pseudos live at the start of a BB reached by an
abnormal edge and all call_used_regs.  Alternatively you might just want
to change global.c:find_reg() to not try caller-saved registers in some
more situations than these:

      if (! accept_call_clobbered
          && allocno[num].calls_crossed != 0
          && CALLER_SAVE_PROFITABLE (allocno[num].n_refs,
                                     allocno[num].calls_crossed))
        {
          HARD_REG_SET new_losers;
          if (! losers)
            CLEAR_HARD_REG_SET (new_losers);
          else
            COPY_HARD_REG_SET (new_losers, losers);

          IOR_HARD_REG_SET(new_losers, losing_caller_save_reg_set);
          find_reg (num, new_losers, alt_regs_p, 1, retrying);
          if (reg_renumber[allocno[num].reg] >= 0)
            {
              caller_save_needed = 1;
              return;
            }
        }

Ciao,
Michael.



More information about the Gcc-patches mailing list