Commit Graph

66 Commits

Author SHA1 Message Date
Anna Zaks
f7606b1439 Warn on unreachable user code after a call to a noreturn function.
Swift SVN r9764
2013-10-29 22:27:24 +00:00
Anna Zaks
27328ac459 Warn on unreachable code due to a constant condition in a switch over enum.
Swift SVN r9679
2013-10-25 21:55:12 +00:00
Anna Zaks
b15085ae3e [DCE] Add a note about the branch that has caused the unreachable code warning.
Swift SVN r9607
2013-10-23 00:04:19 +00:00
Anna Zaks
742c90fcc2 [DCE] Add unreachable code warning to DCE pass.
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
2013-10-18 23:21:24 +00:00
Anna Zaks
563dc79008 [SIL] + a bit of debug output
Swift SVN r8824
2013-10-01 23:02:32 +00:00
Joe Groff
82a18333ed SIL: Purge SpecializeInst.
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
2013-09-28 00:15:45 +00:00
Anna Zaks
6ad7454df0 [SIL DCE] Chain optimization rounds to ensure true/false folds.
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
2013-09-23 20:57:18 +00:00
Anna Zaks
5b71c8dcc5 [SIL] Propagate basic block arguments.
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
2013-09-20 21:53:28 +00:00
Anna Zaks
4beee47c83 [SIL DCE] Reapply r8471: Constant fold SwitchUnionInst and SwitchIntInst.
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
2013-09-20 17:53:42 +00:00
Anna Zaks
3fef691010 [SIL DCE] revert folding of SwitchUnionInst and SwitchIntInst (r8471)
Until further investigation..
This change triggered a test failure (which was masked at the time).

Swift SVN r8497
2013-09-20 16:25:09 +00:00
Anna Zaks
cf5d78ef34 [SIL DCE] + comments
Swift SVN r8496
2013-09-20 16:25:08 +00:00
Joe Groff
e109124186 Replace 'union' keyword with 'enum'.
This only touches the compiler and tests. Doc updates to follow.

Swift SVN r8478
2013-09-20 01:33:14 +00:00
Anna Zaks
bce75895bd [SIL DCE] Constant fold SwitchUnionInst and SwitchIntInst when possible.
Swift SVN r8473
2013-09-19 23:41:04 +00:00
Anna Zaks
8208bf63b6 [SIL Loc] Replace calls to SILLocation() with more specific locations.
(Ideally, I’d like to get rid of SILLocation() to force the API user to always provide a non-null location.)

Swift SVN r7818
2013-08-30 23:41:38 +00:00
Anna Zaks
939badfe02 [SIL] Move recursivelyDeleteTriviallyDeadInstructions so that it could be used by other passes.
Swift SVN r7250
2013-08-15 01:19:57 +00:00
Stephen Lin
8d90466523 Reorganize SIL source tree: move lib/SIL/SILGen -> lib/SILGen, move lib/SIL/Passes -> lib/SILPasses, add lib/SILPasses/Utils
Swift SVN r7246
2013-08-14 23:47:29 +00:00