From 8ad9856bc69615557267604c1841f2a520dcf132 Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Sat, 16 Mar 2019 08:08:16 -0700 Subject: [PATCH] JIT: clear stub register assignment for tail calls via helper (#23288) When we have a VSD tail call via a helper, the stub arg is passed as a normal arg to the helper and moved to the right special register by the copy routine that the helper invokes. So the jit does not need to pass the stub value in the special register when calling the helper. The stub arg gets set to that register by default, so we now unset it for the tail call via helper case. Closes #18943. --- src/jit/morph.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp index 9d0193b..862b77a 100644 --- a/src/jit/morph.cpp +++ b/src/jit/morph.cpp @@ -7372,6 +7372,12 @@ void Compiler::fgMorphTailCall(GenTreeCall* call, void* pfnCopyArgs) if (call->IsVirtualStub()) { GenTree* stubAddrArg = fgGetStubAddrArg(call); + + // We don't need this arg to be in the normal stub register, so + // clear out the register assignment. + assert(stubAddrArg->gtRegNum == virtualStubParamInfo->GetReg()); + stubAddrArg->gtRegNum = REG_NA; + // And push the stub address onto the list of arguments call->gtCallArgs = gtNewListNode(stubAddrArg, call->gtCallArgs); } @@ -7606,6 +7612,12 @@ void Compiler::fgMorphTailCall(GenTreeCall* call, void* pfnCopyArgs) if (call->IsVirtualStub()) { GenTree* stubAddrArg = fgGetStubAddrArg(call); + + // We don't need this arg to be in the normal stub register, so + // clear out the register assignment. + assert(stubAddrArg->gtRegNum == virtualStubParamInfo->GetReg()); + stubAddrArg->gtRegNum = REG_NA; + // And push the stub address onto the list of arguments call->gtCallArgs = gtNewListNode(stubAddrArg, call->gtCallArgs); } -- 2.7.4