Skip to content

Commit

Permalink
[mono][interp] Fix issue with clearing of unused defs (#80186)
Browse files Browse the repository at this point in the history
If within a basic block we have code like `somevar = val1; ...; somevar = val2` and somevar has no indirects and is not used between the two defines, then we can remove the first assignment. However, MINT_SRC_DST_OFF is a special opcode that writes only to a part of a valuetype, even though it has the vt var as a destination. This means we can't clear the previous define, otherwise we lose data in part of the valuetype.
  • Loading branch information
BrzVlad authored Jan 4, 2023
1 parent 517698d commit 5625fee
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -9057,9 +9057,12 @@ interp_cprop (TransformData *td)
if (num_dregs) {
// Check if the previous definition of this var was used at all.
// If it wasn't we can just clear the instruction
//
// MINT_MOV_DST_OFF doesn't fully write to the var, so we special case it here
if (local_defs [dreg].ins != NULL &&
local_defs [dreg].ref_count == 0 &&
!td->locals [dreg].indirects) {
!td->locals [dreg].indirects &&
opcode != MINT_MOV_DST_OFF) {
InterpInst *prev_def = local_defs [dreg].ins;
if (MINT_NO_SIDE_EFFECTS (prev_def->opcode)) {
for (int i = 0; i < mono_interp_op_sregs [prev_def->opcode]; i++)
Expand Down

0 comments on commit 5625fee

Please sign in to comment.