Skip to content

Commit

Permalink
Fix error when returning zero sized struct
Browse files Browse the repository at this point in the history
  • Loading branch information
jkurdek committed Aug 6, 2024
1 parent 684998f commit bedf340
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/mono/mono/mini/mini-llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,11 @@ sig_to_llvm_sig_full (EmitContext *ctx, MonoMethodSignature *sig, LLVMCallInfo *
case LLVMArgVtypeAsScalar: {
int size = mono_class_value_size (mono_class_from_mono_type_internal (rtype), NULL);
/* LLVM models this by returning an int */
if (size < TARGET_SIZEOF_VOID_P) {
if (size == 0) {
/* Empty struct with LayoutKind attribute and without specified size */
g_assert(cinfo->ret.nslots == 0);
ret_type = LLVMIntType (8);
} else if (size < TARGET_SIZEOF_VOID_P) {
g_assert (cinfo->ret.nslots == 1);
ret_type = LLVMIntType (size * 8);
} else {
Expand Down

0 comments on commit bedf340

Please sign in to comment.