kavon/ghc-llvm

register choices for tail calls

Opened this issue · 0 comments

kavon commented

One of the poor register choices made by LLVM for the function pointer in a tail call is due to not updating X86RegisterInfo::getGPRsForTailCall for the GHC calling convention. the GR64_TC register class is specialized to C conventions:

// in X86InstrInfo.td
// GPRs available for tailcall.
// It represents GR32_TC, GR64_TC or GR64_TCW64.
def ptr_rc_tailcall : PointerLikeRegClass<4>;  // the 4 corresponds to the Kind in X86RegisterInfo::getPointerRegClass
// in X86RegisterInfo.td
def GR64_TC   : RegisterClass<"X86", [i64], 64, (add RAX, RCX, RDX, RSI, RDI,
                                                     R8, R9, R11, RIP)>;

See if you can dig around further and try to improve other register choices made?