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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2025-04-13

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

Looks like it has always been a bug:

  for (reorg_pass_number = 0;
       reorg_pass_number < MAX_REORG_PASSES;
       reorg_pass_number++)
    {
      fill_simple_delay_slots (true);
      fill_simple_delay_slots (false);
      if (!targetm.no_speculation_in_delay_slots_p ())
        fill_eager_delay_slots ();
      relax_delay_slots (first);
    }

  /* If we made an end of function label, indicate that it is now
     safe to delete it by undoing our prior adjustment to LABEL_NUSES.
     If it is now unused, delete it.  */
  if (function_return_label && --LABEL_NUSES (function_return_label) == 0)
    delete_related_insns (function_return_label);
  if (function_simple_return_label
      && --LABEL_NUSES (function_simple_return_label) == 0)
    delete_related_insns (function_simple_return_label);

  need_return_insns = false;
  need_return_insns |= targetm.have_return () && function_return_label != 0;
  need_return_insns |= (targetm.have_simple_return ()
                        && function_simple_return_label != 0);
  if (need_return_insns)
    make_return_insns (first);


That is the return insns is filled outside of the normal "reorg_pass_number"
pass. So it was recording the statistics to the wrong element almost always.

Since this is just statistics, I doub't make a difference otherwise.

Note this bug has existed since reorg.c was added to the repo back in 1991
(r0-97-g9c7e297806a27f).

Reply via email to