Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
makes dead code elimination less conservative (#906)
* maked dead code elimination less conservative As was noted in #905 the optimization passes sometimes misses an opportunity to remove obvious assignments. The underlying reason is that we compute a very conservative set of variables which are used for interprocedural communication. And if a variable is a member of this set then we do not delete it (under assumption, that it could be used in other subroutines). What was overconservative is that all versions of the same variable were protected, while only the last definition one could be used for interprocedural communication. The propsed change relaxes the protected set, and removes only the last version of a variable from the set of the dead variables. Fixes #905 * makes it sound Unfortunately, the original proposal was unsound, as the assumption that only the last definition should be preserved is implied by the assumption that only the last definition is used for interprocedural communication, which is totally wrong. The liveness property is propagated from each call (and indirect jump) to all members of the protected set. We're using the SSA form for def-use analysis which is inherently intraprocedural, so to preserve the liveness of the variables with the interprocedural scope we use the protected set as an overapproximation. A tighter approximation would be to reinstantiate their liveness after each call or indirect jump. However, this would require tampering with the ssa algorithm, that we don't want to do right now. The updated solution reinstantiates liveness of protected variables at the end of each block, even the block is not a call or even jump. The liveness is killed by the first use of protection, so it is propagated only to the last (if any) definition. * removes a dead function note: this PR shall be merged after #907 is merged * drops debug info * drops a change that is irrelevant to the proposal to make it cleaner
- Loading branch information