Skip to content

Commit

Permalink
JIT: don't optimize calls to CORINFO_HELP_VIRTUAL_FUNC_PTR
Browse files Browse the repository at this point in the history
The jit currently replaces calls to `CORINFO_HELP_VIRTUAL_FUNC_PTR`
whose results are unused with null pointer checks.

But this helper can now throw a variety of exceptions, so this
optimization is incorrect.

Fixes dotnet#82127.
  • Loading branch information
AndyAyersMS committed Feb 15, 2023
1 parent eb6f712 commit d5d98d7
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7802,25 +7802,6 @@ GenTree* Compiler::fgMorphCall(GenTreeCall* call)
#endif
}

if ((call->gtCallMoreFlags & GTF_CALL_M_SPECIAL_INTRINSIC) == 0 &&
(call->gtCallMethHnd == eeFindHelper(CORINFO_HELP_VIRTUAL_FUNC_PTR)
#ifdef FEATURE_READYTORUN
|| call->gtCallMethHnd == eeFindHelper(CORINFO_HELP_READYTORUN_VIRTUAL_FUNC_PTR)
#endif
) &&
(call == fgMorphStmt->GetRootNode()))
{
// This is call to CORINFO_HELP_VIRTUAL_FUNC_PTR with ignored result.
// Transform it into a null check.

assert(call->gtArgs.CountArgs() >= 1);
GenTree* objPtr = call->gtArgs.GetArgByIndex(0)->GetNode();

GenTree* nullCheck = gtNewNullCheck(objPtr, compCurBB);

return fgMorphTree(nullCheck);
}

noway_assert(call->gtOper == GT_CALL);

//
Expand Down

0 comments on commit d5d98d7

Please sign in to comment.