Fix DCE false positives on ReScript compiler CMT analysis#206
Fix DCE false positives on ReScript compiler CMT analysis#206JonoPrest wants to merge 10 commits into
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 35a8181be8
ℹ️ 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".
| addModuleValueReferences ~locFrom:argumentExpr.mod_loc | ||
| argumentExpr.mod_type |
There was a problem hiding this comment.
Restrict functor refs to required signature
When a functor is applied to a module whose inferred signature contains values beyond the functor parameter signature, this walks argumentExpr.mod_type and adds references to every value in the actual argument module. For example, module Arg = struct type t = int let compare = ... let unused = ... end; module S = Set.Make(Arg) will keep Arg.unused live even though the functor cannot access it, causing DCE to miss genuinely dead values in functor argument modules.
Useful? React with 👍 / 👎.
This fixes several DCE false positives found while running
reanalyze -dce-cmt _build/defaultagainst the ReScript compiler afterdune build @check.The issues were mostly around CMT-based analysis losing liveness information in compiler-shaped code:
cmt_sourcefilewhen typedtree locations point at missing generated/preprocessed files, like*.cppo.mlSet.Make(Ordered).compareEach fix is paired with a regression test that fails on
ocaml-5-3and passes with the fix.