Skip to content

Commit

Permalink
[mono] Handle enum return type when inlining CreateInstance (#91061)
Browse files Browse the repository at this point in the history
Use underlying base type when deciding how to inline a
CreateInstance invocation in mini_emit_inst_for_method.

Fixes #90292
(Mono abort causing .NET 8 msbuild regression).

Co-authored-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Co-authored-by: Larry Ewing <lewing@microsoft.com>
  • Loading branch information
3 people authored Aug 28, 2023
1 parent 4122c63 commit fe64d25
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/mono/mono/mini/intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,9 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
MonoType *t = method_context->method_inst->type_argv [0];
MonoClass *arg0 = mono_class_from_mono_type_internal (t);
if (m_class_is_valuetype (arg0) && !mono_class_has_default_constructor (arg0, FALSE)) {
if (m_class_is_primitive (arg0)) {
if (m_class_is_primitive (arg0) || m_class_is_enumtype (arg0)) {
if (m_class_is_enumtype (arg0))
t = mono_class_enum_basetype_internal (arg0);
int dreg = alloc_dreg (cfg, mini_type_to_stack_type (cfg, t));
mini_emit_init_rvar (cfg, dreg, t);
ins = cfg->cbb->last_ins;
Expand Down

0 comments on commit fe64d25

Please sign in to comment.