Commit Graph

24822 Commits

Author SHA1 Message Date
Owen Voorhees
0ffb727dfe [DependencyVerifier] Route DependencyVerifier diags through DiagnosticEngine 2020-03-05 12:41:04 -08:00
Michael Gottesman
621573e839 [semantic-arc-opts] Refactor out convert to guarantee code into a method on LiveRange.
Should be NFC.

I am doing this since when I am eliminating phi webs, I need this exact
functionality.
2020-03-05 11:49:36 -08:00
Hamish Knight
c26eb11baf Merge pull request #30190 from hamishknight/the-beginning-of-the-pipeline-end
Requestify SourceFile parsing
2020-03-05 11:17:24 -08:00
Slava Pestov
cf451c2ebe Merge pull request #30228 from slavapestov/stronger-invariant-apply-inst-substitution-map
SIL: Verify that the substitution map of an apply instruction matches the callee
2020-03-05 14:11:33 -05:00
AG
97d8c99984 Merge pull request #30219 from bitjammer/acgarland/rdar-59128787-sg-include-synthesized
[SymbolGraph] Emit synthesized members
2020-03-05 09:46:22 -08:00
Alexis Laferrière
34353b8a40 Merge pull request #30215 from xymus/spi-isnt-internal
[SPI] Requestify, inherit SPI groups and better diagnostics
2020-03-05 06:13:01 -08:00
Slava Pestov
5aee91053f SIL: Verify that the substitution map of an apply instruction matches the callee
This fixes part of the problem in <rdar://problem/49509247>, but not the
actual bug.
2020-03-05 00:40:37 -05:00
Michael Gottesman
974f62a5c9 [gardening] Add comments explaining what alloc_stack [dynamic_lifetime] means.
Found the meaning by looking at when Definite Initialization marks alloc_stack
with that marker.

For those who are unware like me, it means the liveness of the value in the
alloc_stack is conditional in some way (i.e. conditional init, destroy, etc).
2020-03-04 19:57:40 -08:00
Michael Gottesman
04007f2583 Merge pull request #30201 from gottesmm/pr-6331d582c9865bfa1aca1fee9d93aeac11f93f4b
[ownership] Convert LiveRange to use Operands.
2020-03-04 19:42:44 -08:00
swift-ci
6e7184287c Merge pull request #30204 from atrick/no-borrow-address 2020-03-04 19:23:46 -08:00
fischertony
6f08216936 Sema: Support where clauses on contextually generic decls 2020-03-05 04:37:12 +03:00
Michael Gottesman
fced2398c5 [semantic-arc] Change LiveRange to work with Operand instead of Operand->getUser().
This is just better information to have since one wants to not only know the
instruction, but also the specific value used on the instruction since behavior
can vary depending upon that. The operand is what ties the two together so it is
a natural fit.

Now that this is done, I am going to work on refactoring out converting a
LiveRange from @owned -> @guaranteed. It will be a consuming operation using a
move operator since once the transformation has completed, the LiveRange no
longer exists.

I need this refactored functionality since I am going to need it when
eliminating phi-webs.
2020-03-04 17:07:48 -08:00
Michael Gottesman
15c7e3a56a Merge pull request #30200 from gottesmm/pr-f782df1b8f778cdddc48f8343fb0876f598f9012
[ownership] Remove BranchPropagatedUser.
2020-03-04 16:59:16 -08:00
Alexis Laferrière
26c6a18345 [Sema] Improve type-checking of the use and exposability of SPIs 2020-03-04 16:43:05 -08:00
Alexis Laferrière
c61cc6fe4e [AST] Add SPI information to public access scopes 2020-03-04 16:42:18 -08:00
Alexis Laferrière
7bd585001a [AST] Intro and use isSPI and getSPIGroups 2020-03-04 16:42:18 -08:00
Alexis Laferrière
fd4feacb0d [AST] Intro request to list declared and inherited SPI groups 2020-03-04 16:41:54 -08:00
Andrew Trick
653a5aae2a Prevent begin_borrow on addresses and cleanup address access utils. 2020-03-04 16:32:08 -08:00
Ashley Garland
f0887fa245 [SymbolGraph] Emit synthesized members
Emit copies of default implementations in protocol extensions and superclass declarations in conforming types and subclasses respectively using a virtual USR, i.e. `${REAL_USR}::SYNTHESIZED::${CONFORMING_OR_SUBCLASS_TYPE_USR}`.

