Commit Graph

18337 Commits

Author SHA1 Message Date
Pavel Yaskevich
1ea3ebc805 Merge pull request #18780 from xedin/refactor-decl-req-diags-into-method
[Diagnostics] NFC: Move logic common to all requirement failures into…
2018-08-17 11:58:16 -07:00
Mike Ash
ba25b624f8 Merge pull request #18737 from mikeash/change-swift_unknownX-to-swift_unknownObjectX
[Runtime] Rename swift_unknown* functions to swift_unknownObject*.
2018-08-17 14:19:27 -04:00
Jordan Rose
a17dbfbf29 Merge pull request #18778 from jrose-apple/towards-stability
[ModuleInterface] More changes to printing and parsing .swiftinterface files
2018-08-17 09:10:57 -07:00
swift-ci
96e1edba51 Merge pull request #18767 from gottesmm/pr-0983614e249bfc12a55e18d548d5ea5de9cd00fa 2018-08-16 20:15:07 -07:00
Pavel Yaskevich
6756c57f91 [Diagnostics] NFC: Move logic common to all requirement failures into RequirementFailure
This is going to make adding same-type and superclass requirement
failures might easier, because they only have to supply custom
diagnostic messages and substituted types.
2018-08-16 18:35:24 -07:00
swift-ci
f1f056cb4b Merge pull request #18765 from gottesmm/pr-c28068372a21dccd2c3076e1f666f346e90865e4 2018-08-16 18:20:55 -07:00
Jordan Rose
d6c8ca016b Constify PrintOptions in ShouldPrintChecker::shouldPrint
No functionality change.
2018-08-16 17:59:24 -07:00
swift-ci
febc065e9b Merge pull request #18775 from nkcsgexi/reorder-abi 2018-08-16 17:44:15 -07:00
Michael Gottesman
f093a8910d [analysis] Add a new form of verification SILAnalysis::verifyFull().
This is a verification routine that is only invoked in PassManager
destructors. I am going to use this to ensure that the
PassManagerVerifierAnalysis only runs at such points (even when sil-verify-all
is enabled) since it is too expensive to run otherwise.

NOTE: The default implementation of verifyFull in this commit is a no-op. I
wanted to have verify() be the default implementation of verifyFull(), but I do
not have more time to invest in this and it seems to catch /real/ bugs, albeit
bugs unrelated to pass manager notification verification. Instead I am going to
file an SR for someone to look at it since I need to move on from this work back
to semantic SIL. At least we will not have notification failure issues anymore
and thus a large correctness issue in the compiler has been fixed. Forward
progress!

rdar://42301529
2018-08-16 17:25:32 -07:00
Xi Ge
bc79f3011a swift-api-digester: diagnose removal/addition of dynamic attribute under abi mode. 2018-08-16 16:50:10 -07:00
Michael Gottesman
c275826a41 Merge pull request #18766 from gottesmm/pr-1fc1bcbaa94bb36d85e974fe09c97d87e9d60b04
[passmanager] Add the two last missing delete notifications.
2018-08-16 16:02:24 -07:00
swift-ci
e0cef24540 Merge pull request #18762 from graydon/num-instructions-executed 2018-08-16 15:16:20 -07:00
Michael Gottesman
3c58cd56e1 [passmanager] Change the verifier analysis to use function names instead of SILFunction pointers for its internal state.
This enables us to have state independent of the liveness of the SILFunction's
that we are tracking.

I also changed the verifier to implement only verifyFull instead of verify to
ensure that when we run with sil-verify-all this only runs at the end of pass
manager pipelines.

rdar://42301529
2018-08-16 14:46:31 -07:00
Michael Gottesman
9168d46015 [passmanager] Add the two last missing delete notifications.
With this change and some other changes that I am committing in parallel, the
stdlib and all of the overlays send all proper pass manager notifications.

