From 0bec2292410e24564693b0e5f97f173c76a674f2 Mon Sep 17 00:00:00 2001 From: SingleAccretion Date: Fri, 6 Mar 2026 00:39:44 +0300 Subject: [PATCH] Remove dead code from "genCallInstruction" --- src/coreclr/jit/codegenarmarch.cpp | 27 ++------------------ src/coreclr/jit/codegenloongarch64.cpp | 27 ++------------------ src/coreclr/jit/codegenriscv64.cpp | 28 ++------------------- src/coreclr/jit/codegenxarch.cpp | 34 +++----------------------- src/coreclr/jit/lower.cpp | 1 + 5 files changed, 10 insertions(+), 107 deletions(-) diff --git a/src/coreclr/jit/codegenarmarch.cpp b/src/coreclr/jit/codegenarmarch.cpp index a690b94be6ac16..fcef600921e254 100644 --- a/src/coreclr/jit/codegenarmarch.cpp +++ b/src/coreclr/jit/codegenarmarch.cpp @@ -3435,33 +3435,10 @@ void CodeGen::genCallInstruction(GenTreeCall* call) { // Generate a direct call to a non-virtual user defined or helper method assert(call->IsHelperCall() || (call->gtCallType == CT_USER_FUNC)); + assert(call->gtDirectCallAddress != nullptr); -#ifdef FEATURE_READYTORUN - if (call->gtEntryPoint.addr != NULL) - { - assert(call->gtEntryPoint.accessType == IAT_VALUE); - params.addr = call->gtEntryPoint.addr; - } - else -#endif // FEATURE_READYTORUN - if (call->IsHelperCall()) - { - CorInfoHelpFunc helperNum = m_compiler->eeGetHelperNum(params.methHnd); - noway_assert(helperNum != CORINFO_HELP_UNDEF); - - CORINFO_CONST_LOOKUP helperLookup = m_compiler->compGetHelperFtn(helperNum); - params.addr = helperLookup.addr; - assert(helperLookup.accessType == IAT_VALUE); - } - else - { - // Direct call to a non-virtual user function. - params.addr = call->gtDirectCallAddress; - } - - assert(params.addr != nullptr); + params.addr = call->gtDirectCallAddress; -// Non-virtual direct call to known addresses #ifdef TARGET_ARM if (!validImmForBL((ssize_t)params.addr)) { diff --git a/src/coreclr/jit/codegenloongarch64.cpp b/src/coreclr/jit/codegenloongarch64.cpp index 8cb00e60920b59..feb4d28396a082 100644 --- a/src/coreclr/jit/codegenloongarch64.cpp +++ b/src/coreclr/jit/codegenloongarch64.cpp @@ -5830,33 +5830,10 @@ void CodeGen::genCallInstruction(GenTreeCall* call) { // Generate a direct call to a non-virtual user defined or helper method assert(call->IsHelperCall() || (call->gtCallType == CT_USER_FUNC)); - -#ifdef FEATURE_READYTORUN - if (call->gtEntryPoint.addr != NULL) - { - assert(call->gtEntryPoint.accessType == IAT_VALUE); - params.addr = call->gtEntryPoint.addr; - } - else -#endif // FEATURE_READYTORUN - if (call->IsHelperCall()) - { - CorInfoHelpFunc helperNum = m_compiler->eeGetHelperNum(params.methHnd); - noway_assert(helperNum != CORINFO_HELP_UNDEF); - - CORINFO_CONST_LOOKUP helperLookup = m_compiler->compGetHelperFtn(helperNum); - params.addr = helperLookup.addr; - assert(helperLookup.accessType == IAT_VALUE); - } - else - { - // Direct call to a non-virtual user function. - params.addr = call->gtDirectCallAddress; - } - - assert(params.addr != nullptr); + assert(call->gtDirectCallAddress != nullptr); params.callType = EC_FUNC_TOKEN; + params.addr = call->gtDirectCallAddress; genEmitCallWithCurrentGC(params); } } diff --git a/src/coreclr/jit/codegenriscv64.cpp b/src/coreclr/jit/codegenriscv64.cpp index 2a0c20272c70f8..148a42c53c98b1 100644 --- a/src/coreclr/jit/codegenriscv64.cpp +++ b/src/coreclr/jit/codegenriscv64.cpp @@ -5662,35 +5662,11 @@ void CodeGen::genCallInstruction(GenTreeCall* call) { // Generate a direct call to a non-virtual user defined or helper method assert(call->IsHelperCall() || (call->gtCallType == CT_USER_FUNC)); - -#ifdef FEATURE_READYTORUN - if (call->gtEntryPoint.addr != NULL) - { - assert(call->gtEntryPoint.accessType == IAT_VALUE); - params.addr = call->gtEntryPoint.addr; - } - else -#endif // FEATURE_READYTORUN - { - if (call->IsHelperCall()) - { - CorInfoHelpFunc helperNum = m_compiler->eeGetHelperNum(params.methHnd); - noway_assert(helperNum != CORINFO_HELP_UNDEF); - - CORINFO_CONST_LOOKUP helperLookup = m_compiler->compGetHelperFtn(helperNum); - params.addr = helperLookup.addr; - assert(helperLookup.accessType == IAT_VALUE); - } - else - { - // Direct call to a non-virtual user function. - params.addr = call->gtDirectCallAddress; - } - } + assert(call->gtDirectCallAddress != nullptr); params.callType = EC_FUNC_TOKEN; + params.addr = call->gtDirectCallAddress; params.ireg = params.isJump ? rsGetRsvdReg() : REG_RA; - genEmitCallWithCurrentGC(params); } } diff --git a/src/coreclr/jit/codegenxarch.cpp b/src/coreclr/jit/codegenxarch.cpp index 3906df348e1761..36a120250c6cf3 100644 --- a/src/coreclr/jit/codegenxarch.cpp +++ b/src/coreclr/jit/codegenxarch.cpp @@ -6325,42 +6325,14 @@ void CodeGen::genCallInstruction(GenTreeCall* call X86_ARG(target_ssize_t stackA params.ireg = indirCellReg; genEmitCallWithCurrentGC(params); } -#ifdef FEATURE_READYTORUN - else if (call->gtEntryPoint.addr != nullptr) - { - params.callType = (call->gtEntryPoint.accessType == IAT_VALUE) ? EC_FUNC_TOKEN : EC_FUNC_TOKEN_INDIR; - params.addr = (void*)call->gtEntryPoint.addr; - genEmitCallWithCurrentGC(params); - } -#endif else { - // Generate a direct call to a non-virtual user defined or helper method + // Generate a direct call to a non-virtual user defined or helper method. assert(call->IsHelperCall() || (call->gtCallType == CT_USER_FUNC)); - - void* addr = nullptr; - if (call->IsHelperCall()) - { - // Direct call to a helper method. - CorInfoHelpFunc helperNum = m_compiler->eeGetHelperNum(params.methHnd); - noway_assert(helperNum != CORINFO_HELP_UNDEF); - - CORINFO_CONST_LOOKUP helperLookup = m_compiler->compGetHelperFtn(helperNum); - addr = helperLookup.addr; - assert(helperLookup.accessType == IAT_VALUE); - } - else - { - // Direct call to a non-virtual user function. - addr = call->gtDirectCallAddress; - } - - assert(addr != nullptr); - - // Non-virtual direct calls to known addresses + assert(call->gtDirectCallAddress != nullptr); params.callType = EC_FUNC_TOKEN; - params.addr = addr; + params.addr = call->gtDirectCallAddress; genEmitCallWithCurrentGC(params); } } diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index 95be5933bcdfed..0da90f7edeca7f 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -2867,6 +2867,7 @@ GenTree* Lowering::LowerCall(GenTree* node) } #endif + call->gtDirectCallAddress = nullptr; // Clear out any stale data from the union. call->ClearOtherRegs(); #if HAS_FIXED_REGISTER_SET