The flag -experimental-skip-non-inlinable-function-bodies-without-types
is built in the emit-module-separately phase to quickly extract the API
of the target module. It is designed to not skip functions with nested
types as these are used by LLDB.
This logic relies on a simple heuristic to find nested type. Let's make
sure it detects tyealiases and actors.
rdar://120928396
Previously, the initializer expressions of lazy vars would only be marked as
subsumed when the getter body for the var was synthesized. This didn't work
with `-experimental-lazy-typechecking` since accessor synthesis was not
guaranteed to happen. Consequently, SILGen would emit the initializer even
though it was already subsumed and then assert/crash since the init had also
not been checked and contextualized. Now lazy var inits are marked subsumed in
the request creating storage.
Resolves rdar://118421753
Function bodies are skipped during typechecking when one of the
-experimental-skip-*-function-bodies flags is passed to the frontend. This was
implemented by setting the "body kind" of an `AbstractFunctionDecl` during decl
checking in `TypeCheckDeclPrimary`. This approach had a couple of issues:
- It is incompatible with skipping function bodies during lazy typechecking,
since the skipping is only evaluated during a phase of eager typechecking.
- It prevents skipped function bodies from being parsed on-demand ("skipped" is
a state that is distinct from "parsed", when they ought to be orthogonal).
This needlessly prevented complete module interfaces from being emitted with
-experimental-skip-all-function-bodies.
Storing the skipped status of a function separately from body kind and
requestifying the determination of whether to skip a function solves these
problems.
Resolves rdar://116020403
The skip-function-bodies.swift test previously relied on `-emit-sorted-sil` to
control the order of SIL emission for matching CHECK: lines. I found that this
made the test too difficult to evolve, so I've re-written the test to instead
use SILGen's natural output order. This makes it much more straightforward to
add new test cases at the right location in the file.
There are a number of additional improvements to the test:
- SILGen without any function body skipping is now checked as a baseline to
ensure that all the checks are in the right order. Previously, most of the
negative CHECK lines were not properly ordered in the file, so they could have
missed regressions.
- Every declaration in the test has a set of exhaustive CHECK lines covering
each of the outputs explicitly. While more verbose, it should be clearer what
is expected for every declaration.
- Module interfaces are emitted with the proper flags and are typechecked to
verify they are valid.
- Superfluous diagnostics (e.g. unused variables) have been minimized to
improve the experience of debugging failures.
The skip-function-bodies.swift test previously relied on `-emit-sorted-sil` to
control the order of SIL emission for matching CHECK: lines. I found that this
made the test too difficult to evolve, so I've re-written the test to instead
check SILGen's output by extracting just the `string_literal` lines and then
sorting them. This makes it much more straightforward to add new test cases at
the right location in the file.
There are a number of additional improvements to the test:
- SILGen without any function body skipping is now checked as a baseline to
ensure that all the checks are in the right order. Previously, most of the
negative CHECK lines were not properly ordered in the file, so they could have
missed regressions.
- Every declaration in the test has a set of exhaustive CHECK lines covering
each of the outputs explicitly. While more verbose, it should be clearer what
is expected for every declaration.
- Module interfaces are emitted with the proper flags and are typechecked to
verify they are valid.
- Superfluous diagnostics (e.g. unused variables) have been minimized to
improve the experience of debugging failures.
This makes the main skip-function-bodies.swift test easier to maintain because
there are fewer `RUN:` lines to wade through in the output. The early `RUN:`
lines that redirect stderr to stdout were also making iterative debugging very
painful.
This frontend flag can be used as an alternative to
-experimental-skip-non-inlinable-function-bodies that doesn’t skip
functions defining nested types. We want to keep these types as they are
used by LLDB. Other functions ares safe to skip parsing and
type-checking.
rdar://71130519
Adds a new flag "-experimental-skip-all-function-bodies" that skips
typechecking and SIL generation for all function bodies (where
possible).
`didSet` functions are still typechecked and have SIL generated as their
body is checked for the `oldValue` parameter, but are not serialized.
Parsing will generally be skipped as well, but this isn't necessarily
the case since other flags (eg. "-verify-syntax-tree") may force delayed
parsing off.