On Tue, May 6, 2025 at 2:04 PM H.J. Lu <hjl.to...@gmail.com> wrote: > > On Wed, May 7, 2025 at 12:29 AM Andi Kleen <a...@firstfloor.org> wrote: > > > > On 2025-05-06 09:48, H.J. Lu wrote: > > > On Mon, May 5, 2025 at 9:56 PM Andi Kleen <a...@firstfloor.org> 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. > > > > > > I can't try it right now, but since the RTL musttail checks are in RTL > > expand it is clear any RTL pass is too late. Put it into a target hook > > and call it from calls.cc when it expands sibcalls. At that point the > > sibcall discovery is already done so it will need less code too > > > > What does musttail check do? My patch doesn't remove sibcall. > I don't see how it impacts musttail check.
I think Andi is confused. This pass converts a conditional branch that has a bb that just does a tail call into a condition branch which does the tail call. E.g. ``` jne L1 ... L1: jmp func1 ``` into: ``` jne func1 ... ``` So saving one jump. tailcalls are already expanded into jumps at the point when this pass happens. It does NOT change a tail call into a non-tail call nor a non-tail call into a tail call. So it has nothing to do with musttail at all. Thanks, Andrew Pinski > > -- > H.J.