@@ -4756,7 +4756,8 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref,
47564756 mono_llvm_add_instr_byval_attr (lcall , 1 + ainfo -> pindex , LLVMGetElementType (param_types [ainfo -> pindex ]));
47574757 }
47584758
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 );
47604761 gboolean should_promote_to_value = FALSE;
47614762 const char * load_name = NULL ;
47624763 /*
@@ -4821,11 +4822,17 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref,
48214822 case LLVMArgGsharedvtFixedVtype :
48224823 values [ins -> dreg ] = LLVMBuildLoad2 (builder , rtype , convert_full (ctx , addresses [call -> inst .dreg ]-> value , pointer_type (rtype ), FALSE), "" );
48234824 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 );
48254831 if (!addresses [call -> inst .dreg ])
48264832 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 );
48284834 break ;
4835+ }
48294836 default :
48304837 if (sig -> ret -> type != MONO_TYPE_VOID )
48314838 /* If the method returns an unsigned value, need to zext it */
0 commit comments