From b2b199a1674cc70b19bb47ae8917c3a9e39086b3 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Wed, 29 May 2024 15:17:58 -0700 Subject: [PATCH] Flow the CORINFO_CONST_LOOKUP down to the GenTreeIntrinsic/GenTreeHWIntrinsic creation sites --- src/coreclr/inc/utilcode.h | 6 ++ src/coreclr/jit/compiler.h | 12 ++-- src/coreclr/jit/gentree.cpp | 35 +++-------- src/coreclr/jit/gentree.h | 24 ++++--- src/coreclr/jit/hwintrinsic.cpp | 7 ++- src/coreclr/jit/hwintrinsicarm64.cpp | 5 +- src/coreclr/jit/hwintrinsicxarch.cpp | 47 ++++++++------ src/coreclr/jit/importercalls.cpp | 94 ++++++++++++---------------- src/coreclr/jit/lsra.cpp | 22 +++++-- 9 files changed, 131 insertions(+), 121 deletions(-) diff --git a/src/coreclr/inc/utilcode.h b/src/coreclr/inc/utilcode.h index 53e4b2bb0fe977..23680253c70ae2 100644 --- a/src/coreclr/inc/utilcode.h +++ b/src/coreclr/inc/utilcode.h @@ -166,6 +166,12 @@ typedef LPSTR LPUTF8; #define DEBUGARG(x) #endif +#if defined(FEATURE_READYTORUN) +#define R2RARG(x) , x +#else +#define R2RARG(x) +#endif + #ifndef sizeofmember // Returns the size of a class or struct member. #define sizeofmember(c,m) (sizeof(((c*)0)->m)) diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 96c8c2b500bbfa..cb1e459c949e07 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -4531,7 +4531,8 @@ class Compiler bool tailCall, bool callvirt, CORINFO_RESOLVED_TOKEN* pContstrainedResolvedToken, - CORINFO_THIS_TRANSFORM constraintCallThisTransform, + CORINFO_THIS_TRANSFORM constraintCallThisTransform + R2RARG(CORINFO_CONST_LOOKUP* entryPoint), NamedIntrinsic* pIntrinsicName, bool* isSpecialIntrinsic = nullptr); GenTree* impEstimateIntrinsic(CORINFO_METHOD_HANDLE method, @@ -4540,7 +4541,8 @@ class Compiler NamedIntrinsic intrinsicName, bool mustExpand); GenTree* impMathIntrinsic(CORINFO_METHOD_HANDLE method, - CORINFO_SIG_INFO* sig, + CORINFO_SIG_INFO* sig + R2RARG(CORINFO_CONST_LOOKUP* entryPoint), var_types callType, NamedIntrinsic intrinsicName, bool tailCall); @@ -4576,7 +4578,8 @@ class Compiler GenTree* impHWIntrinsic(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, - CORINFO_SIG_INFO* sig, + CORINFO_SIG_INFO* sig + R2RARG(CORINFO_CONST_LOOKUP* entryPoint), bool mustExpand); GenTree* impSimdAsHWIntrinsic(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, @@ -4600,7 +4603,8 @@ class Compiler GenTree* impSpecialIntrinsic(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, - CORINFO_SIG_INFO* sig, + CORINFO_SIG_INFO* sig + R2RARG(CORINFO_CONST_LOOKUP* entryPoint), CorInfoType simdBaseJitType, var_types retType, unsigned simdSize, diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 53a1a877d6b717..950629f9a2c166 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -9635,10 +9635,8 @@ GenTree* Compiler::gtCloneExpr(GenTree* tree) case GT_INTRINSIC: copy = new (this, GT_INTRINSIC) GenTreeIntrinsic(tree->TypeGet(), tree->AsOp()->gtOp1, tree->AsOp()->gtOp2, - tree->AsIntrinsic()->gtIntrinsicName, tree->AsIntrinsic()->gtMethodHandle); -#ifdef FEATURE_READYTORUN - copy->AsIntrinsic()->gtEntryPoint = tree->AsIntrinsic()->gtEntryPoint; -#endif + tree->AsIntrinsic()->gtIntrinsicName, + tree->AsIntrinsic()->gtMethodHandle R2RARG(tree->AsIntrinsic()->gtEntryPoint)); break; case GT_BOUNDS_CHECK: @@ -9723,7 +9721,8 @@ GenTree* Compiler::gtCloneExpr(GenTree* tree) if (tree->AsHWIntrinsic()->IsUserCall()) { - copy->AsHWIntrinsic()->SetMethodHandle(this, tree->AsHWIntrinsic()->GetMethodHandle()); + copy->AsHWIntrinsic()->SetMethodHandle(this, tree->AsHWIntrinsic()->GetMethodHandle() + R2RARG(tree->AsHWIntrinsic()->GetEntryPoint())); } goto CLONE_MULTIOP_OPERANDS; #endif @@ -19591,13 +19590,15 @@ void GenTreeMultiOp::InitializeOperands(GenTree** operands, size_t operandCount) // Arguments: // comp - The compiler instance // methodHandle - The method handle representing the fallback handling for the intrinsic +// entryPoint - The entry point information required for R2R scenarios // // Notes: // We need to ensure that the operands are not tracked inline so that we can track the // underlying method handle. See the comment in GenTreeJitIntrinsic around why the union // of fields exists. // -void GenTreeJitIntrinsic::SetMethodHandle(Compiler* comp, CORINFO_METHOD_HANDLE methodHandle) +void GenTreeJitIntrinsic::SetMethodHandle(Compiler* comp, + CORINFO_METHOD_HANDLE methodHandle R2RARG(CORINFO_CONST_LOOKUP entryPoint)) { assert(OperIsHWIntrinsic() && !IsUserCall()); gtFlags |= GTF_HW_USER_CALL; @@ -19619,31 +19620,11 @@ void GenTreeJitIntrinsic::SetMethodHandle(Compiler* comp, CORINFO_METHOD_HANDLE } gtMethodHandle = methodHandle; - gtEntryPoint = nullptr; -} #if defined(FEATURE_READYTORUN) -//------------------------------------------------------------------------ -// GenTreeJitIntrinsic::SetEntryPoint: Sets the entry point for an intrinsic -// so that it can be rewritten back to a user call in a later phase for R2R -// scenarios -// -// Arguments: -// comp - The compiler instance -// entryPoint - The entry point information required for R2R scenarios -// -// Notes: -// This requires SetMethodHandle to have been called first to ensure we aren't -// overwriting any inline operands -// -void GenTreeJitIntrinsic::SetEntryPoint(Compiler* comp, CORINFO_CONST_LOOKUP entryPoint) -{ - assert(IsUserCall()); - assert(gtEntryPoint == nullptr); - gtEntryPoint = new (comp, CMK_ASTNode) CORINFO_CONST_LOOKUP(entryPoint); -} #endif // FEATURE_READYTORUN +} var_types GenTreeJitIntrinsic::GetAuxiliaryType() const { diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index ad77714cfd16bd..578b2f43b349be 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -5952,24 +5952,30 @@ struct GenTreeIntrinsic : public GenTreeOp NamedIntrinsic gtIntrinsicName; CORINFO_METHOD_HANDLE gtMethodHandle; // Method handle of the method which is treated as an intrinsic. -#ifdef FEATURE_READYTORUN +#if defined(FEATURE_READYTORUN) // Call target lookup info for method call from a Ready To Run module CORINFO_CONST_LOOKUP gtEntryPoint; -#endif +#endif // FEATURE_READYTORUN - GenTreeIntrinsic(var_types type, GenTree* op1, NamedIntrinsic intrinsicName, CORINFO_METHOD_HANDLE methodHandle) + GenTreeIntrinsic(var_types type, + GenTree* op1, + NamedIntrinsic intrinsicName, + CORINFO_METHOD_HANDLE methodHandle R2RARG(CORINFO_CONST_LOOKUP entryPoint)) : GenTreeOp(GT_INTRINSIC, type, op1, nullptr) , gtIntrinsicName(intrinsicName) - , gtMethodHandle(methodHandle) + , gtMethodHandle(methodHandle) R2RARG(gtEntryPoint(entryPoint)) { assert(intrinsicName != NI_Illegal); } - GenTreeIntrinsic( - var_types type, GenTree* op1, GenTree* op2, NamedIntrinsic intrinsicName, CORINFO_METHOD_HANDLE methodHandle) + GenTreeIntrinsic(var_types type, + GenTree* op1, + GenTree* op2, + NamedIntrinsic intrinsicName, + CORINFO_METHOD_HANDLE methodHandle R2RARG(CORINFO_CONST_LOOKUP entryPoint)) : GenTreeOp(GT_INTRINSIC, type, op1, op2) , gtIntrinsicName(intrinsicName) - , gtMethodHandle(methodHandle) + , gtMethodHandle(methodHandle) R2RARG(gtEntryPoint(entryPoint)) { assert(intrinsicName != NI_Illegal); } @@ -6264,7 +6270,7 @@ struct GenTreeJitIntrinsic : public GenTreeMultiOp return gtMethodHandle; } - void SetMethodHandle(Compiler* comp, CORINFO_METHOD_HANDLE methodHandle); + void SetMethodHandle(Compiler* comp, CORINFO_METHOD_HANDLE methodHandle R2RARG(CORINFO_CONST_LOOKUP entryPoint)); #if defined(FEATURE_READYTORUN) CORINFO_CONST_LOOKUP GetEntryPoint() const @@ -6272,8 +6278,6 @@ struct GenTreeJitIntrinsic : public GenTreeMultiOp assert(IsUserCall()); return *gtEntryPoint; } - - void SetEntryPoint(Compiler* comp, CORINFO_CONST_LOOKUP entryPoint); #endif // FEATURE_READYTORUN //----------------------------------------------------------- diff --git a/src/coreclr/jit/hwintrinsic.cpp b/src/coreclr/jit/hwintrinsic.cpp index dff528d5d5c91d..a7bbc623902706 100644 --- a/src/coreclr/jit/hwintrinsic.cpp +++ b/src/coreclr/jit/hwintrinsic.cpp @@ -1131,6 +1131,7 @@ bool Compiler::CheckHWIntrinsicImmRange(NamedIntrinsic intrinsic, // clsHnd -- class handle containing the intrinsic function. // method -- method handle of the intrinsic function. // sig -- signature of the intrinsic call +// entryPoint -- The entry point information required for R2R scenarios // mustExpand -- true if the intrinsic must return a GenTree*; otherwise, false // Return Value: @@ -1139,7 +1140,7 @@ bool Compiler::CheckHWIntrinsicImmRange(NamedIntrinsic intrinsic, GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, - CORINFO_SIG_INFO* sig, + CORINFO_SIG_INFO* sig R2RARG(CORINFO_CONST_LOOKUP* entryPoint), bool mustExpand) { // NextCallRetAddr requires a CALL, so return nullptr. @@ -1577,8 +1578,8 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, } else { - retNode = - impSpecialIntrinsic(intrinsic, clsHnd, method, sig, simdBaseJitType, nodeRetType, simdSize, mustExpand); + retNode = impSpecialIntrinsic(intrinsic, clsHnd, method, sig R2RARG(entryPoint), simdBaseJitType, nodeRetType, + simdSize, mustExpand); } #if defined(TARGET_ARM64) diff --git a/src/coreclr/jit/hwintrinsicarm64.cpp b/src/coreclr/jit/hwintrinsicarm64.cpp index 60f2cbbd775ae9..aca047b7342637 100644 --- a/src/coreclr/jit/hwintrinsicarm64.cpp +++ b/src/coreclr/jit/hwintrinsicarm64.cpp @@ -482,6 +482,7 @@ GenTree* Compiler::impNonConstFallback(NamedIntrinsic intrinsic, var_types simdT // clsHnd -- class handle containing the intrinsic function. // method -- method handle of the intrinsic function. // sig -- signature of the intrinsic call. +// entryPoint -- The entry point information required for R2R scenarios // simdBaseJitType -- generic argument of the intrinsic. // retType -- return type of the intrinsic. // mustExpand -- true if the intrinsic must return a GenTree*; otherwise, false @@ -492,7 +493,7 @@ GenTree* Compiler::impNonConstFallback(NamedIntrinsic intrinsic, var_types simdT GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, - CORINFO_SIG_INFO* sig, + CORINFO_SIG_INFO* sig R2RARG(CORINFO_CONST_LOOKUP* entryPoint), CorInfoType simdBaseJitType, var_types retType, unsigned simdSize, @@ -1876,7 +1877,7 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, retNode = gtNewSimdHWIntrinsicNode(retType, op1, op2, intrinsic, simdBaseJitType, simdSize); - retNode->AsHWIntrinsic()->SetMethodHandle(this, method); + retNode->AsHWIntrinsic()->SetMethodHandle(this, method R2RARG(*entryPoint)); break; } diff --git a/src/coreclr/jit/hwintrinsicxarch.cpp b/src/coreclr/jit/hwintrinsicxarch.cpp index bfcf81913f7054..039fc3a3d3c816 100644 --- a/src/coreclr/jit/hwintrinsicxarch.cpp +++ b/src/coreclr/jit/hwintrinsicxarch.cpp @@ -955,6 +955,7 @@ GenTree* Compiler::impNonConstFallback(NamedIntrinsic intrinsic, var_types simdT // clsHnd -- class handle containing the intrinsic function. // method -- method handle of the intrinsic function. // sig -- signature of the intrinsic call. +// entryPoint -- The entry point information required for R2R scenarios // simdBaseJitType -- generic argument of the intrinsic. // retType -- return type of the intrinsic. // mustExpand -- true if the intrinsic must return a GenTree*; otherwise, false @@ -965,7 +966,7 @@ GenTree* Compiler::impNonConstFallback(NamedIntrinsic intrinsic, var_types simdT GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, - CORINFO_SIG_INFO* sig, + CORINFO_SIG_INFO* sig R2RARG(CORINFO_CONST_LOOKUP* entryPoint), CorInfoType simdBaseJitType, var_types retType, unsigned simdSize, @@ -986,6 +987,13 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, assert(varTypeIsArithmetic(simdBaseType)); } +#if defined(FEATURE_READYTORUN) + CORINFO_CONST_LOOKUP emptyEntryPoint; + + emptyEntryPoint.addr = nullptr; + emptyEntryPoint.accessType = IAT_VALUE; +#endif // FEATURE_READYTORUN + switch (intrinsic) { case NI_Vector128_Abs: @@ -1100,8 +1108,8 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, if (vectorTByteLength == YMM_REGSIZE_BYTES) { // Vector is TYP_SIMD32, so we should treat this as a call to Vector128.ToVector256 - return impSpecialIntrinsic(NI_Vector128_ToVector256, clsHnd, method, sig, simdBaseJitType, retType, - simdSize, mustExpand); + return impSpecialIntrinsic(NI_Vector128_ToVector256, clsHnd, method, sig R2RARG(&emptyEntryPoint), + simdBaseJitType, retType, simdSize, mustExpand); } else if (vectorTByteLength == XMM_REGSIZE_BYTES) { @@ -1210,8 +1218,8 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, case TYP_SIMD32: { // Vector is TYP_SIMD32, so we should treat this as a call to Vector256.GetLower - return impSpecialIntrinsic(NI_Vector256_GetLower, clsHnd, method, sig, simdBaseJitType, retType, - simdSize, mustExpand); + return impSpecialIntrinsic(NI_Vector256_GetLower, clsHnd, method, sig R2RARG(&emptyEntryPoint), + simdBaseJitType, retType, simdSize, mustExpand); } default: @@ -1250,14 +1258,15 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, if (intrinsic == NI_Vector256_AsVector) { - return impSpecialIntrinsic(NI_Vector256_GetLower, clsHnd, method, sig, simdBaseJitType, retType, - simdSize, mustExpand); + return impSpecialIntrinsic(NI_Vector256_GetLower, clsHnd, method, sig R2RARG(&emptyEntryPoint), + simdBaseJitType, retType, simdSize, mustExpand); } else { assert(intrinsic == NI_Vector256_AsVector256); - return impSpecialIntrinsic(NI_Vector128_ToVector256, clsHnd, method, sig, simdBaseJitType, - retType, 16, mustExpand); + return impSpecialIntrinsic(NI_Vector128_ToVector256, clsHnd, method, + sig R2RARG(&emptyEntryPoint), simdBaseJitType, retType, 16, + mustExpand); } } } @@ -1283,14 +1292,14 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, if (intrinsic == NI_Vector512_AsVector) { - return impSpecialIntrinsic(NI_Vector512_GetLower, clsHnd, method, sig, simdBaseJitType, retType, - simdSize, mustExpand); + return impSpecialIntrinsic(NI_Vector512_GetLower, clsHnd, method, sig R2RARG(&emptyEntryPoint), + simdBaseJitType, retType, simdSize, mustExpand); } else { assert(intrinsic == NI_Vector512_AsVector512); - return impSpecialIntrinsic(NI_Vector256_ToVector512, clsHnd, method, sig, simdBaseJitType, retType, - 32, mustExpand); + return impSpecialIntrinsic(NI_Vector256_ToVector512, clsHnd, method, sig R2RARG(&emptyEntryPoint), + simdBaseJitType, retType, 32, mustExpand); } break; } @@ -1303,14 +1312,16 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, if (intrinsic == NI_Vector512_AsVector) { - return impSpecialIntrinsic(NI_Vector512_GetLower128, clsHnd, method, sig, simdBaseJitType, - retType, simdSize, mustExpand); + return impSpecialIntrinsic(NI_Vector512_GetLower128, clsHnd, method, + sig R2RARG(&emptyEntryPoint), simdBaseJitType, retType, simdSize, + mustExpand); } else { assert(intrinsic == NI_Vector512_AsVector512); - return impSpecialIntrinsic(NI_Vector128_ToVector512, clsHnd, method, sig, simdBaseJitType, - retType, 16, mustExpand); + return impSpecialIntrinsic(NI_Vector128_ToVector512, clsHnd, method, + sig R2RARG(&emptyEntryPoint), simdBaseJitType, retType, 16, + mustExpand); } } } @@ -2897,7 +2908,7 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, retNode = gtNewSimdHWIntrinsicNode(retType, op1, op2, intrinsic, simdBaseJitType, simdSize); - retNode->AsHWIntrinsic()->SetMethodHandle(this, method); + retNode->AsHWIntrinsic()->SetMethodHandle(this, method R2RARG(*entryPoint)); break; } diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index 0b0a271c769479..2c277469a3648a 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -228,9 +228,23 @@ var_types Compiler::impImportCall(OPCODE opcode, const bool isTailCall = canTailCall && (tailCallFlags != 0); +#if defined(FEATURE_READYTORUN) + CORINFO_CONST_LOOKUP entryPoint; + + if (opts.IsReadyToRun() && (callInfo->kind == CORINFO_CALL)) + { + entryPoint = callInfo->codePointerLookup.constLookup; + } + else + { + entryPoint.addr = nullptr; + entryPoint.accessType = IAT_VALUE; + } +#endif // FEATURE_READYTORUN + call = impIntrinsic(newobjThis, clsHnd, methHnd, sig, mflags, pResolvedToken, isReadonlyCall, isTailCall, - opcode == CEE_CALLVIRT, pConstrainedResolvedToken, callInfo->thisTransform, &ni, - &isSpecialIntrinsic); + opcode == CEE_CALLVIRT, pConstrainedResolvedToken, + callInfo->thisTransform R2RARG(&entryPoint), &ni, &isSpecialIntrinsic); if (compDonotInline()) { @@ -239,44 +253,6 @@ var_types Compiler::impImportCall(OPCODE opcode, if (call != nullptr) { -#if defined(FEATURE_READYTORUN) - if (call->OperGet() == GT_INTRINSIC) - { - if (opts.IsReadyToRun()) - { - noway_assert(callInfo->kind == CORINFO_CALL); - call->AsIntrinsic()->gtEntryPoint = callInfo->codePointerLookup.constLookup; - } - else - { - call->AsIntrinsic()->gtEntryPoint.addr = nullptr; - call->AsIntrinsic()->gtEntryPoint.accessType = IAT_VALUE; - } - } -#if defined(FEATURE_HW_INTRINSICS) - else if (call->OperIsHWIntrinsic()) - { - if (call->AsHWIntrinsic()->IsUserCall()) - { - CORINFO_CONST_LOOKUP entryPoint; - - if (opts.IsReadyToRun()) - { - noway_assert(callInfo->kind == CORINFO_CALL); - entryPoint = callInfo->codePointerLookup.constLookup; - } - else - { - entryPoint.addr = nullptr; - entryPoint.accessType = IAT_VALUE; - } - - call->AsHWIntrinsic()->SetEntryPoint(this, entryPoint); - } - } -#endif // FEATURE_HW_INTRINSICS -#endif // FEATURE_READYTORUN - bIntrinsicImported = true; goto DONE_CALL; } @@ -2853,6 +2829,7 @@ GenTree* Compiler::impCreateSpanIntrinsic(CORINFO_SIG_INFO* sig) // pConstrainedResolvedToken -- resolved token for constrained call, or nullptr // if call is not constrained // constraintCallThisTransform -- this transform to apply for a constrained call +// entryPoint - The entry point information required for R2R scenarios // pIntrinsicName [OUT] -- intrinsic name (see enumeration in namedintrinsiclist.h) // for "traditional" jit intrinsics // isSpecialIntrinsic [OUT] -- set true if intrinsic expansion is a call @@ -2894,9 +2871,10 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, bool tailCall, bool callvirt, CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken, - CORINFO_THIS_TRANSFORM constraintCallThisTransform, - NamedIntrinsic* pIntrinsicName, - bool* isSpecialIntrinsic) + CORINFO_THIS_TRANSFORM constraintCallThisTransform + R2RARG(CORINFO_CONST_LOOKUP* entryPoint), + NamedIntrinsic* pIntrinsicName, + bool* isSpecialIntrinsic) { bool mustExpand = false; bool isSpecial = false; @@ -3090,7 +3068,7 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, } } - GenTree* hwintrinsic = impHWIntrinsic(ni, clsHnd, method, sig, mustExpand); + GenTree* hwintrinsic = impHWIntrinsic(ni, clsHnd, method, sig R2RARG(entryPoint), mustExpand); if (mustExpand && (hwintrinsic == nullptr)) { @@ -3377,7 +3355,7 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, else { // op1 is not a known constant, we'll do the expansion in morph - retNode = new (this, GT_INTRINSIC) GenTreeIntrinsic(TYP_INT, op1, ni, method); + retNode = new (this, GT_INTRINSIC) GenTreeIntrinsic(TYP_INT, op1, ni, method R2RARG(*entryPoint)); JITDUMP("\nConverting RuntimeHelpers.IsKnownConstant to:\n"); DISPTREE(retNode); } @@ -4085,7 +4063,7 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, case NI_System_Math_Log2: case NI_System_Math_Log10: { - retNode = impMathIntrinsic(method, sig, callType, ni, tailCall); + retNode = impMathIntrinsic(method, sig R2RARG(entryPoint), callType, ni, tailCall); break; } @@ -4178,7 +4156,7 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, case NI_System_Math_Tanh: case NI_System_Math_Truncate: { - retNode = impMathIntrinsic(method, sig, callType, ni, tailCall); + retNode = impMathIntrinsic(method, sig R2RARG(entryPoint), callType, ni, tailCall); break; } @@ -4274,7 +4252,8 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, { JITDUMP("Expanding as special intrinsic\n"); impPopStack(); - op1 = new (this, GT_INTRINSIC) GenTreeIntrinsic(genActualType(callType), op1, ni, method); + op1 = new (this, GT_INTRINSIC) + GenTreeIntrinsic(genActualType(callType), op1, ni, method R2RARG(*entryPoint)); // Set the CALL flag to indicate that the operator is implemented by a call. // Set also the EXCEPTION flag because the native implementation of @@ -9056,8 +9035,16 @@ GenTree* Compiler::impEstimateIntrinsic(CORINFO_METHOD_HANDLE method, if (intrinsicName == NI_System_Math_ReciprocalSqrtEstimate) { assert(!IsIntrinsicImplementedByUserCall(NI_System_Math_Sqrt)); + +#if defined(FEATURE_READYTORUN) + CORINFO_CONST_LOOKUP entryPoint; + + entryPoint.addr = nullptr; + entryPoint.accessType = IAT_VALUE; +#endif // FEATURE_READYTORUN + op1 = new (this, GT_INTRINSIC) - GenTreeIntrinsic(genActualType(callType), op1, NI_System_Math_Sqrt, nullptr); + GenTreeIntrinsic(genActualType(callType), op1, NI_System_Math_Sqrt, nullptr R2RARG(entryPoint)); } return gtNewOperNode(GT_DIV, genActualType(callType), gtNewDconNode(1.0, callType), op1); } @@ -9070,7 +9057,7 @@ GenTree* Compiler::impEstimateIntrinsic(CORINFO_METHOD_HANDLE method, } GenTree* Compiler::impMathIntrinsic(CORINFO_METHOD_HANDLE method, - CORINFO_SIG_INFO* sig, + CORINFO_SIG_INFO* sig R2RARG(CORINFO_CONST_LOOKUP* entryPoint), var_types callType, NamedIntrinsic intrinsicName, bool tailCall) @@ -9107,7 +9094,8 @@ GenTree* Compiler::impMathIntrinsic(CORINFO_METHOD_HANDLE method, op1 = impPopStack().val; op1 = impImplicitR4orR8Cast(op1, callType); - op1 = new (this, GT_INTRINSIC) GenTreeIntrinsic(genActualType(callType), op1, intrinsicName, method); + op1 = new (this, GT_INTRINSIC) + GenTreeIntrinsic(genActualType(callType), op1, intrinsicName, method R2RARG(*entryPoint)); break; case 2: @@ -9119,8 +9107,8 @@ GenTree* Compiler::impMathIntrinsic(CORINFO_METHOD_HANDLE method, op1 = impPopStack().val; op1 = impImplicitR4orR8Cast(op1, callType); op2 = impImplicitR4orR8Cast(op2, callType); - op1 = - new (this, GT_INTRINSIC) GenTreeIntrinsic(genActualType(callType), op1, op2, intrinsicName, method); + op1 = new (this, GT_INTRINSIC) + GenTreeIntrinsic(genActualType(callType), op1, op2, intrinsicName, method R2RARG(*entryPoint)); break; default: diff --git a/src/coreclr/jit/lsra.cpp b/src/coreclr/jit/lsra.cpp index 08c30882d59d00..5e5bbac3839f05 100644 --- a/src/coreclr/jit/lsra.cpp +++ b/src/coreclr/jit/lsra.cpp @@ -7595,8 +7595,15 @@ void LinearScan::insertUpperVectorSave(GenTree* tree, saveLcl->SetRegNum(lclVarReg); SetLsraAdded(saveLcl); - GenTreeIntrinsic* simdUpperSave = - new (compiler, GT_INTRINSIC) GenTreeIntrinsic(LargeVectorSaveType, saveLcl, NI_SIMD_UpperSave, nullptr); +#if defined(FEATURE_READYTORUN) + CORINFO_CONST_LOOKUP entryPoint; + + entryPoint.addr = nullptr; + entryPoint.accessType = IAT_VALUE; +#endif // FEATURE_READYTORUN + + GenTreeIntrinsic* simdUpperSave = new (compiler, GT_INTRINSIC) + GenTreeIntrinsic(LargeVectorSaveType, saveLcl, NI_SIMD_UpperSave, nullptr R2RARG(entryPoint)); SetLsraAdded(simdUpperSave); simdUpperSave->SetRegNum(spillReg); @@ -7653,8 +7660,15 @@ void LinearScan::insertUpperVectorRestore(GenTree* tree, restoreLcl->SetRegNum(lclVarReg); SetLsraAdded(restoreLcl); - GenTreeIntrinsic* simdUpperRestore = - new (compiler, GT_INTRINSIC) GenTreeIntrinsic(varDsc->TypeGet(), restoreLcl, NI_SIMD_UpperRestore, nullptr); +#if defined(FEATURE_READYTORUN) + CORINFO_CONST_LOOKUP entryPoint; + + entryPoint.addr = nullptr; + entryPoint.accessType = IAT_VALUE; +#endif // FEATURE_READYTORUN + + GenTreeIntrinsic* simdUpperRestore = new (compiler, GT_INTRINSIC) + GenTreeIntrinsic(varDsc->TypeGet(), restoreLcl, NI_SIMD_UpperRestore, nullptr R2RARG(entryPoint)); regNumber restoreReg = upperVectorInterval->physReg; SetLsraAdded(simdUpperRestore);