Fixes https://github.com/dotnet/runtime/issues/50955.
}
void
+mono_llvm_add_param_byval_attr (LLVMValueRef param, LLVMTypeRef type)
+{
+ Function *func = unwrap<Argument> (param)->getParent ();
+ int n = unwrap<Argument> (param)->getArgNo ();
+ func->addParamAttr (n, Attribute::getWithByValType (*unwrap (LLVMGetGlobalContext ()), unwrap (type)));
+}
+
+void
mono_llvm_add_instr_attr (LLVMValueRef val, int index, AttrKind kind)
{
#if LLVM_API_VERSION >= 1100
#endif
}
+void
+mono_llvm_add_instr_byval_attr (LLVMValueRef val, int index, LLVMTypeRef type)
+{
+#if LLVM_API_VERSION >= 1100
+ unwrap<CallBase> (val)->addAttribute (index, Attribute::getWithByValType (*unwrap (LLVMGetGlobalContext ()), unwrap (type)));
+#else
+ CallSite (unwrap<Instruction> (val)).addAttribute (index, Attribute::getWithByValType (*unwrap (LLVMGetGlobalContext ()), unwrap (type)));
+#endif
+}
+
void*
mono_llvm_create_di_builder (LLVMModuleRef module)
{
mono_llvm_add_param_attr (LLVMValueRef param, AttrKind kind);
void
+mono_llvm_add_param_byval_attr (LLVMValueRef param, LLVMTypeRef type);
+
+void
mono_llvm_add_instr_attr (LLVMValueRef val, int index, AttrKind kind);
+void
+mono_llvm_add_instr_byval_attr (LLVMValueRef val, int index, LLVMTypeRef type);
+
#if defined(ENABLE_LLVM) && defined(HAVE_UNWIND_H)
G_EXTERN_C _Unwind_Reason_Code mono_debug_personality (int a, _Unwind_Action b,
uint64_t c, struct _Unwind_Exception *d, struct _Unwind_Context *e);
if (ainfo && ainfo->storage == LLVMArgVtypeByVal)
mono_llvm_add_instr_attr (lcall, 1 + ainfo->pindex, LLVM_ATTR_BY_VAL);
+
+#ifdef TARGET_WASM
+ if (ainfo && ainfo->storage == LLVMArgVtypeByRef)
+ /* This causes llvm to make a copy of the value which is what we need */
+ mono_llvm_add_instr_byval_attr (lcall, 1 + ainfo->pindex, param_types [ainfo->pindex]);
+#endif
}
gboolean is_simd = MONO_CLASS_IS_SIMD (ctx->cfg, mono_class_from_mono_type_internal (sig->ret));
/* For OP_LDADDR */
cfg->args [i + sig->hasthis]->opcode = OP_VTARG_ADDR;
}
+
+#ifdef TARGET_WASM
+ if (ainfo->storage == LLVMArgVtypeByRef) {
+ /* This causes llvm to make a copy of the value which is what we need */
+ mono_llvm_add_param_byval_attr (LLVMGetParam (method, pindex), LLVMTypeOf (LLVMGetParam (method, pindex)));
+ }
+#endif
}
g_free (names);