See #637. This does not produce the optimal result, but it does prevent the removal of non-side-effect-free code.