[Mips] Permit tail calls on the R3000A (PS2-184) #10
Loading…
Reference in a new issue
No description provided.
Delete branch "r3000a-tail-calls"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacked on #9 (which is stacked on #8); the diff against
r5900-eeincludes their commits until those merge.GCC turns a call in tail position into a jump (
jr $25/j callee) when the callee's arguments fit in the caller's incoming argument area. LLVM's MIPS backend disables tail calls by default (mips-tail-calls, because of $gp handling in position independent code), so a wrapper that forwards its arguments keeps them in callee-saved registers across a normal call, needing a frame plus a save and restore for each.A new
tail-callssubtarget feature, implied byr3000aonly, turns tail calls on. For a CPU with the feature and no SVR4 abicalls the callee no longer has to be DSO-local, since there is no $gp to restore. Other CPUs are unchanged (the existingtailcall.lltest passes unmodified); themips-tail-callsoption still overrides the feature either way. Test:CodeGen/Mips/r3000a-tail-calls.ll.Results (-Os/-Oz): sdk-core IOP modules at -Oz 57,808 -> 56,836 bytes (-1.7%, +9.5% -> +7.6% over GCC). RiptOPL IOP modules at -Oz: the 46 IRX files 684,894 -> 681,166 (-0.5%), now +4.7% over GCC's 650,850. Each forwarding wrapper loses its frame and its register saves.
Tested
iopfixup --irx1.🤖 Generated with Claude Code