Skip to content

Commit

Permalink
Fix AssignAndPushReferenceValue ignoring var value coercion
Browse files Browse the repository at this point in the history
  • Loading branch information
ike709 committed Jan 28, 2025
1 parent d12f5ef commit a89c4aa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions DMCompiler/Optimizer/PeepholeOptimizations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,11 @@ public bool CheckPreconditions(List<IAnnotatedBytecode> input, int index) {
AnnotatedBytecodeReference assignTarget = firstInstruction.GetArg<AnnotatedBytecodeReference>(0);
AnnotatedBytecodeReference pushTarget = secondInstruction.GetArg<AnnotatedBytecodeReference>(0);

// Assigning certain values to certain vars (e.g. setting a SrcField like "dir" to null)
// actually causes the value to be coerced to something different than the value on the stack.
// We don't have a good way to identify those vars at this point, so just restrict the opt to locals and args since those shouldn't have side effects
if (pushTarget.RefType != DMReference.Type.Local && pushTarget.RefType != DMReference.Type.Argument) return false;

return assignTarget.Equals(pushTarget);
}

Expand Down

0 comments on commit a89c4aa

Please sign in to comment.