On Mon, May 5, 2025 at 9:56 PM Andi Kleen <[email protected]> wrote:
>
> On Mon, May 05, 2025 at 06:20:40AM -0700, Andi Kleen wrote:
> > > If the branch edge destination is a basic block with only a direct
> > > sibcall, change the jcc target to the sibcall target, decrement the
> > > destination basic block entry label use count and redirect the edge
> > > to the exit basic block. Call delete_unreachable_blocks to delete
> > > the unreachable basic blocks at the end if edges are redirected.
> >
> > Its hard to believe this needs a new pass. Could the existing middle end
> > tail call code handle it somehow?
>
> On further thought it absolutely needs to be in calls.c, otherwise it
> cannot work with musttail. Currently musttail would error out before
> this pass runs.
Do you have a testcase? Since this pass is run just before
pass_convert_to_eh_region_ranges, I think it should work with
musttail.
> > > + FOR_EACH_BB_FN (bb, cfun)
> > > + {
> > > + FOR_BB_INSNS (bb, insn)
> > > + {
> > > + if (!JUMP_P (insn))
> > > + continue;
> >
> > Instead of searching all basic blocks this could search from the end
> > simllar to tree tailcall
> >
> > > + /* opt_pass methods: */
> > > + bool gate (function *) final override
> > > + {
> > > + return optimize;
> >
> > Thia needs to depend on the existing tail call options. I would also
> > add a new option because it is highly likely to break some unwinders
> > and static asm analysis tools like Linux objtool.
>
> > Does the gcc unwinding
> > or gdb calltrace still work?
>
> It should be invisible to unwinders so that part is probably ok.
>
> Andi
--
H.J.