Emit less garbage without opts, if it has no side effects#1141
Emit less garbage without opts, if it has no side effects#1141
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 044797f8e8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (ImVar var : analyzer.directlySetVariables(expr)) { | ||
| if (var.isGlobal()) { | ||
| return true; |
There was a problem hiding this comment.
Treat local writes in RHS as side effects
The new side‑effect filter only treats writes to globals as effects, so any RHS expression that mutates a local (e.g., a statement‑block expression that does x = 1; 42 and is assigned to an otherwise unused variable) will now be dropped by removeGarbage. That changes semantics because the local update is observable later in the same function, even though it isn’t global. Consider flagging local writes as side effects when the target variable is later read, or conservatively treat any directlySetVariables hit as a side effect in this context.
Useful? React with 👍 / 👎.
This reverts commit 044797f.
No description provided.