> 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? Each new pass makes the compiler a little slower. > + 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? Andi