rdar://42301529
2018-08-16 14:41:22 -07:00
Xi Ge
95e9879cac Merge pull request #18761 from nkcsgexi/diagnose-gs
swift-api-digester: diagnose generic signature change for any declarations.
2018-08-16 14:33:05 -07:00
Graydon Hoare
fe5667a4b6 [Stats] Change NumInstructions to NumInstructionsExecuted, accept 0 when on VMs. 2018-08-16 13:19:36 -07:00
Xi Ge
07e002ce5e swift-api-digester: diagnose generic signature change for any declarations. 2018-08-16 11:32:43 -07:00
Harlan
9b29e8dc91 Merge pull request #18454 from harlanhaskins/requests-ive-had-a-few
Remove SimpleRequest::breakCycle
2018-08-16 11:03:22 -07:00
Michael Gottesman
74ae66bacd Merge pull request #18725 from gottesmm/pr-1e9eaf3649841fc06185d9b353db89111ed4c380
[sil-pass-manager] Wire up pass manager to the new deserialization notification infrastructure.
2018-08-16 10:50:27 -07:00
Michael Gottesman
9b036b2316 Merge pull request #18724 from gottesmm/pr-e32bbcf553e857952e63a87d9b9f24d9d991da98
[sil-optimizer] Centralize how we send out serialization notifications.
2018-08-16 10:48:09 -07:00
Ben Cohen
428c580158 Fix unused variable warnings in release builds. (#18755) 2018-08-16 11:46:45 -06:00
Jordan Rose
1958d7aea3 [AST] Add an AccessScope::dump helper (#18756)
And factor an existing getAccessLevelString out into a
generally-available swift::getAccessLevelSpelling.
2018-08-16 10:30:30 -07:00
John McCall
1c99f31f20 Basic motions towards moving yields into AnyFunctionType.
Still not intending to do this anytime soon.
2018-08-16 02:13:54 -04:00
John McCall
5d8252b8c6 Pass around whether storage is mutable as an enum instead of a bool. 2018-08-16 02:13:54 -04:00
Xi Ge
7f2fff6cac Merge pull request #18739 from nkcsgexi/abi-flag
swift-api-digester: diagnose the addition and removal of @objc, @_fixed_layout and @_frozen under ABI mode.
2018-08-15 19:03:06 -07:00
Harlan
c8f8afd51e Merge pull request #18736 from harlanhaskins/magic-eraser
[TBDGen] Remove TBD options from FrontendOptions
2018-08-15 19:01:15 -07:00
Xi Ge
17b9a4edf9 swift-api-digester: diagnose the addition and removal of @objc, @_fixed_layout and @_frozen under ABI mode. 2018-08-15 17:49:01 -07:00
Michael Gottesman
aa11068fd4 [sil-pass-manager] Wire up pass manager to the new deserialization notification infrastructure.
rdar://42301529
2018-08-15 16:28:50 -07:00
Harlan Haskins
5498e869c0 Use evaluator's dependency printing for cycles 2018-08-15 16:02:48 -07:00
Michael Gottesman
872bf40e17 [sil-optimizer] Centralize how we send out serialization notifications.
Previously SILModule contained two different pathways for the deserializer to
send notifications that it had created functions:

1. A list of function pointers that were called when a function's body was
deserialized. This was added recently so that access enforcement elimination is
run on newly deserialized SIL code if we have already eliminated access
enforcement from the module.

2. SILModule::SerializationCallback. This is an implementation of the full
callback interface and is used by the SILModule to update linkage and other
sorts of book keeping.

To fix the pass manager notification infrastructure, I need to be able to send
notifications to a SILPassManager when deserializing. I also need to be able to
eliminate these callbacks when a SILPassManager is destroyed. These requirements
are incompatible with the current two implementations since: (2) is an
implementation detail of SILModule and (1) only notifies on function bodies
being deserialized instead of the creation of new declarations (what the caller
analysis wants).

Rather than adding a third group of callbacks, this commit refactors the
infrastructure in such a way that all of these use cases can use one
implementation. This is done by:

1. Lifting the interface of SerializedSILLoader::Callback into a base
notification protocol for deserialization called
DeserializationNotificationHandlerBase and its base no-op implementation into an
implementation of the aforementioned protocol:
DeserializationNotificationHandler.

2. Changing SILModule::SerializationCallback to implement
DeserializationNotificationHandler.

3. Creating a class called FunctionBodyDeserializationNotificationHandler that
takes in a function pointer and uses that to just override the
didDeserializeFunctionBody. This eliminates the need for the specific function
body deserialization list.

4. Replacing the state associated with the two other pathways with a single
DeserializationNotificationHandlerSet class that contains a set of
DeserializationNotificationHandler and chains notifications to them. This set
implements DeserializationNotificationHandlerBase so we know that its
implementation will always be in sync with DeserializationNotificationHandler.

rdar://42301529
2018-08-15 15:49:15 -07:00
Harlan Haskins
14a7ae56db [TBDGen] Remove TBD options from FrontendOptions
This patch removes the duplication between FrontendOptions and
TBDGenOptions by parsing the TBDGenOptions up front similarly to IRGen
and SIL options.
2018-08-15 14:53:44 -07:00
Mike Ash
46309d9794 [Runtime] Rename swift_unknown* functions to swift_unknownObject*.
These functions don't accept local variable heap memory, although the names make it sound like they work on anything. When you try, they mistakenly identify such things as ObjC objects, call through to the equivalent objc_* function, and crash confusingly. This adds Object to the name of each one to make it more clear what they accept.

rdar://problem/37285743
2018-08-15 17:48:23 -04:00
Alex Hoppen
e8dc5055d6 Merge pull request #18715 from ahoppen/gen-tokenkinds
[libSyntax] Generate TokenKinds.def from gyb_syntax_support
2018-08-15 13:27:43 -07:00
Harlan
7318efe49d [TBDGen] Allow user-provided dylib version flags (#18716)
* [TBDGen] Allow user-provided dylib version flags

This patch adds two frontend arguments, -tbd-compatibility-version and
-tbd-current-version, both of which accept SemVer versions.

These will show up in the generated TBD file for a given module as

current-version: 2.7
compatibility-version: 2.0

These flags both default to `1.0.0`.

* Reword some comments

* Add test for invalid version string

* Expand on comments for TBD flags
2018-08-15 11:42:42 -07:00
Harlan Haskins
c31d7f808a Rebase on master and resolve conflicts 2018-08-15 11:22:09 -07:00
Alex Hoppen
e9e7d5cf68 [libSyntax] Generate TokenKinds.def from gyb_syntax_support 2018-08-15 11:11:27 -07:00
Harlan Haskins
5a6985f39e Remove SimpleRequest::breakCycle
This patch removes the need for Request objects to provide a default
cycle-breaking value, instead opting to return llvm::Expected so clients
must handle a cycle failure explicitly.

Currently, all clients do the 'default' behavior, but this opens the
possibility for future requests to handle failures explicitly.
2018-08-15 11:01:12 -07:00
swift-ci
be0e1643d6 Merge pull request #18720 from DougGregor/kill-type-resolver-context-generic-signature 2018-08-15 10:55:08 -07:00
Jordan Rose
6dfff66a83 Merge pull request #18617 from jrose-apple/any-requestions
Request evaluator: Cut down on the cost of AnyRequest in two ways
2018-08-15 10:09:23 -07:00
Doug Gregor
876738fabe Merge pull request #18718 from DougGregor/cleanup-type-lookup
[Name lookup] Clean up qualified and type lookup
2018-08-15 10:03:41 -07:00
Jordan Rose
a5f84ec2f6 [AST] Drop redundant ProtocolDecl::TrailingWhereClause
There's already a field for this in GenericContext, which ProtocolDecl
indirectly inherits. Protocols may have slightly different treatment
of their where-clauses, but not enough to justify a separate field.

No functionality change.
2018-08-14 23:17:57 -07:00
Andrew Trick
1bb7b37b9f Teach static exclusivity verification about withoutActuallyEscaping.
DiagnoseStaticExclusivity no longer asserts as follows when
non-escaping closures are passed to withoutActuallyEscaping:

Applied argument must be @noescape function type: ...
A partial_apply with @inout_aliasable may only be used as a @noescape
function type argument.

Subsequent commits will improve diagnostics to detect actual conflicts
in these situations.

Fixes <rdar://problem/43059088> Assertion in DiagnoseStaticExclusivity.
2018-08-14 17:14:25 -07:00
Andrew Trick
c9033ed938 Add a SIL attribute [without_actually_escaping].
ConvertFunction and reabstraction thunks need this attribute. Otherwise,
there is no way to identify that withoutActuallyEscaping was used
to explicitly perform a conversion.

The destination of a [without_actually_escaping] conversion always has
an escaping function type. The source may have either an escaping or
@noescape function type. The conversion itself may be a nop, and there
is nothing distinctive about it. The thing that is special about these
conversions is that the source function type may have unboxed
captures. i.e. they have @inout_aliasable parameters. Exclusivity
requires that the compiler enforce a SIL data flow invariant that
nonescaping closures with unboxed captures can never be stored or
passed as an @escaping function argument. Adding this attribute allows
the compiler to enforce the invariant in general with an escape hatch
for withoutActuallyEscaping.
2018-08-14 17:14:25 -07:00
Doug Gregor
8a81ea45fb [Name lookup] Teach lookupQualified() to accept TypeDecls.
Rather than require clients of lookupQualified() to resolve
their type declarations to nominal type declarations (and
separately cope with modules), have lookupQualified() accept
an array of TypeDecls and handle the resolution to nominal
type declarations (where it can look directly) and module
declarations, combining the results.
2018-08-14 14:40:51 -07:00
Jordan Rose
910894a970 Merge pull request #18597 from jrose-apple/well-worn-path
Cache ConformanceAccessPaths in GSB::EquivalenceClass for big wins
2018-08-14 11:42:15 -07:00
Alex Hoppen
79e9113a58 Merge pull request #18677 from ahoppen/ref-counted-owned-string
[libSyntax] Add a reference counted version of OwnedString
2018-08-14 11:37:40 -07:00
Doug Gregor
6e2d3fe355 [AST/TypeChecker] Remove DynamicLookup flag.
We detect whether we’re performing AnyObject lookup based on 
whether we are looking into AnyObject; these two DynamicLookup
flags are unused.
2018-08-14 11:32:55 -07:00
Jordan Rose
84f471b031 [IRGen] Handle ProtocolInfo for protocols whose members aren't used (#18692)
Certain uses of protocols only formally need the requirement
signature, not any of the method requirements. This results in IRGen
seeing a protocol where none of the members have been validated except
the associated types. Account for this by allowing ProtocolInfo to
only contain the layout for the base protocols and associated types,
if requested.

Note that this relies on the layout of a witness table always putting
the "requirement signature part" at the front, or at least at offsets
that aren't affected by function requirements.

rdar://problem/43260117
2018-08-14 11:10:02 -07:00
Doug Gregor
ca343aeaa3 Merge pull request #18703 from DougGregor/get-reference-counting-cleanups
[AST] Drop resilience expansion from TypeBase::getReferenceCounting().
2018-08-14 11:04:39 -07:00
Greg Titus
8f41ee7750 Merge pull request #18324 from gregomni/opty2
[Sema] More unwrap fixits
2018-08-14 09:12:35 -07:00