- Add a -skip-synthesized-members option to skip these synthesized members.

- Create a new wrapping `Symbol` type that can also contain a base type declaration as well as the inherited declaration for those synthesized cases. Move some symbol-specific APIs there.

- Doc comments can “cascade” down to protocol extensions or refinements in concrete types. When emitting the doc comment for a symbol, look up through to superclasses or protocol requirements for where a doc comment is actually written.

- Clean up filtering of implicitly private (e.g. “public underscored”) types

rdar://problem/59128787
2020-03-04 16:04:21 -08:00
Kuba (Brecka) Mracek
0d400ca310 Merge branch 'master' into mracek/arm64e 2020-03-04 09:36:25 -08:00
Mike Ash
614f4becef [Runtime] Reject suffixes on ObjC mangled class names.
The demangler tolerates arbitrary suffixes on mangled names, and parses them as a Suffix node. When looking up a class by an ObjC mangled name, we don't want such demanglings to succeed, because this will result in false positives. It's expected that NSClassFromString(someClassName + "some suffix") will fail, unless something has actually created a class with that suffix.

rdar://problem/60012296
2020-03-04 12:05:35 -05:00
Michael Gottesman
be16822af9 [ownership] Remove BranchPropagatedUser.
The only reason why BranchPropagatedUser existed was because early on in SIL, we
weren't sure if cond_br should be able to handle non-trivial values in
ossa. Now, we have reached the point where we have enough experience to make the
judgement that it is not worth having in the representation due to it not
holding its weight.

Now that in ToT we have banned cond_br from having non-trivial operands in ossa,
I can just eliminate BranchPropagatedUser and replace it with the operands that
we used to construct them!

A few notes:

1. Part of my motiviation in doing this is that I want to change LiveRange to
store operands instead of instructions. This is because we are interested in
being able to understand the LiveRange at a use granularity in cases where we
have multiple operands. While doing this, I discovered that I needed
SILInstructions to use the Linear Lifetime Checker. Then I realized that now was
the time to just unwind BranchPropagatedUser.

2. In certain places in SemanticARCOpts, I had to do add some extra copies to
transform arrays of instructions from LiveRange into their operand form. I am
going to remove them in a subsequent commit when I change LiveRange to work on
operands. I am doing this split to be incremental.

3. I changed isSingleInitAllocStack to have an out array of Operand *. The only
user of this code is today in SemanticARCOpts and this information is fed to the
Linear Lifetime Checker, so I needed to do it.
2020-03-04 07:35:23 -08:00
fischertony
eb539e62f8 Parse: Diagnose where clauses early on non-generic top-level declarations 2020-03-04 15:04:28 +03:00
Slava Pestov
a60ffb9e26 Merge pull request #30196 from slavapestov/abi-check-cleanup
AST: Centralize ABI-related deployment target checks
2020-03-04 02:07:52 -05:00
Robert Widmann
ef149d5c86 Merge pull request #30135 from CodaFi/verily-i-depend-on-thee
[Incremental] Introducing: DependencyVerifier
2020-03-03 22:01:38 -08:00
Brent Royal-Gordon
a3e3598b9a Make cross-importing faster
We previously computed cross-imports by comparing N transitive imports against N transitive imports. This is wasteful, because at least one of the two modules in a pair has to actually declare a cross-import overlay for us to discover one, and the vast majority of modules don’t declare any.

This commit makes us instead compare N transitive imports against M transitive imports which are known to declare at least one cross-import overlay. Since N is potentailly in the thousands while M is perhaps in the double digits, this should be good for a substantial time savings.

However, this optimization has made a test of another cross-import performance optimization fail—not because we have regressed on that, but because it skips work the test case expects us to perform. I have XFAILed that test for now.

