Commit Graph

15033 Commits

Author SHA1 Message Date
Andrew Trick
3a15cee084 -sil-print-all (et al.) should print specialized functions when they are created. 2018-02-08 11:27:46 -08:00
Jordan Rose
af67204b51 [Serialization] Handle XREFs to private types (#14352)
We can encounter these when the compiler modifies an inlinable
function to break apart a struct and the struct uses a private
type for one of its fields. It's questionable whether we /should/
handle this, but meanwhile this /is/ a non-intrusive fix that
preserves the performance of non-resilient libraries.

(That is, it appears this worked in Swift 4.0, though perhaps
not all of the same optimizations kicked in.)

https://bugs.swift.org/browse/SR-6874
2018-02-07 16:42:16 -08:00
Erik Eckstein
9c7612f31c Cache the substituted types in the TypeSubstCloner.
This results some significant compile time wins in some cases.

rdar://problem/36887449
2018-02-07 15:02:51 -08:00
Jordan Rose
0c92fdda33 [SIL] Remove unused ResilienceExpansion from SILDeclRef (#14451)
We ended up not using this, so let's not leave it in as cruft.
No functionality change.
2018-02-07 09:41:25 -08:00
Arnold Schwaighofer
cf5b5dcb68 Merge pull request #14440 from aschwaighofer/convert_function_to_trivial
SIL: Add a convert_function_to_trivial instruction for converting escaping t…
2018-02-07 05:11:36 -08:00
Pavel Yaskevich
6cf1aa3083 Merge pull request #14399 from xedin/field-desc-for-imported-structs-2.0
[Reflection] Add support for imported structs with recorded fields (attempt #2)
2018-02-07 01:57:03 -08:00
Joe Groff
f75dd6c704 Merge pull request #14391 from jckarter/too-complex-message
Reword the "expression too complex" error not to blame the user.
2018-02-06 19:43:03 -08:00
Arnold Schwaighofer
d51053b003 Add convert_escape_to_noescape instruction for converting escaping to noescape functions
@noescape function types will eventually be trivial. A
convert_escape_to_noescape instruction does not take ownership of its
operand. It is a projection to the trivial value carried by the closure
-- both context and implementation function viewed as a trivial value.

A safe SIL program must ensure that the object that the project value is based
on is live beyond the last use of the trivial value. This will be
achieve by means of making the lifetimes dependent.

For example:

  %e = partial_apply [callee_guaranteed] %f(%z) : $@convention(thin) (Builtin.Int64) -> ()
  %n = convert_escape_to_noescape %e : $@callee_guaranteed () -> () to $@noescape @callee_guaranteed () -> ()
  %n2 = mark_dependence %n : $@noescape @callee_guaranteed () -> () on %e : $@callee_guaranteed () -> ()
  %f2 = function_ref @use : $@convention(thin) (@noescape @callee_guaranteed () -> ()) -> ()
  apply %f2(%n2) : $@convention(thin) (@noescape @callee_guaranteed () -> ()) -> ()
  release_value %e : $@callee_guaranteed () -> ()

Note: This is not yet actually used.

Part of:
SR-5441
rdar://36116691
2018-02-06 18:01:23 -08:00
Pavel Yaskevich
8f05d64770 [Reflection] Add support for imported structs with recorded fields
Update IRGen to trigger generation of type metadata for foreign
struct types found in fields. And fix TypeRefBuilder to handle
the case where struct has fields but at the same time has opaque
metadata.
2018-02-06 15:50:52 -08:00
Arnold Schwaighofer
d981bb1d96 Mangling: noescape functions will be trivial and no longer compatible with escape function types.
Mangle escapeness as part of the type.

Part of:
SR-5441
rdar://36116691
2018-02-06 08:51:43 -08:00
Mark Lacey
be8defb29e Rename lookThroughAllAnyOptionalTypes to lookThroughAllOptionalTypes. 2018-02-05 23:59:01 -08:00
Mark Lacey
fdd86fe069 Remove ImplicitlyUnwrappedOptionalType.
We haven't been creating these since
https://github.com/apple/swift/pull/14299 but there was more
groundwork before we could actually remove the type definition.
2018-02-05 23:59:01 -08:00
Mark Lacey
7f805ba2bc Replace classifyAsOptionalType with isOptionalDecl. 2018-02-05 23:59:00 -08:00
Mark Lacey
b4b66bc8e8 Replace getAnyOptionalObjectType with getOptionalObjectType. 2018-02-05 23:59:00 -08:00
Mark Lacey
8a775e1068 Revert "Add CanType::getOptionalObjectType for staging a rename."
This reverts commit b253f94247.
2018-02-05 23:54:35 -08:00
David Ungar
56b50cb28d Merge pull request #14349 from davidungar/PR-18-4b-refactor-performCompile
[Batch Mode] NFC: Carve up performCompile & performCompileStepsPostSILGen. (2)
2018-02-05 19:17:53 -08:00
Andrew Trick
113bebb035 Centralize logic for access marker and exclusivity verification.
Create helpers in InstructionUtils.h wherever we need a guarantee that the diagnostics cover the same patterns as the verifier. Eventually this will be called from both SILVerifier and the diagnostic pass:
- findAccessedAddressBase
- isPossibleFormalAccessBase
- isPartialApplyOfReabstractionThunk
- findClosureForAppliedArg
- visitAccessedAddress

Add partial_apply verification assert.

This applies the normal "find a closure" logic inside the "find all partial_apply uses" verification. Making the verifier round-trip ensures that we don't have holes in exclusivity enforcement related to this logic.
2018-02-05 18:43:30 -08:00
David Ungar
d3f16229c0 Tweaks to shorten performCompile* a bit more.
# Conflicts:
#	lib/FrontendTool/FrontendTool.cpp
2018-02-05 17:47:47 -08:00
Erik Eckstein
7ddfa9a9b6 mangling: remove the round-trip check for mangled runtime names (in the old mangling scheme).
This check doesn't make sense anymore because we are still making changes to the old remangler, but not to the old demangler.
Also, this check didn't work in most cases anyway.

rdar://problem/37241935
2018-02-05 14:02:18 -08:00
swift-ci
c345043030 Merge pull request #14400 from dcci/ub-madness 2018-02-03 16:18:12 -08:00
Davide Italiano
4ab738e13b [MetadataReader] Initialize fields to prevent UB.
hasVtable is not initialized on all paths, so when we read it,
we end up reading a random value. On debug builds, this value
almost always happen to be zero, so we do the right thing. This
isn't necessarily true when the optimizations kick in.

lldb uses metadata reder to resolve types and as result of this
undefined behaviour sometimes gets wrong results back, causing
a bunch of tests to fail in release builds.
2018-02-03 15:19:58 -08:00
Harlan
5e02d2a877 Implement #warning and #error (#14048)
* Implement #warning and #error

* Fix #warning/#error in switch statements

* Fix AST printing for #warning/#error

* Add to test case

* Add extra handling to ParseDeclPoundDiagnostic

* fix dumping

* Consume the right paren even in the failure case

* Diagnose extra tokens on the same line after a diagnostic directive
2018-02-03 18:07:05 -05:00
swift-ci
a49f175b07 Merge pull request #14398 from rudkx/some-iuo-deletion 2018-02-03 13:58:15 -08:00
Pavel Yaskevich
73a7ebc8ac Merge pull request #14397 from apple/revert-14185-field-desc-for-imported-structs
Revert "[WIP][IRGen] Emit type field descriptors for imported structs"
2018-02-03 11:41:53 -08:00
Mark Lacey
3654dcc8fe Remove getImplicitlyUnwrappedOptionalObjectType. 2018-02-03 10:57:11 -08:00
Mark Lacey
cc1d258374 Merge pull request #14387 from rudkx/CanType-getOptionalObjectType
Add CanType::getOptionalObjectType for staging a rename.
2018-02-03 10:52:41 -08:00
Mark Lacey
8667eb6f91 Revert "[WIP][IRGen] Emit type field descriptors for imported structs" 2018-02-03 10:27:34 -08:00
Joe Groff
69baceffb1 Reword the "expression too complex" error not to blame the user.
It's not you, it's us. We shouldn't tell the user their code is too complex, and "solve" doesn't mean anything to them in this context. Make it clearer this is an implementation limitation.
2018-02-03 08:32:51 -08:00
swift-ci
bf4f2848f9 Merge pull request #14385 from DougGregor/conformance-location-sr-6839 2018-02-02 23:01:47 -08:00
Mark Lacey
b253f94247 Add CanType::getOptionalObjectType for staging a rename.
In order to replace uses of getAnyOptionalObjectType() with
getOptionalObjectType(), we need to update LLDB. But in order
to do that, we need to have the version of this function for
CanType available.

So this adds this, as a temporary measure, to facilitate the LLDB
update that will unblock the compiler rename.
2018-02-02 21:47:41 -08:00
Doug Gregor
2f6cb21079 [AST] Prefer 'synthesized' conformances to 'implied' ones consistently.
When determining which declaration context should own a particular
protocol conformance that was not explicitly spelled out, prefer
"synthesized" contexts (i.e., which is always the nominal type itself)
for automatically-generated conformances (such as a raw-valued enum's
conformance to RawRepresentable) to conformances that are "implied" by
conformance to a more-refined protocol. Previously, we biased the
other way---but because conformances due to more-refined protocols can
be discovered later, we could get into a problem where two files
disagreed on which context would own the conformance---and neither
would emit the corresponding witness table.

Biasing toward "synthesized" contexts, which are always trivially
discoverable from the nominal type declaration itself, eliminates the
issue.

Fixes SR-6839 / rdar://problem/36911943.
2018-02-02 21:46:22 -08:00
Mark Lacey
f51d925d01 Merge pull request #14221 from hamishknight/optional-to-any-diag
[Sema] Improve Optional-to-Any diagnostics for collections, nested optionals & IUOs
2018-02-02 20:42:30 -08:00
David Ungar
4821e15795 Extract shouldActionOnlyParse. 2018-02-02 20:25:05 -08:00
Pavel Yaskevich
b2f1260ead Merge pull request #14185 from xedin/field-desc-for-imported-structs
[WIP][IRGen] Emit type field descriptors for imported structs
2018-02-02 19:23:46 -08:00
Mark Lacey
393eae2fb4 Merge pull request #14364 from rudkx/typealias-for-iuo
Make ImplicitlyUnwrappedOptional<T> an unavailable typealias.
2018-02-02 17:46:49 -08:00
Rintaro Ishizaki
2134f9f768 [Parse] Move SyntaxParsingContext to Parse (#14360)
This is only for the Parser.
Also, this resolves layering violation where libAST and libSyntax
depends on each other.
2018-02-03 10:43:52 +09:00
Doug Gregor
93442cf11f [Runtime] SE-0143: Evaluate conditional conformances at runtime.
When evaluating whether a given type conforms to a protocol, evaluate the
conditional requirements and pass the results to the witness table
accessor function. This provides the ability to query conditional
conformances at runtime, and is the last major part of implementing
SE-0143.

The newly-added unlock/lock dance in the conformance lookup code is a
temporary stub. We have some ideas to do this better.

Fixes rdar://problem/34944655.
2018-02-02 16:41:27 -08:00
Doug Gregor
b9e91e3934 [ABI] Describe module context and conditional requirements of conformances.
Extend protocol conformance descriptors with two more bits of information:

* For retroactive conformances, add the module in which the conformance
  occurs. This will eventually be used for error reporting/ambiguity
  resolution when retroactive conformances collide.
* For conditional conformances, add the conditional requirements. We need
  these for runtime evaluation of conditional conformances.
2018-02-02 16:41:27 -08:00
Pavel Yaskevich
9e08ea4c56 [Reflection] Add support for imported structs with recorded fields
Update IRGen to trigger generation of type metadata for foreign
struct types found in fields. And fix TypeRefBuilder to handle
the case where struct has fields but at the same time has opaque
metadata.
2018-02-02 15:54:12 -08:00
David Ungar
c396a3a972 Don’t free the ASTContext if > 1 primary input. 2018-02-02 13:49:08 -08:00
troughton
e156826984 Remove _swift_allocBox_ function pointers. 2018-02-03 10:20:57 +13:00
troughton
cf28ff448c Remove TwoWordPair and use SwiftCC instead. 2018-02-03 09:43:00 +13:00
Mark Lacey
2008674495 Make ImplicitlyUnwrappedOptional<T> an unavailable typealias.
Also remove the decl from the known decls and remove a
bunch of code referencing that decl as well as a bunch of other
random things including deserialization support.

This includes removing some specialized diagnostics code that
matched the identifier ImplicitlyUnwrappedOptional, and tweaking
diagnostics for various modes and various issues.

Fixes most of rdar://problem/37121121, among other things.
2018-02-02 08:35:53 -08:00
Hamish
1891c3820b [Sema] Change Optional-to-Any diagnostics to take a variable destination type
This will let us customise the diagnostic for collections and nested optionals.
2018-02-02 14:07:00 +00:00
Mark Lacey
e43ff7164c Merge pull request #14299 from rudkx/iuo-remove-the-type
IUO: Generate Optional<T> rather than ImplicitlyUnwrappedOptional<T>
2018-02-01 21:58:37 -08:00
Rintaro Ishizaki
4e327f7058 Merge pull request #14330 from rintaro/syntax-arena
[Syntax] Bump allocate and cache/reuse RawSyntax
2018-02-02 11:13:24 +09:00
David Ungar
354a76ac4e Merge pull request #14198 from davidungar/PR-18-3c-exp2
[Batch mode] Move frontend main output files to FrontendInputsAndOutputs. (1)
2018-02-01 16:42:10 -08:00
Doug Gregor
6dc429af43 Merge pull request #14327 from DougGregor/demangle-to-metadata-generic-reqs
Check generic requirements in `_typeByMangledName`.
2018-02-01 16:07:29 -08:00
David Ungar
6b1d16b68b Move comment to declaration. 2018-02-01 15:20:20 -08:00
Doug Gregor
7f926809e7 [Runtime] Fix accessors for TargetGenericParamRef.
RelativeDirectPointerIntPair uses the alignment of the pointer to determine
how many low bits are in the tiny integer value. This led to an inconsistency
between the runtime view of TargetGenericParamRef (which expected the
Boolean flag to be in the lower two bits) and the compiler's view
(which put the Boolean flag in the lowest bit), causing crashes.
2018-02-01 14:45:13 -08:00