Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AssignAndPushReferenceValue ignoring var value coercion #2190

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading