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

Code before:
//    operand - The node to consume the register for
//    reason  - What was the register allocated for
//
void WasmRegAlloc::ConsumeTemporaryRegForOperand(GenTree* operand DEBUGARG(const char* reason))
{
    if ((operand->gtLIRFlags & LIR::Flags::MultiplyUsed) == LIR::Flags::None)
    {
        return;
    }

    regNumber reg = ReleaseTemporaryRegister(genActualType(operand));
    assert(reg == operand->GetRegNum());
    CollectReference(operand);

    operand->gtLIRFlags &= ~LIR::Flags::MultiplyUsed;
    JITDUMP("Consumed a temporary reg for [%06u]: %s\n", Compiler::dspTreeID(operand), reason);
}

//------------------------------------------------------------------------
// ResolveReferences: Translate virtual registers to physical ones (WASM locals).
//
// And fill-in the references collected earlier.
//
void WasmRegAlloc::ResolveReferences()
{
    // Finish the allocation by allocating temprary registers to virtual registers.
    struct TemporaryRegBank
    {
        regNumber* Regs;
        unsigned   Count;
    };
    TemporaryRegBank temporaryRegMap[static_cast<unsigned>(WasmValueType::Count)];
    for (WasmValueType type = WasmValueType::First; type < WasmValueType::Count; ++type)
    {
        TemporaryRegStack& temporaryRegs          = m_temporaryRegs[static_cast<unsigned>(type)];
        TemporaryRegBank&  allocatedTemporaryRegs = temporaryRegMap[static_cast<unsigned>(type)];
        assert(temporaryRegs.Count == 0);

        allocatedTemporaryRegs.Count = temporaryRegs.MaxCount;
        if (allocatedTemporaryRegs.Count == 0)
        {
            continue;
        }

        allocatedTemporaryRegs.Regs = new (m_compiler->getAllocator(CMK_LSRA)) regNumber[allocatedTemporaryRegs.Count];
        for (unsigned i = 0; i < allocatedTemporaryRegs.Count; i++)
        {
            allocatedTemporaryRegs.Regs[i] = AllocateVirtualRegister(type);
        }
    }


Review comment (suggestion):
```suggestion
    // Finish the allocation by allocating temporary registers to virtual registers.
```

Code after:
//    operand - The node to consume the register for
//    reason  - What was the register allocated for
//
void WasmRegAlloc::ConsumeTemporaryRegForOperand(GenTree* operand DEBUGARG(const char* reason))
{
    if ((operand->gtLIRFlags & LIR::Flags::MultiplyUsed) == LIR::Flags::None)
    {
        return;
    }

    regNumber reg = ReleaseTemporaryRegister(genActualType(operand));
    assert(reg == operand->GetRegNum());
    CollectReference(operand);

    operand->gtLIRFlags &= ~LIR::Flags::MultiplyUsed;
    JITDUMP("Consumed a temporary reg for [%06u]: %s\n", Compiler::dspTreeID(operand), reason);
}

//------------------------------------------------------------------------
// ResolveReferences: Translate virtual registers to physical ones (WASM locals).
//
// And fill-in the references collected earlier.
//
void WasmRegAlloc::ResolveReferences()
{
    // Finish the allocation by allocating temporary registers to virtual registers.
    struct TemporaryRegBank
    {
        regNumber* Regs;
        unsigned   Count;
    };
    TemporaryRegBank temporaryRegMap[static_cast<unsigned>(WasmValueType::Count)];
    for (WasmValueType type = WasmValueType::First; type < WasmValueType::Count; ++type)
    {
        TemporaryRegStack& temporaryRegs          = m_temporaryRegs[static_cast<unsigned>(type)];
        TemporaryRegBank&  allocatedTemporaryRegs = temporaryRegMap[static_cast<unsigned>(type)];
        assert(temporaryRegs.Count == 0);

        allocatedTemporaryRegs.Count = temporaryRegs.MaxCount;
        if (allocatedTemporaryRegs.Count == 0)
        {
            continue;
        }

        allocatedTemporaryRegs.Regs = new (m_compiler->getAllocator(CMK_LSRA)) regNumber[allocatedTemporaryRegs.Count];
        for (unsigned i = 0; i < allocatedTemporaryRegs.Count; i++)
        {
            allocatedTemporaryRegs.Regs[i] = AllocateVirtualRegister(type);
        }
    }