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 PR rtl-optimization/42461


> This is a missed optimization due the EH rewrite from last year: the RTL DCE 
> pass doesn't eliminate calls to pure/const functions any longer.
> 
> Tested on x86_64-suse-linux.  I'd like to put this on the 4.5 branch as well, 
> any objections from RMs?

Hi,
I noticed the patch as a result of my oprofiling, fast_dce disappeared from top of profile for me ;)

However I think we are wrong here.  CONST/PURE functions are a allowed to throw unless they are
declared NOTHORW.

I think the problem is in insn_nothrow_p.

It is implemented using:

  return get_eh_region_and_lp_from_rtx (insn, &r, &lp);

that leads to:

static bool
get_eh_region_and_lp_from_rtx (const_rtx insn, eh_region *pr,
                               eh_landing_pad *plp)
{
  eh_landing_pad lp = NULL;
  eh_region r = NULL;
  bool ret = false;
  rtx note;
  int lp_nr;

  if (! INSN_P (insn))
    goto egress;

  if (NONJUMP_INSN_P (insn)
      && GET_CODE (PATTERN (insn)) == SEQUENCE)
    insn = XVECEXP (PATTERN (insn), 0, 0);

  note = find_reg_note (insn, REG_EH_REGION, NULL_RTX);
  if (!note)
    { 
      ret = !insn_could_throw_p (insn);
      goto egress;
    }

that finally leads to:

/* Return true if INSN could throw, assuming no REG_EH_REGION note
   to the contrary.  */

bool
insn_could_throw_p (const_rtx insn)
{
  if (!flag_exceptions)
    return false;
  if (CALL_P (insn))
    return true;

this is not correct, we are missing NOTHROW here.  Traditionally we detected if
function can or can not thorw by presence/absence of EH note.  This has
changed?

Honza


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