@@ -4756,7 +4756,8 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref,
4756
4756
mono_llvm_add_instr_byval_attr (lcall , 1 + ainfo -> pindex , LLVMGetElementType (param_types [ainfo -> pindex ]));
4757
4757
}
4758
4758
4759
- gboolean is_simd = MONO_CLASS_IS_SIMD (ctx -> cfg , mono_class_from_mono_type_internal (sig -> ret ));
4759
+ MonoClass * retclass = mono_class_from_mono_type_internal (sig -> ret );
4760
+ gboolean is_simd = MONO_CLASS_IS_SIMD (ctx -> cfg , retclass );
4760
4761
gboolean should_promote_to_value = FALSE;
4761
4762
const char * load_name = NULL ;
4762
4763
/*
@@ -4821,11 +4822,17 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref,
4821
4822
case LLVMArgGsharedvtFixedVtype :
4822
4823
values [ins -> dreg ] = LLVMBuildLoad2 (builder , rtype , convert_full (ctx , addresses [call -> inst .dreg ]-> value , pointer_type (rtype ), FALSE), "" );
4823
4824
break ;
4824
- case LLVMArgWasmVtypeAsScalar :
4825
+ case LLVMArgWasmVtypeAsScalar : {
4826
+ /*
4827
+ * If the vtype contains references, making the store volatile ensures there is a reference
4828
+ * on the stack.
4829
+ */
4830
+ gboolean is_volatile = m_class_has_references (retclass );
4825
4831
if (!addresses [call -> inst .dreg ])
4826
4832
addresses [call -> inst .dreg ] = build_alloca_address (ctx , sig -> ret );
4827
- LLVMBuildStore (builder , lcall , convert_full (ctx , addresses [call -> inst .dreg ]-> value , pointer_type (LLVMTypeOf (lcall )), FALSE));
4833
+ emit_store (builder , lcall , convert_full (ctx , addresses [call -> inst .dreg ]-> value , pointer_type (LLVMTypeOf (lcall )), FALSE), is_volatile );
4828
4834
break ;
4835
+ }
4829
4836
default :
4830
4837
if (sig -> ret -> type != MONO_TYPE_VOID )
4831
4838
/* If the method returns an unsigned value, need to zext it */
0 commit comments