| DeadCodeElimination performs SSA-based dead code elimination as described in
[Cytron, et. al. 91]. The idea behind dead code elimination is that there are
some instructions that do not contribute anything useful to the result of the
program. Most dead code is introduced by other optimizations.
A program statement is live if one or more of the following holds:
- The statement effects program output. In Java this is a lot more than
just I/O. We must be conservative and assume that exceptions and monitor
expression are always live.
- The statement is an assignment statement whose target is used in a live
statement.
- The statement is a conditional branch and there are live statements
whose execution depend on the conditional branch.
Basically, the algorithm proceeds by marking a number of statements as being
pre-live and then uses a worklist to determine which statements must also be
live by the above three conditions.
|