Skip to content

Commit

Permalink
[mono][jit] Avoid doing copy propagation on ldaddr for gsharedvt vari…
Browse files Browse the repository at this point in the history
…ables. (#87713)

Ldaddr requires the emission of dummy uses for
gsharedvt_info_var/gsharedvt_locals_var and the copy wouldn't have these,
leading to register allocation problems.

Fixes #87551.
  • Loading branch information
vargaz authored Jun 21, 2023
1 parent 57cfd06 commit fc75f7e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/mono/mono/mini/local-propagation.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,8 @@ mono_local_cprop (MonoCompile *cfg)
} else if (srcindex == 0 && ins->opcode == OP_COMPARE && defs [ins->sreg1]->opcode == OP_PCONST && defs [ins->sreg2] && defs [ins->sreg2]->opcode == OP_PCONST) {
/* typeof(T) == typeof(..) */
mono_constant_fold_ins (cfg, ins, defs [ins->sreg1], defs [ins->sreg2], TRUE);
} else if (ins->opcode == OP_MOVE && def->opcode == OP_LDADDR) {
} else if (ins->opcode == OP_MOVE && def->opcode == OP_LDADDR && !(G_UNLIKELY (cfg->gsharedvt) && mini_is_gsharedvt_variable_klass (def->klass))) {
/* Can't copyprop ldaddr for gsharedvt vars because the copy is missing the uses added by handle_gsharedvt_ldaddr () */
ins->opcode = OP_LDADDR;
ins->sreg1 = -1;
ins->inst_p0 = def->inst_p0;
Expand Down
5 changes: 4 additions & 1 deletion src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -6722,7 +6722,10 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
cfg->gsharedvt_info = info;

var = mono_compile_create_var (cfg, mono_get_int_type (), OP_LOCAL);
/* prevent it from being register allocated */
/*
* Decomposing ldaddr creates uses for this and gsharedvt_locals_var, so
* when we emit an ldaddr, we emit dummy uses for these in handle_gsharedvt_ldaddr ().
*/
//var->flags |= MONO_INST_VOLATILE;
cfg->gsharedvt_info_var = var;

Expand Down
3 changes: 2 additions & 1 deletion src/mono/mono/mini/mini-generic-sharing.c
Original file line number Diff line number Diff line change
Expand Up @@ -2753,7 +2753,7 @@ mono_rgctx_info_type_to_str (MonoRgctxInfoType type)
case MONO_RGCTX_INFO_REFLECTION_TYPE: return "REFLECTION_TYPE";
case MONO_RGCTX_INFO_METHOD: return "METHOD";
case MONO_RGCTX_INFO_METHOD_FTNDESC: return "METHOD_FTNDESC";
case MONO_RGCTX_INFO_METHOD_GSHAREDVT_INFO: return "GSHAREDVT_INFO";
case MONO_RGCTX_INFO_METHOD_GSHAREDVT_INFO: return "METHOD_GSHAREDVT_INFO";
case MONO_RGCTX_INFO_GENERIC_METHOD_CODE: return "GENERIC_METHOD_CODE";
case MONO_RGCTX_INFO_GSHAREDVT_OUT_WRAPPER: return "GSHAREDVT_OUT_WRAPPER";
case MONO_RGCTX_INFO_INTERP_METHOD: return "INTERP_METHOD";
Expand Down Expand Up @@ -2782,6 +2782,7 @@ mono_rgctx_info_type_to_str (MonoRgctxInfoType type)
case MONO_RGCTX_INFO_VIRT_METHOD_CODE: return "VIRT_METHOD_CODE";
case MONO_RGCTX_INFO_VIRT_METHOD_BOX_TYPE: return "VIRT_METHOD_BOX_TYPE";
case MONO_RGCTX_INFO_DELEGATE_TRAMP_INFO: return "DELEGATE_TRAMP_INFO";
case MONO_RGCTX_INFO_GSHAREDVT_CONSTRAINED_CALL_INFO: return "GSHAREDVT_CONSTRAINED_CALL_INFO";
default:
return "<UNKNOWN RGCTX INFO TYPE>";
}
Expand Down

0 comments on commit fc75f7e

Please sign in to comment.