Fixes <rdar://problem/59538458>.
2020-03-03 21:56:19 -08:00
Hamish Knight
e9a7427712 [SILOptimizer] Add pipeline execution request (#29552)
[SILOptimizer] Add pipeline execution request
2020-03-03 20:24:28 -08:00
Slava Pestov
3904fe83fb AST: Centralize ABI-related deployment target checks
There were a couple of methods in LangOptions and some related ones in
Availability and ASTContext that were added more recently.

Refactor the three older checks to the newer scheme.
2020-03-03 22:49:19 -05:00
Robert Widmann
f85ec3825f Address review feedback 2020-03-03 16:46:04 -08:00
Michael Gottesman
847ad07847 [ownership] Move LinearLifetimeChecker from OwnershipUtils.h -> LinearLifetimeChecker.h
OwnershipUtils.h is growing a bit and I want to use it to store abstract higher
level utilities for working with ossa. LinearLifetimeChecker is just a low level
detail of that, so it makes sense to move it out now.
2020-03-03 16:15:25 -08:00
Hamish Knight
df34be72e8 [AST] Remove parsing ASTStages
Now that the parsing stage has been
requestified, these are no longer
meaningful.
2020-03-03 15:53:18 -08:00
Hamish Knight
011f4f1584 Requestify SourceFile parsing
Add ParseSourceFileRequest that parses a SourceFile
for its top-level decls.
2020-03-03 15:53:18 -08:00
Michael Gottesman
ef309b8830 Merge pull request #30179 from gottesmm/pr-413b415c765eb62debe5d09415f22e89952479af
[ownership] Clean up BorrowScopeIntroducingValue.
2020-03-03 13:21:38 -08:00
Hamish Knight
92ba9483b9 Merge pull request #30166 from hamishknight/three-flags
Move parsing flags onto SourceFile
2020-03-03 13:14:21 -08:00
Andrew Trick
d47b802950 Merge pull request #30173 from atrick/fix-temp-rvalue-access
Fix MemBehavior and TempRValueOpt to handle access markers
2020-03-03 11:10:16 -08:00
Visoiu Mistrih Francis
aaab1869af Merge pull request #29650 from francisvm/sil-remark-streamer
[Remarks] Add a specialized RemarkStreamer for SIL remarks
2020-03-03 09:30:17 -08:00
Andrew Trick
badc5658bb Fix SIL MemBehavior queries with access markers.
This is in prepration for other bug fixes.

Clarify the SIL utilities that return canonical address values for
formal access given the address used by some memory operation:

- stripAccessMarkers
- getAddressAccess
- getAccessedAddress

These are closely related to the code in MemAccessUtils.

Make sure passes use these utilities consistently so that
optimizations aren't defeated by normal variations in SIL patterns.

Create an isLetAddress() utility alongside these basic utilities to
make sure it is used consistently with the address corresponding to
formal access. When this query is used inconsistently, it defeats
optimization. It can also cause correctness bugs because some
optimizations assume that 'let' initialization is only performed on a
unique address value.

Functional changes to Memory Behavior:

- An instruction with side effects now conservatively still has side
  effects even when the queried value is a 'let'. Let values are
  certainly sensitive to side effects, such as the parent object being
  deallocated.

- Return the correct MemBehavior for begin/end_access markers.
2020-03-03 09:24:18 -08:00
Owen Voorhees
69b513afaf [Diagnostics] Updated (experimental) diagnostic printing style (#30027)
* [Diagnostics] Experimental diagnostic printing updates

This new style directly annotates small snippets of code with
error messages, highlights and fix-its. It also uses color more
effectively to highlight important segments.

* [Diagnostics] Stage educational notes and experimental formatting behind separate frontend flags

educational notes -> -enable-educational-notes
formatting -> -enable-experimental-diagnostic-formatting

* [Diagnostics] Refactor expensive line lookups in diag formatting

* [Diagnostics] Refactor some PrintingDiagnosticConsumer code into a flush method

* [Diag-Experimental-Formatting] Custom formatting for Xcode editor placeholders

* [Diag-Experimental-Formatting] Better and more consistent textual description of fix its

* [Diags-Experimental-Formatting] Handle lines with tab characters correctly when rendering highlights and messages

Tabs are converted to 2 spaces for display purposes.

* [Diag-Experimental-Formatting] Refactor byte-to-column mapping for efficiency

* [Diag-Experimental-Formatting] Fix line number indent calculation

* [Diag-Experimental-Formatting] Include indicators of insertions and deletions in the highlight line

Inserts are underlined by green '+' chars, deletions by red '-' chars.

* [Diag-Experimental-Formatting] Change color of indicator arrow for non-ASCII anchored messages
* [Diag-experimental-formatting] Make tests less sensitive to line numbering

* [Diag-Experimental-Formatting] Update tests to allow windows path separators

* [Diag-Experimental-Formatting] Bug fixes for the integrated REPL
2020-03-03 08:48:32 -08:00
Kuba (Brecka) Mracek
5d918e5ee1 Merge branch 'master' into mracek/arm64e 2020-03-03 08:28:01 -08:00
Joe Groff
d8e8b3d307 Merge pull request #30105 from jckarter/objc-opt-self
IRGen: Invoke objc_opt_self directly when available.
2020-03-03 07:29:27 -08:00
Suyash Srijan
13487edd09 [Typechecker] Diagnose key paths with contextual type but no leading dot (#30164) 2020-03-03 12:17:32 +00:00
Michael Gottesman
ae2bef9f1e Merge pull request #30069 from gottesmm/pr-cdc5d32f1a5317b8716c016a0e72f9ee40eae4dd
[semantic-arc] Change StorageGuaranteesLoadVisitor::visitClassAccess to find borrow scope introducers using utilities from OwnershipUtils.h.
2020-03-02 22:58:01 -08:00
Michael Gottesman
6fe7ad2676 [ownership] Clean up BorrowScopeIntroducingValue.
Specifically, I got rid of the constructors for BorrowScopeIntroducingValue and
made it so one can only construct BorrowScopeIntroducingValue from the static
constructor.

I also changed the place where we mapped values from BorrowScopeIntroducingValue
-> BorrowScopeIntroducingValueKind. This simplifies the whole thing.
2020-03-02 22:24:02 -08:00
Francis Visoiu Mistrih
e724ebab6b [Remarks] Add a specialized RemarkStreamer for SIL remarks
This allows the usage of the whole remark infrastructure developed in
LLVM, which includes a new binary format, metadata in object files, etc.

This gets rid of the YAMLTraits-based remark serialization and does the
plumbing for hooking to LLVM's main remark streamer.

For more about the idea behind LLVM's main remark streamer, see the
docs/Remarks.rst changes in https://reviews.llvm.org/D73676.

The flags are now:

* -save-optimization-record: enable remarks, defaults to YAML
* -save-optimization-record=<format>: enable remarks, use <format> for
serialization
* -save-optimization-record-passes <regex>: only serialize passes that
match <regex>.

The YAMLTraits in swift had a different `flow` setting for the debug
location, resulting in some test changes.
2020-03-02 18:33:20 -08:00
Robert Widmann
d3edb5b15a [Incremental] Plumb -verify-incremental-dependencies Through The Frontend and Driver
When enabled at the driver level, the frontends will inherit the flag. For each frontend that recieves this option, all primaries will have their reference dependencies validated.
2020-03-02 16:45:37 -08:00
Robert Widmann
101dd2d9f7 Merge pull request #30167 from davidungar/ref-name-tracker-factor-3-2-20
[NFC, Incremental] Factor used Decl enumeration in preparation for dependency verifier
2020-03-02 16:45:28 -08:00
David Ungar
85d70b59de Move use enumeration to ReferencedNameTracker 2020-03-02 14:39:47 -08:00
David Ungar
fa3d4c5df3 Move fine-grained NodeKind to ReferenceDependencyKeys.h 2020-03-02 14:34:00 -08:00
David Ungar
f6f086ff85 Add Decl::isPrivateToEnclosingFile 2020-03-02 14:23:47 -08:00
Hamish Knight
f56b061407 [Parse] Check the SourceFile for #if evaluation
Remove the `EvaluateConditionals` flags from the
parser, and instead query the source file.

This commit also changes ParserUnit such that it
doesn't evaluate #if conditions by default, as
none of its clients appear to require it. The
only client that wasn't explicitly disabling #if
evaluation and is processing the resulting AST is
swift-indent, so this commit also adds a test to
ensure it continues to work correctly with #if
decls.
2020-03-02 14:12:37 -08:00