This is the mail archive of the gcc-bugs@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]

[Bug target/66215] [4.8/4.9/5/6 Regression] Wrong after label NOP emission for -mhotpatch


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

--- Comment #16 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The function I've mentioned has:
(note 1 0 3 NOTE_INSN_DELETED)
(note 3 1 12 [bb 2] NOTE_INSN_BASIC_BLOCK)
(note 12 3 2 NOTE_INSN_PROLOGUE_END)
(note 2 12 5 NOTE_INSN_FUNCTION_BEG)
(barrier 5 2 8)
(note 8 5 0 NOTE_INSN_DELETED)
(at least in my somewhat older trunk version).
I can't think of anything simpler than that, because if the function isn't
noreturn, it shall have at least a return insn at the end, and if it is
noreturn, but doesn't have __builtin_unreachable () in it, there should be
either an endless loop (so some jump_insn), or noreturn call (call_insn).
Though, thinking about it, if you only have notes at the beginning and then
some CODE_LABEL, adding the nops after the CODE_LABEL would result in running
the nops not just when entering the function the first time, but more often.
Thus, I'd suggest maybe:
for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
  if (active_insn_p (insn)
      || BARRIER_P (insn)
      || LABEL_P (insn))
    break;
Thus, put the nops before first of active insns, barrier (that one for the
__builtin_unreachable () case) and the last one for e.g.:
void
baz (volatile unsigned int *i)
{
  for (;;)
    (*i)++;
}
where I guess hotpatching wouldn't really like to see this as running the
function many times.


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