ronantakizawa/codereview-bench huggingface dataset:
Repository: dotnet/runtime
File: src/coreclr/vm/threads.cpp (C++)

Code before:

    s_fCleanFinalizedThread = FALSE;
}

#ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT

void Thread::CleanupCOMState()
{
    CONTRACTL {
        NOTHROW;
        GC_TRIGGERS;
    }
    CONTRACTL_END;

#ifdef FEATURE_COMINTEROP
    if (GetFinalApartment() == Thread::AS_InSTA)
        ReleaseRCWsInCachesNoThrow(GetCurrentCtxCookie());
#endif // FEATURE_COMINTEROP

    // Running threads might have performed a CoInitialize which must
    // now be balanced. However only the thread that called COInitialize can
    // call CoUninitialize.

    BOOL needsUninitialize = IsCoInitialized();

    if (needsUninitialize)
    {
        GCX_PREEMP();
        CONTRACT_VIOLATION(ThrowsViolation);

        if (IsCoInitialized())
        {
            BaseCoUninitialize();
            ResetCoInitialized();
        }
    }
}
#endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT

// Thread cleanup that must be run in cooperative mode before the thread is destroyed.
void Thread::CooperativeCleanup()
{
    CONTRACTL {
        NOTHROW;
        GC_TRIGGERS;
    }
    CONTRACTL_END;

    // Skip the cleanup during process exit. Switch to cooperative mode can deadlock during process exit on Windows.
    if (IsAtProcessExit())
        return;

Review comment (suggestion):
```suggestion
    if (IsCoInitialized())
```
@copilot 

Also, delete redundant IsCoInitialized() check below

Code after:
#ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT

void Thread::CleanupCOMState()
{
    CONTRACTL {
        NOTHROW;
        GC_TRIGGERS;
    }
    CONTRACTL_END;

#ifdef FEATURE_COMINTEROP
    if (GetFinalApartment() == Thread::AS_InSTA)
        ReleaseRCWsInCachesNoThrow(GetCurrentCtxCookie());
#endif // FEATURE_COMINTEROP

    // Running threads might have performed a CoInitialize which must
    // now be balanced. However only the thread that called COInitialize can
    // call CoUninitialize.

    if (IsCoInitialized())
    {
        GCX_PREEMP();
        CONTRACT_VIOLATION(ThrowsViolation);

        BaseCoUninitialize();
        ResetCoInitialized();
    }
}
#endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT

// Thread cleanup that must be run in cooperative mode before the thread is destroyed.
void Thread::CooperativeCleanup()
{
    CONTRACTL {
        NOTHROW;
        GC_TRIGGERS;
    }
    CONTRACTL_END;

    // Skip the cleanup during process exit. Switch to cooperative mode can deadlock during process exit on Windows.
    if (IsAtProcessExit())
        return;

    GCX_COOP();

    // Clear any outstanding stale EH state that maybe still active on the thread.
    ExInfo::PopTrackers((void*)-1);

    if (m_ThreadLocalDataPtr != NULL)
    {
        FreeThreadStaticData(this);
Repository: dotnet/runtime
File: src/coreclr/nativeaot/Runtime/unix/PalCreateDump.cpp (C++)

Code before:
    return buffer;
}

/*++
Function
  BuildCreateDumpCommandLine

Abstract
  Builds the createdump command line from the arguments.

Return
  true - succeeds, false - fails

--*/
static
bool
BuildCreateDumpCommandLine(
    const char** argv,
    const char* dumpName,
    const char* logFileName,
    int dumpType,
    uint32_t flags)
{
    if (g_szCreateDumpPath == nullptr || g_ppidarg == nullptr)
    {
        fprintf(stderr, "DOTNET_DbgEnableMiniDump is set and the createdump binary does not exist\n");
        return false;
    }

    int argc = 0;
    argv[argc++] = g_szCreateDumpPath;

    if (dumpName != nullptr)
    {
        argv[argc++] = "--name";
        argv[argc++] = dumpName;
    }

    switch (dumpType)
    {
        case DumpTypeNormal:
            argv[argc++] = "--normal";
            break;
        case DumpTypeWithHeap:
            argv[argc++] = "--withheap";
            break;
        case DumpTypeTriage:
            argv[argc++] = "--triage";
            break;
        case DumpTypeFull:
            argv[argc++] = "--full";

Review comment (bug):
This doesn't look right. This is called in `PalCreateDumpInitialize` so it will still print even if no crash occurs

Code after:
    return buffer;
}

/*++
Function
  BuildCreateDumpCommandLine

Abstract
  Builds the createdump command line from the arguments.

Return
  true - succeeds, false - fails

--*/
static
bool
BuildCreateDumpCommandLine(
    const char** argv,
    const char* dumpName,
    const char* logFileName,
    int dumpType,
    uint32_t flags)
{
    if (g_szCreateDumpPath == nullptr || g_ppidarg == nullptr)
    {
        return false;
    }

    int argc = 0;
    argv[argc++] = g_szCreateDumpPath;

    if (dumpName != nullptr)
    {
        argv[argc++] = "--name";
        argv[argc++] = dumpName;
    }

    switch (dumpType)
    {
        case DumpTypeNormal:
            argv[argc++] = "--normal";
            break;
        case DumpTypeWithHeap:
            argv[argc++] = "--withheap";
            break;
        case DumpTypeTriage:
            argv[argc++] = "--triage";
            break;
        case DumpTypeFull:
            argv[argc++] = "--full";
            break;
Repository: dotnet/runtime
File: src/coreclr/jit/codegenwasm.cpp (C++)

Code before:
//    tree - the GT_STOREIND node
//
void CodeGen::genCodeForStoreInd(GenTreeStoreInd* tree)
{
    GenTree* data = tree->Data();
    GenTree* addr = tree->Addr();

    GCInfo::WriteBarrierForm writeBarrierForm = gcInfo.gcIsWriteBarrierCandidate(tree);
    if (writeBarrierForm != GCInfo::WBF_NoBarrier)
    {
        NYI_WASM("write barriers in StoreInd");
    }
    else // A normal store, not a WriteBarrier store
    {
        // We must consume the operands in the proper execution order,
        // so that liveness is updated appropriately.
        genConsumeAddress(addr);

        if (!data->isContained())
        {
            genConsumeRegs(data);
        }

        var_types   type = tree->TypeGet();
        instruction ins  = ins_Store(type);

        // TODO-WASM: Memory barriers

        GetEmitter()->emitIns_I(ins, emitActualTypeSize(type), 0);
    }
}

//------------------------------------------------------------------------
// 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();

    if (varTypeIsFloating(op1Type))
    {
        genCompareFloat(tree);
    }
    else
    {

Review comment (suggestion):
```suggestion
    }

    genUpdateLife(tree);
```
`STOREIND`s are among the few special nodes that may affect liveness (if it's an indirect store to a tracked local).

Code after:
//    tree - the GT_STOREIND node
//
void CodeGen::genCodeForStoreInd(GenTreeStoreInd* tree)
{
    GenTree* data = tree->Data();
    GenTree* addr = tree->Addr();

    GCInfo::WriteBarrierForm writeBarrierForm = gcInfo.gcIsWriteBarrierCandidate(tree);
    if (writeBarrierForm != GCInfo::WBF_NoBarrier)
    {
        NYI_WASM("write barriers in StoreInd");
    }
    else // A normal store, not a WriteBarrier store
    {
        // We must consume the operands in the proper execution order,
        // so that liveness is updated appropriately.
        genConsumeAddress(addr);
        genConsumeRegs(data);

        var_types   type = tree->TypeGet();
        instruction ins  = ins_Store(type);

        // TODO-WASM: Memory barriers

        GetEmitter()->emitIns_I(ins, emitActualTypeSize(type), 0);
    }

    genUpdateLife(tree);
}

//------------------------------------------------------------------------
// 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();

    if (varTypeIsFloating(op1Type))
    {
        genCompareFloat(tree);
    }
    else
    {
        genCompareInt(tree);
    }
Repository: dotnet/runtime
File: src/coreclr/vm/jitinterface.h (C/C++)

Code before:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// ===========================================================================
// File: JITinterface.H
//
// ===========================================================================

#ifndef JITINTERFACE_H
#define JITINTERFACE_H

#include "corjit.h"

#ifdef TARGET_WASM
#define MAX_UNCHECKED_OFFSET_FOR_NULL_OBJECT 0
#elif !defined(TARGET_UNIX)
#define MAX_UNCHECKED_OFFSET_FOR_NULL_OBJECT ((32*1024)-1)   // when generating JIT code
#else // TARGET_WASM or !TARGET_UNIX
#define MAX_UNCHECKED_OFFSET_FOR_NULL_OBJECT ((GetOsPageSize() / 2) - 1)
#endif // TARGET_UNIX
#include "pgo.h"

class ILCodeStream;

enum StompWriteBarrierCompletionAction
{
    SWB_PASS = 0x0,
    SWB_ICACHE_FLUSH = 0x1,
    SWB_EE_RESTART = 0x2
};

enum SignatureKind
{
    SK_NOT_CALLSITE,
    SK_CALLSITE,
    SK_VIRTUAL_CALLSITE,
    SK_STATIC_VIRTUAL_CODEPOINTER_CALLSITE,
};

class Stub;

Review comment (bug):
Although this will likely result in "more correct" codegen today, it is not going to be 100% correct (there are some bugs that are hidden by the large default `MAX_UNCHECKED_OFFSET_FOR_NULL_OBJECT` value).

More importantly though, this will disable a lot of optimizations in the Jit that do inferences like:
```
if (obj != null) obj.Field = 1; // store [obj + 8], 1 => deduced to never throw since 8 < MAX_UNCHECKED_OFFSET_FOR_NULL_OBJECT
```
I think a more interesting short-term fix would be to use a `addr < 1024` for a null check like we do in NAOT-LLVM. The long-term fix is the same as for address modes and is not so simple.

By the way, this value is also hardcoded in CG2 (`CorInfoImpl.cs`, `maxUncheckedOffsetForNullObject `), if we're changing it here that needs to stay in sync.

Code after:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// ===========================================================================
// File: JITinterface.H
//
// ===========================================================================

#ifndef JITINTERFACE_H
#define JITINTERFACE_H

#include "corjit.h"

#ifndef TARGET_UNIX
#define MAX_UNCHECKED_OFFSET_FOR_NULL_OBJECT ((32*1024)-1)   // when generating JIT code
#else // !TARGET_UNIX
#define MAX_UNCHECKED_OFFSET_FOR_NULL_OBJECT ((GetOsPageSize() / 2) - 1)
#endif // !TARGET_UNIX
#include "pgo.h"

class ILCodeStream;

enum StompWriteBarrierCompletionAction
{
    SWB_PASS = 0x0,
    SWB_ICACHE_FLUSH = 0x1,
    SWB_EE_RESTART = 0x2
};

enum SignatureKind
{
    SK_NOT_CALLSITE,
    SK_CALLSITE,
    SK_VIRTUAL_CALLSITE,
    SK_STATIC_VIRTUAL_CODEPOINTER_CALLSITE,
};

class Stub;
class MethodDesc;
class NativeCodeVersion;
Repository: dotnet/runtime
File: src/coreclr/jit/codegenwasm.cpp (C++)

Code before:

    GCInfo::WriteBarrierForm writeBarrierForm = gcInfo.gcIsWriteBarrierCandidate(tree);
    if (writeBarrierForm != GCInfo::WBF_NoBarrier)
    {
        NYI_WASM("write barriers in StoreInd");
    }
    else // A normal store, not a WriteBarrier store
    {
        // We must consume the operands in the proper execution order,
        // so that liveness is updated appropriately.
        genConsumeAddress(addr);
        genConsumeRegs(data);

        var_types   type = tree->TypeGet();
        instruction ins  = ins_Store(type);

        // TODO-WASM: Memory barriers

        GetEmitter()->emitIns_I(ins, emitActualTypeSize(type), 0);
    }

    genUpdateLife(tree);
}

//---------------------------------------------------------------------
// genPutArgReg - generate code for a T_PUTARG_REG node
//
// Arguments
//    tree - the GT_PUTARG_REG node
//
// Return value:
//    None
//
void CodeGen::genPutArgReg(GenTreeOp* tree)
{
    assert(tree->OperIs(GT_PUTARG_REG));

    var_types targetType = tree->TypeGet();
    regNumber targetReg  = tree->GetRegNum();

    assert(targetType != TYP_STRUCT);

    GenTree* op1 = tree->gtOp1;
    genConsumeReg(op1);

    GetEmitter()->emitIns_I(INS_local_get, emitTypeSize(tree), WasmRegToIndex(op1->GetRegNum()));
    GetEmitter()->emitIns_I(INS_local_set, emitTypeSize(tree), WasmRegToIndex(targetReg));

    genProduceReg(tree);
}


Review comment (suggestion):
```suggestion
// genPutArgReg - generate code for a GT_PUTARG_REG node
```

Code after:
    // dividend (next)
    // ...
    // TODO-WASM: To check for exception, we will have to spill these to
    // internal registers along the way, like so:
    //
    // ... push dividend
    // tee.local $temp1
    // ... push divisor
    // tee.local $temp2
    // ... exception checks (using $temp1 and $temp2; will introduce flow)
    // div/mod op

    if (!varTypeIsFloating(treeNode->TypeGet()))
    {
        ExceptionSetFlags exSetFlags = treeNode->OperExceptions(compiler);

        // TODO-WASM:(AnyVal / 0) => DivideByZeroException
        //
        if ((exSetFlags & ExceptionSetFlags::DivideByZeroException) != ExceptionSetFlags::None)
        {
        }

        // TODO-WASM: (MinInt / -1) => ArithmeticException
        //
        if ((exSetFlags & ExceptionSetFlags::ArithmeticException) != ExceptionSetFlags::None)
        {
        }
    }

    instruction ins;
    switch (PackOperAndType(treeNode->OperGet(), treeNode->TypeGet()))
    {
        case PackOperAndType(GT_DIV, TYP_INT):
            ins = INS_i32_div_s;
            break;
        case PackOperAndType(GT_DIV, TYP_LONG):
            ins = INS_i64_div_s;
            break;
        case PackOperAndType(GT_DIV, TYP_FLOAT):
            ins = INS_f32_div;
            break;
        case PackOperAndType(GT_DIV, TYP_DOUBLE):
            ins = INS_f64_div;
            break;

        case PackOperAndType(GT_UDIV, TYP_INT):
            ins = INS_i32_div_u;
            break;
        case PackOperAndType(GT_UDIV, TYP_LONG):
            ins = INS_i64_div_u;
            break;
Repository: dotnet/runtime
File: src/coreclr/jit/emitfmtswasm.h (C/C++)

Code before:
#undef DEFINE_ID_OPS

#else // !DEFINE_ID_OPS

#ifndef IF_DEF
#error Must define IF_DEF macro before including this file
#endif

//////////////////////////////////////////////////////////////////////////////
//
// enum insFormat   instruction            enum ID_OPS
//                  scheduling
//                  (unused)
//////////////////////////////////////////////////////////////////////////////

IF_DEF(NONE,        IS_NONE, NONE)
IF_DEF(OPCODE,      IS_NONE, NONE) // <opcode>
IF_DEF(BLOCK,       IS_NONE, NONE) // <opcode> <0x40>
IF_DEF(RAW_ULEB128, IS_NONE, NONE) // <ULEB128 immediate>
IF_DEF(ULEB128,     IS_NONE, NONE) // <opcode> <ULEB128 immediate>
IF_DEF(SLEB128,     IS_NONE, NONE) // <opcode> <LEB128 immediate (signed)>
IF_DEF(F32,         IS_NONE, NONE) // <opcode> <f32 immediate (stored as 64-bit integer constant)>
IF_DEF(F64,         IS_NONE, NONE) // <opcode> <f64 immediate (stored as 64-bit integer constant)>
IF_DEF(MEMARG,      IS_NONE, NONE) // <opcode> <memarg> (<align> <offset>)
IF_DEF(LOCAL_DECL,  IS_NONE, NONE) // <ULEB128 immediate> <byte>
IF_DEF(ULEB128_X2,  IS_NONE, NONE) // <opcode> <ULEB128 immediate> <ULEB128 immediate>

#undef IF_DEF
#endif // !DEFINE_ID_OPS
// clang-format on


Review comment (suggestion):
I don't think we need this for indirect calls. The table index/symbol will always be `__indirect_function_table_table`, we can just hardcode it.

Code after:
#undef DEFINE_ID_OPS

#else // !DEFINE_ID_OPS

#ifndef IF_DEF
#error Must define IF_DEF macro before including this file
#endif

//////////////////////////////////////////////////////////////////////////////
//
// enum insFormat   instruction            enum ID_OPS
//                  scheduling
//                  (unused)
//////////////////////////////////////////////////////////////////////////////

IF_DEF(NONE,          IS_NONE, NONE)
IF_DEF(OPCODE,        IS_NONE, NONE) // <opcode>
IF_DEF(BLOCK,         IS_NONE, NONE) // <opcode> <0x40>
IF_DEF(RAW_ULEB128,   IS_NONE, NONE) // <ULEB128 immediate>
IF_DEF(ULEB128,       IS_NONE, NONE) // <opcode> <ULEB128 immediate>
IF_DEF(SLEB128,       IS_NONE, NONE) // <opcode> <LEB128 immediate (signed)>
IF_DEF(F32,           IS_NONE, NONE) // <opcode> <f32 immediate (stored as 64-bit integer constant)>
IF_DEF(F64,           IS_NONE, NONE) // <opcode> <f64 immediate (stored as 64-bit integer constant)>
IF_DEF(MEMARG,        IS_NONE, NONE) // <opcode> <memarg> (<align> <offset>)
IF_DEF(LOCAL_DECL,    IS_NONE, NONE) // <ULEB128 immediate> <byte>
IF_DEF(CALL_INDIRECT, IS_NONE, NONE) // <opcode> <ULEB128 immediate> <ULEB128 immediate>

#undef IF_DEF
#endif // !DEFINE_ID_OPS
// clang-format on
Repository: dotnet/runtime
File: src/coreclr/jit/codegenwasm.cpp (C++)

Code before:
        case PackOperAndType(GT_UMOD, TYP_INT):
            ins = INS_i32_rem_u;
            break;
        case PackOperAndType(GT_UMOD, TYP_LONG):
            ins = INS_i64_rem_u;
            break;

        default:
            ins = INS_none;
            NYI_WASM("genCodeForDivMod");
            break;
    }

    GetEmitter()->emitIns(ins);
    genProduceReg(treeNode);
}

//------------------------------------------------------------------------
// genCodeForConstant: Generate code for an integer or floating point constant
//
// Arguments:
//    treeNode - The constant.
//
void CodeGen::genCodeForConstant(GenTree* treeNode)
{
    instruction    ins  = INS_unreachable;
    cnsval_ssize_t bits = 0;
    var_types      type = treeNode->TypeIs(TYP_REF, TYP_BYREF) ? TYP_I_IMPL : treeNode->TypeGet();
    static_assert(sizeof(cnsval_ssize_t) >= sizeof(double));

    GenTreeIntConCommon* icon = nullptr;
    if ((type == TYP_INT) || (type == TYP_LONG))
    {
        icon = treeNode->AsIntConCommon();
        if (icon->ImmedValNeedsReloc(compiler))
        {
            // WASM-TODO: Generate reloc for this handle; 64-bit support
            ins  = INS_i32_const;
            bits = 0;
        }
        else
        {
            bits = icon->IntegralValue();
        }
    }

    if (ins == INS_unreachable)
    {
        switch (type)
        {
            case TYP_INT:

Review comment (suggestion):
```suggestion
    instruction    ins  = INS_none;
```

Code after:
        case PackOperAndType(GT_UMOD, TYP_INT):
            ins = INS_i32_rem_u;
            break;
        case PackOperAndType(GT_UMOD, TYP_LONG):
            ins = INS_i64_rem_u;
            break;

        default:
            ins = INS_none;
            NYI_WASM("genCodeForDivMod");
            break;
    }

    GetEmitter()->emitIns(ins);
    genProduceReg(treeNode);
}

//------------------------------------------------------------------------
// genCodeForConstant: Generate code for an integer or floating point constant
//
// Arguments:
//    treeNode - The constant.
//
void CodeGen::genCodeForConstant(GenTree* treeNode)
{
    instruction    ins  = INS_none;
    cnsval_ssize_t bits = 0;
    var_types      type = treeNode->TypeIs(TYP_REF, TYP_BYREF) ? TYP_I_IMPL : treeNode->TypeGet();
    static_assert(sizeof(cnsval_ssize_t) >= sizeof(double));

    GenTreeIntConCommon* icon = nullptr;
    if ((type == TYP_INT) || (type == TYP_LONG))
    {
        icon = treeNode->AsIntConCommon();
        if (icon->ImmedValNeedsReloc(compiler))
        {
            // WASM-TODO: Generate reloc for this handle
            ins  = INS_I_const;
            bits = 0;
        }
        else
        {
            bits = icon->IntegralValue();
        }
    }

    if (ins == INS_none)
    {
        switch (type)
        {
            case TYP_INT:
Repository: dotnet/runtime
File: src/coreclr/jit/codegenwasm.cpp (C++)

Code before:

    GetEmitter()->emitIns(ins);
    genProduceReg(treeNode);
}

//------------------------------------------------------------------------
// genCodeForConstant: Generate code for an integer or floating point constant
//
// Arguments:
//    treeNode - The constant.
//
void CodeGen::genCodeForConstant(GenTree* treeNode)
{
    instruction    ins  = INS_unreachable;
    cnsval_ssize_t bits = 0;
    var_types      type = treeNode->TypeIs(TYP_REF, TYP_BYREF) ? TYP_I_IMPL : treeNode->TypeGet();
    static_assert(sizeof(cnsval_ssize_t) >= sizeof(double));

    GenTreeIntConCommon* icon = nullptr;
    if ((type == TYP_INT) || (type == TYP_LONG))
    {
        icon = treeNode->AsIntConCommon();
        if (icon->ImmedValNeedsReloc(compiler))
        {
            // WASM-TODO: Generate reloc for this handle; 64-bit support
            ins  = INS_i32_const;
            bits = 0;
        }
        else
        {
            bits = icon->IntegralValue();
        }
    }

    if (ins == INS_unreachable)
    {
        switch (type)
        {
            case TYP_INT:
            {
                ins = INS_i32_const;
                assert(((INT64)(INT32)bits) == bits);
                break;
            }
            case TYP_LONG:
            {
                ins = INS_i64_const;
                break;
            }
            case TYP_FLOAT:
            {

Review comment (suggestion):
```suggestion
            // WASM-TODO: Generate reloc for this handle
            ins  = INS_I_const;
```

Code after:

    GetEmitter()->emitIns(ins);
    genProduceReg(treeNode);
}

//------------------------------------------------------------------------
// genCodeForConstant: Generate code for an integer or floating point constant
//
// Arguments:
//    treeNode - The constant.
//
void CodeGen::genCodeForConstant(GenTree* treeNode)
{
    instruction    ins  = INS_none;
    cnsval_ssize_t bits = 0;
    var_types      type = treeNode->TypeIs(TYP_REF, TYP_BYREF) ? TYP_I_IMPL : treeNode->TypeGet();
    static_assert(sizeof(cnsval_ssize_t) >= sizeof(double));

    GenTreeIntConCommon* icon = nullptr;
    if ((type == TYP_INT) || (type == TYP_LONG))
    {
        icon = treeNode->AsIntConCommon();
        if (icon->ImmedValNeedsReloc(compiler))
        {
            // WASM-TODO: Generate reloc for this handle
            ins  = INS_I_const;
            bits = 0;
        }
        else
        {
            bits = icon->IntegralValue();
        }
    }

    if (ins == INS_none)
    {
        switch (type)
        {
            case TYP_INT:
            {
                ins = INS_i32_const;
                assert(FitsIn<INT32>(bits));
                break;
            }
            case TYP_LONG:
            {
                ins = INS_i64_const;
                break;
            }
            case TYP_FLOAT:
            {