Repository: dotnet/runtime
File: src/coreclr/jit/codegenwasm.cpp (C++)

Code before:
            assert(call->IsR2ROrVirtualStubRelativeIndir());

            params.callType = EC_INDIR_R;
            // params.ireg     = targetAddrReg;
            genEmitCallWithCurrentGC(params);
        }
        else
        {
            // Generate a direct call to a non-virtual user defined or helper method
            assert(call->IsHelperCall() || (call->gtCallType == CT_USER_FUNC));

            if (call->gtEntryPoint.addr != NULL)
            {
                NYI_WASM("Call with statically known address");
            }
            else
            {
                if (call->IsHelperCall())
                {
                    NYI_WASM("Call helper statically without indirection cell");
                    CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(params.methHnd);
                    noway_assert(helperNum != CORINFO_HELP_UNDEF);

                    CORINFO_CONST_LOOKUP helperLookup = 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;
                }
            }

            params.callType = EC_FUNC_TOKEN;
            // params.ireg     = params.isJump ? rsGetRsvdReg() : REG_RA;

            genEmitCallWithCurrentGC(params);
        }
    }
}

/*****************************************************************************
 *  Emit a call to a helper function.
 */
void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, regNumber callTargetReg /*= REG_NA */)
{
    EmitCallParams params;

    CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn((CorInfoHelpFunc)helper);
    params.ireg                         = callTargetReg;

Review comment (refactor):
The NYI_WASM macro call will throw or terminate execution, making the subsequent code unreachable. Either remove the dead code (lines 1532-1537) or move the NYI_WASM call to after setting up the parameters if the code path needs to be preserved for future implementation.
```suggestion
                    CorInfoHelpFunc helperNum = compiler->eeGetHelperNum(params.methHnd);
                    noway_assert(helperNum != CORINFO_HELP_UNDEF);

                    CORINFO_CONST_LOOKUP helperLookup = compiler->compGetHelperFtn(helperNum);
                    params.addr                       = helperLookup.addr;
                    assert(helperLookup.accessType == IAT_VALUE);

                    NYI_WASM("Call helper statically without indirection cell");
```

Code after:
        }
    }
}

/*****************************************************************************
 *  Emit a call to a helper function.
 */
void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, regNumber callTargetReg /*= REG_NA */)
{
    EmitCallParams params;

    CORINFO_CONST_LOOKUP helperFunction = compiler->compGetHelperFtn((CorInfoHelpFunc)helper);
    params.ireg                         = callTargetReg;

    if (helperFunction.accessType == IAT_VALUE)
    {
        params.callType = EC_FUNC_TOKEN;
        params.addr     = helperFunction.addr;
    }
    else
    {
        params.addr = nullptr;
        assert(helperFunction.accessType == IAT_PVALUE);
        void* pAddr = helperFunction.addr;

        // Push indirection cell address onto stack for genEmitCall to dereference
        GetEmitter()->emitIns_I(INS_i32_const, emitActualTypeSize(TYP_I_IMPL), (cnsval_ssize_t)pAddr);

        params.callType = EC_INDIR_R;
    }

    params.methHnd = compiler->eeFindHelper(helper);
    params.argSize = argSize;
    params.retSize = retSize;

    genEmitCallWithCurrentGC(params);
}

//------------------------------------------------------------------------
// genCodeForCompare: Produce code for a GT_EQ/GT_NE/GT_LT/GT_LE/GT_GE/GT_GT node.
//
// Arguments:
//    tree - the node
//
void CodeGen::genCodeForCompare(GenTreeOp* tree)
{
    assert(tree->OperIsCmpCompare());

    GenTree* const  op1     = tree->gtGetOp1();
    var_types const op1Type = op1->TypeGet();