Skip to content

Commit 76ece90

Browse files
[release/9.0-staging] [wasm][AOT] fix codegen for small structs on stack (dotnet#118416)
1 parent 1080780 commit 76ece90

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/mono/mono/mini/mini-wasm.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -798,18 +798,20 @@ mini_wasm_is_scalar_vtype (MonoType *type, MonoType **etype)
798798
} else if (MONO_TYPE_ISSTRUCT (t)) {
799799
if (!mini_wasm_is_scalar_vtype (t, etype))
800800
return FALSE;
801-
} else if (!((MONO_TYPE_IS_PRIMITIVE (t) || MONO_TYPE_IS_REFERENCE (t) || MONO_TYPE_IS_POINTER (t)))) {
801+
} else if (!(MONO_TYPE_IS_PRIMITIVE (t) || MONO_TYPE_IS_REFERENCE (t) || MONO_TYPE_IS_POINTER (t))) {
802802
return FALSE;
803803
} else {
804804
if (etype)
805805
*etype = t;
806806
}
807807
}
808808

809-
if (etype) {
810-
if (!(*etype))
811-
*etype = mono_get_int32_type ();
809+
// empty struct
810+
if (nfields == 0 && etype) {
811+
*etype = m_class_get_byval_arg (mono_defaults.sbyte_class);
812812
}
813813

814+
g_assert (!etype || *etype);
815+
814816
return TRUE;
815817
}

0 commit comments

Comments
 (0)