Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -2238,12 +2238,12 @@ mono_emit_widen_call_res (MonoCompile *cfg, MonoInst *ins, MonoMethodSignature *
// LLVM code doesn't uses zero extend the full word while jit expects it.
// A proper fix would be to detect if we are actually using llvm code from aot images
// or make sure llvm code actually zero extends the return.
#ifdef MONO_ARCH_LLVM_SUPPORTED
gboolean might_use_llvm = TRUE;
#if defined(MONO_ARCH_LLVM_SUPPORTED) || defined(MONO_ARCH_INTERPRETER_SUPPORTED)
gboolean might_use_llvm_or_interp = TRUE;
#else
gboolean might_use_llvm = FALSE;
gboolean might_use_llvm_or_interp = FALSE;
#endif
if ((fsig->pinvoke || might_use_llvm) && !m_type_is_byref (fsig->ret)) {
if ((fsig->pinvoke || might_use_llvm_or_interp) && !m_type_is_byref (fsig->ret)) {
int widen_op = -1;

/*
Expand Down
6 changes: 6 additions & 0 deletions src/mono/mono/mini/mini-amd64.c
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,12 @@ mono_arch_set_native_call_context_ret (CallContext *ccontext, gpointer frame, Mo
interp_cb->frame_arg_to_data ((MonoInterpFrameHandle)frame, sig, -1, storage);
if (temp_size)
arg_set_val (ccontext, ainfo, storage);

// amd64 backend expects I4 return value to be sign extended. Smaller integer types
// are extended in mono_emit_widen_call_res. On arm64, caller always does the sign
// extend for I4 in emit_move_return_value.
if (sig->ret->type == MONO_TYPE_I4 && ainfo->storage == ArgInIReg && ainfo->reg == AMD64_RAX)
ccontext->gregs [AMD64_RAX] = (gint64)*(gint32*)storage;
}
}

Expand Down
Loading