Refactor optimizer to track upvalue usage
The `UsageInfo` struct has been updated to include tracking for `used_upvalues` and `assigned_upvalues`. The `collect_usage` function has been modified to handle these new fields when encountering `Address::Upvalue`. The `map_params_to_args` function now takes `body_usage` as an argument to ensure that parameters assigned to or used in the body are correctly substituted. A new helper function, `collect_parameter_slots_set`, has been added to gather all parameter slots within a pattern. The inlining logic in `Optimizer::inline_call` has been enhanced to prevent inlining if a parameter is used or assigned in the function body but cannot be substituted. This addresses a bug where aggressive inlining could lead to incorrect code generation when parameters were reassigned. A new integration test, `test_closure_reassignment_optimization_bug`, has been added to specifically target and verify the fix for this inlining issue.
This commit is contained in:
@@ -31,6 +31,7 @@ Wichtig: zentraler Einstiegspunkt ist Delphi/Myc.Ast.Environment.pasund die dort
|
||||
* Wir wollen die Sprachfeatures von Rust nutzen.
|
||||
* Der Code soll aber so gut wie möglich nach Rust-Style-Guidelines geschrieben werden.
|
||||
* Dokumentation nach Rust-Regeln.
|
||||
* Im Code und den Kommentaren muss alles auf englisch sein.
|
||||
|
||||
## Interaktion
|
||||
|
||||
@@ -38,6 +39,7 @@ Wichtig: zentraler Einstiegspunkt ist Delphi/Myc.Ast.Environment.pasund die dort
|
||||
* Wenn clippy etwas vorschlägt, von dem du glaubst, dass es nicht stabil ist, dann überprüfe die aktuelle Version. Wahrscheinlich ist das Feature mittlerweile im trunk. Wir gehen immer davon aus, dass clippy recht hat.
|
||||
* Keine Interaktion mit GIT. Kein Commit, oder ähnliches. Schlage auch nichts dergleichen vor.
|
||||
* Gehe immer schrittweise vor. Zeige mir, was du vor hast, bevor du Code erzeugst.
|
||||
* Sprich im Chat deutsch mit mir.
|
||||
|
||||
## Testing & Debugging
|
||||
|
||||
|
||||
Reference in New Issue
Block a user