JIT: clear stub register assignment for tail calls via helper (#23288)
authorAndy Ayers <andya@microsoft.com>
Sat, 16 Mar 2019 15:08:16 +0000 (08:08 -0700)
committerGitHub <noreply@github.com>
Sat, 16 Mar 2019 15:08:16 +0000 (08:08 -0700)
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

index 9d0193b..862b77a 100644 (file)
@@ -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);
     }