Re: redundant code?
Matthew Fluet <[email protected]>
| Newsgroups | gmane.comp.lang.ml.mlton.devel |
|---|---|
| Message-ID | <[email protected]> |
2011/3/15 Baojian Hua <[email protected]>: > The code at line 46 of "mlton/core-ml/dead-code.fun" seems > to be redundant. The only use of the function "decIsNeeded" > is at line 69: > > if decIsWild dec orelse decIsNeeded dec > > where it is preceeded by a call to "decIsWild". > > Am I missing something? No, I think your analysis is correct. The obvious redundancy was introduced at r3233, which was the integration of the ML Basis System. Prior to that, the compiler made a special distinction between Basis Library code and user code, with only the Basis Library code subject to dead code elimination. This version of dead-code.fun did a pass over the Basis Library using decIsWild and then a filtering pass using decIsNeeded. In that situation, decIsNeeded must subsume decIsWild so as to not filter out the wild decs. With the integration of the ML Basis System, we use annotations to govern which code is subject to dead code elimination (in practice, it is still only the Basis Library). That suggested doing a single reverse walk over the program, using and keeping everything that is either decIsWild or decIsNeeded.