• Damien George's avatar
    py/emitnative: Fix case of clobbered REG_TEMP0 when loading const obj. · afba3e05
    Damien George authored
    The `emit_load_reg_with_object()` helper function will clobber `REG_TEMP0`.
    This is currently OK on architectures where `REG_RET` and `REG_TEMP0` are
    the same (all architectures except RV32), because all callers of
    `emit_load_reg_with_object()` use either `REG_RET` or `REG_TEMP0` as the
    destination register.  But on RV32 these registers are different and so
    when `REG_RET` is the destination, `REG_TEMP0` is clobbered, leading to
    incorrectly generated machine code.
    
    This commit fixes the issue simply by using `REG_TEMP0` as the destination
    register for all uses of `emit_load_reg_with_object()`, and adds a comment
    to make sure the caller of this function is careful.
    Signed-off-by: default avatarDamien George <damien@micropython.org>
    afba3e05
emitnative.c 131 KB