This commit teaches DCE to warn about unreachable code. The general approach
is to record the BasicBlocks that become unreachable as we are folding
conditional branches. Later, when all the reachability info is available,
we walk though these blocks and issue warnings on the ones that contain SIL
instructions that correspond to user code. We determine if a SIL instruction
corresponds to user code by looking at the SILLocations.
TODO:
- Note, that folding conditions is not as strong right now. Specifically,
folding 'x == 0' for Ints is blocked by generics specialization. This limits
the applicability of the warning on real code.
- We need to extend this to other foldable terminators (not only conditional branch).
- We could print a note telling the user which condition has been folded in
order to get the unreachable code.
Swift SVN r9506
Make ApplyInst and PartialApplyInst directly take substitutions for generic functions instead of trying to stage out substitutions separately. The legacy reasons for doing this are gone.
Swift SVN r8747
This is an ad-hoc, temporary solution.
(TODO: More tests with real 'true' & 'false' after they get deserialized
from stdlib and inlined.)
Swift SVN r8569
Propagate/remove basic block input values when all predecessors supply
the same arguments. Another optimization needed to fold 'true'.
TODO: I need to figure out additional surcumstances in which to to trigger this
optimization and if we need to rerun CCP after this. (For example, we need to
rerun this after constant folding the terminator in order to fold 'true'.)
Swift SVN r8518
Includes the fix for the crash - pass the payload as an argument to the
successor blocks when available. (By looking at the documentation and the
existing test cases, successors of SwitchIntInst do not take arguments.)
Swift SVN r8502