Commit Graph

359 Commits

Author SHA1 Message Date
Slava Pestov
8fe8b89b0f SIL: Terminology change: [fragile] => [serialized]
Also, add a third [serializable] state for functions whose bodies we
*can* serialize, but only do so if they're referenced from another
serialized function.

This will be used for bodies synthesized for imported definitions,
such as init(rawValue:), etc, and various thunks, but for now this
change is NFC.
2017-03-29 16:47:28 -07:00
Roman Levenstein
a05cc2c8b5 Enable simple version of partial specialization by default
The simple version does not allow for partial specialization of generic parameters whose replacement types in a substitution are generic.
2017-03-28 15:56:40 -07:00
Saleem Abdulrasool
092650cad6 Merge pull request #8276 from compnerd/vars
SILOptimizer: remove unused variable
2017-03-23 19:16:37 -07:00
Saleem Abdulrasool
8669365feb SILOptimizer: remove unused variable
swift/lib/SILOptimizer/Utils/Generics.cpp:1429:9: warning: unused variable 'SM' [-Wunused-variable]
2017-03-22 11:46:27 -07:00
Saleem Abdulrasool
ccae6e81f8 SILOptimizer: avoid "deprecation" warnings
The `dump` method is meant for interactive use in debuggers only.  Use
the parameter form to avoid the warning.
2017-03-22 11:43:50 -07:00
Roman Levenstein
fae0628a97 Implement partial specialization which supports generic substitutions.
Use -sil-partial-specialization-with-generic-substitutions to enable the partial specialization even in cases of substitutions containing generic replacement types.
2017-03-21 08:46:40 -07:00
Erik Eckstein
d70bfc5de2 rename namespace NewMangling -> Mangle 2017-03-20 10:09:30 -07:00
Erik Eckstein
1625345b90 Remove the old mangler.
NFC
2017-03-17 16:10:36 -07:00
Roman Levenstein
c336dafb04 [sil-generic-specializer] Provide a possibility to disable the indirect-to-direct conversions of parameters and results
This is required by the capture propagation pass. Indirect-to-direct conversions are still performed by default.
2017-03-15 08:27:21 -07:00
Greg Parker
44135ae69a Revert "[sil-capture-propagation] Switch to the new notifyAddFunction API" 2017-03-15 00:49:07 -07:00
Roman Levenstein
b3f558321a [sil-generic-specializer] Provide a possibility to disable the indirect-to-direct conversions of parameters and results
This is required by the capture propagation pass. Indirect-to-direct conversions are still performed by default.
2017-03-14 17:37:19 -07:00
Greg Parker
5c01a65a40 Revert "[sil-capture-propagation] Support generic partial_apply instructions" 2017-03-14 17:32:42 -07:00
Roman Levenstein
ea3d69130c Merge pull request #8081 from swiftix/wip-capture-propagation-generics
[sil-capture-propagation] Support generic partial_apply instructions
2017-03-14 17:09:12 -07:00
John McCall
3c5de5fa0a Preserve type canonicality better in several places and
idiomatize some uses of SILType::getSwiftRValueType().
2017-03-14 14:59:43 -04:00
Roman Levenstein
65091d6dbf [sil-generic-specializer] Provide a possibility to disable the indirect-to-direct conversions of parameters and results
This is required by the capture propagation pass. Indirect-to-direct conversions are still performed by default.
2017-03-14 08:36:00 -07:00
Roman Levenstein
2b5585410b [sil-generic-specializer] Don't specialize types which are too wide or too deep
This improves the existing logic which is used to stop specialization for types that are too big to handle. It catches some pathological cases which hang the compiler.

Fixes rdar://30938882

Re-applying this commit, which was speculatively reverted. It turned out that that performance tests issues were unrelated.
2017-03-12 11:40:30 -07:00
Roman Levenstein
5f4cc96267 Revert "[sil-generic-specializer] Don't specialize types which are too wide or too deep"
This speculatively reverts commit f07743b117, because it seems to have caused compiler hangs on performance bots.
2017-03-11 07:14:02 -08:00
Roman Levenstein
f07743b117 [sil-generic-specializer] Don't specialize types which are too wide or too deep
This improves the existing logic which is used to stop specialization for types that are too big to handle. It catches some pathological cases which hang the compiler.

Fixes rdar://30938882
2017-03-09 12:09:53 -08:00
Roman Levenstein
d85013ecaf Small fixes based on review comments. 2017-03-06 13:51:18 -08:00
Roman Levenstein
d6e842524b [sil-generic-specializer] Canonicalize the substituted type of the specialized function in the context of a new generic signature 2017-03-06 12:54:11 -08:00
Roman Levenstein
eae26a9139 Small clean-ups 2017-03-06 12:54:11 -08:00
Roman Levenstein
dd7f84bd33 [sil-generic-specializer] Support partial specialization of closures 2017-03-06 12:54:11 -08:00
Roman Levenstein
a9db867e8d Implement partial specialization behind a flag.
Partial specialization is disabled by default. Use -sil-partial-specialization to enable it.

Use -sil-partial-specialization-with-generic-substitutions to enable the partial specialization even in cases of substitutions containing generic replacement types.
2017-03-02 23:29:55 -08:00
Slava Pestov
7c844fca9f SILOptimizer: Use the SubstitutionMap form of substGenericArgs() 2017-03-01 01:24:29 -08:00
Slava Pestov
4138381e4e SIL: Remove SILType::substFuncType() 2017-02-28 20:52:43 -08:00
Doug Gregor
2d430d8324 [GSB] Always pass a root potential archetype to a requirement source.
Whenever we create a (root) requirement source, associate it with the
potential archetype on which the requirement is written. This lets us
follow a requirement source from the (stated or implied) requirement on
the root potential archetype to the effective requirement on the
resulting potential archetype.

Introduce FloatingRequirementSource for the cases where we need to
state what the root source is, but don't yet have a potential
archetype to attach it to. These get internally resolved to
RequirementSources as soon as possible.
2017-02-28 09:47:02 -08:00
Doug Gregor
40a813bc8d [GenericSigBuilder] Sink RequirementSource into GenericSignatureBuilder. 2017-02-28 09:41:23 -08:00
Roman Levenstein
34815ff9ef [sil-generic-specializer] Do not create specializations for functions marked with @_semantics("optimize.sil.specialize.generic.never")
Those functions are not critical for performance, but their specializations result in a stdlib code bloat.
2017-02-24 14:59:44 -08:00
Doug Gregor
da39d9b17b [GenericSig Builder] Rework RequirementSource to describe requirement path.
Reimplement the RequirementSource class, which captures how
a particular requirement is satisfied by a generic signature. The
primary goal of this rework is to keep the complete path one follows
in a generic signature to get from some explicit requirement in the
generic signature to some derived requirement or type, e.g.,

1) Start at an explicit requirement "C: Collection"
2) Go to the inherited protocol Sequence,
3) Get the "Iterator" associated type
4) Get its conformance to "IteratorProtocol"
5) Get the "Element" associated type

We don't currently capture all of the information we want in the path,
but the basic structure is there, and should also allow us to capture
more source-location information, find the "optimal" path, etc. There are
are a number of potential uses:

* IRGen could eventually use this to dig out the witness tables and
  type metadata it needs, instead of using its own fulfillment
  strategy
* SubstitutionMap could use this to lookup conformances, rather than
  it's egregious hacks
* The canonical generic signature builder could use this to lookup
  conformances as needed, e.g., for the recursive-conformances case.

... and probably more simplifications, once we get this right.
2017-02-17 13:50:51 -08:00
Slava Pestov
41eba98902 Gardening: Fix some unused variable warnings in no-assert builds 2017-02-15 12:57:35 -08:00
practicalswift
65b0219f7b [gardening] Fix typos 2017-02-14 20:04:08 +01:00
Roman Levenstein
fc7b9e1081 [sil-linker] Minor clean-ups of function lookup code in SILModule and SIL linker. NFC.
Stop using SILLinkage::Private as a flag for "linkage doesn't matter". Use Optional instead.
2017-02-14 08:15:51 -08:00
Jordan Rose
1c60910198 Revert "Merge pull request #6092 from swiftix/wip-generics-inlining-flag-4"
This reverts commit 1b3d29a163, reversing
changes made to b32424953e.

We're seeing a handful of issues from turning on inlining of generics,
so I'm reverting to unblock the bots.
2017-02-13 10:52:17 -08:00
Slava Pestov
e069d6553c SILOptimizer: Clean up partial specialization substitution construction 2017-02-12 00:51:28 -08:00
Roman Levenstein
1b3d29a163 Merge pull request #6092 from swiftix/wip-generics-inlining-flag-4
Enable inlining of generics
2017-02-10 20:13:36 -08:00
Roman Levenstein
199e76d6d4 Fixes for a lookup of functions by name
Among other things it fixes a bug in the function signature optimization where it would use an already existing mangled name for a different function
2017-02-10 18:07:30 -08:00
Doug Gregor
579af863c5 Rename ArchetypeBuilder -> GenericSignatureBuilder 2017-02-10 12:46:34 -08:00
Roman Levenstein
c3bbe643c6 Code cleanups based @slavapestov's review 2017-02-08 15:33:50 -08:00
Roman Levenstein
ec4f28eff2 Teach EagerSpecializer how to use the new form of the @_specialize attribute
In addition to supporting the creation of full specializations, the EagerSpecializer changes contain some code for generating the layout-constrained partial specializations as well.
2017-02-08 01:08:09 -08:00
Roman Levenstein
2b9444e03a Add mangling support for partial specializations. 2017-02-07 23:16:00 -08:00
Roman Levenstein
26c963f27b Generic specializer API changes to prepare for the new @_specialize attribute and partial specializations. 2017-02-07 23:16:00 -08:00
Slava Pestov
3519e0cd25 AST: Introduce new SubstitutionList type to replace ArrayRef<Substitution>
SubstitutionList is going to be a more compact representation of
a SubstitutionMap, suitable for inline allocation inside another
object.

For now, it's just a typedef for ArrayRef<Substitution>.
2017-02-06 21:36:33 -08:00
Slava Pestov
b22f9ea487 AST: Remove SubstitutionMap::getMap()
We don't want to expose the fact that SubstitutionMaps are
backed by a DenseMap, since that's going to change soon.
2017-02-06 19:43:33 -08:00
Andrew Trick
8d65b758f2 [SILOpt] support for opaque values. 2017-01-31 16:19:24 -08:00
Andrew Trick
978b2fc80b Fix terminology. There's no such thing as a "formal SIL type".
Formal types are defined by the language's type system. SIL types are
lowered. They are no longer part of that type system.

The important distinction here is between the SIL storage type and the SIL value
type. To make this distinction clear, I refer to the SILFunctionTypes "formal"
conventions. These conventions dictate the SIL storage type but *not* the SIL
value type. I call them "formal" conventions because they are an immutable
characteristic of the function's type and made explicit via qualifiers on the
function type's parameters and results. This is in contrast to to SIL
conventions which depend on the SIL stage, and in the short term whether the
opaque values flag is enabled.
2017-01-26 15:35:48 -08:00
Andrew Trick
1abeddcc5d [SILType] SILFunctionConventions API.
Separate formal lowered types from SIL types.
The SIL type of an argument will depend on the SIL module's conventions.
The module conventions are determined by the SIL stage and LangOpts.

Almost NFC, but specialized manglings are broken incidentally as a result of
fixes to the way passes handle book-keeping of aruments. The mangler is fixed in
the subsequent commit.

Otherwise, NFC is intended, but quite possible do to rewriting the logic in many
places.
2017-01-26 15:35:48 -08:00
Michael Gottesman
ea1f804207 [semantic-sil] Eliminate ValueOwnershipKind::Any from SILPHIArguments in Semantic SIL.
Most of this involved sprinkling ValueOwnershipKind::Owned in many places. In
some of these places, I am sure I was too cavalier and I expect some of them to
be trivial. The verifier will help me to track those down.

On the other hand, I do expect there to be some places where we are willing to
accept guaranteed+trivial or owned+trivial. In those cases, I am going to
provide an aggregate ValueOwnershipKind that will then tell SILArgument that it
should disambiguate using the type. This will eliminate the ackwardness from
such code.

I am going to use a verifier to fix such cases.

This commit also begins the serialization of ValueOwnershipKind of arguments,
but does not implement parsing of value ownership kinds. That and undef are the
last places that we still use ValueOwnershipKind::Any.

rdar://29791263
2017-01-10 20:05:23 -08:00
Slava Pestov
844765b2fc SILOptimizer: Clean up hasDynamicSelfTypes() and hasUnboundGenericTypes() 2017-01-08 21:01:13 -08:00
Roman Levenstein
506b2b1591 Merge pull request #6582 from djwbrown/djwbrown-OnoneSupport-reversed
[Onone][prespecialize] Added iteration through reversed() arrays.
2017-01-06 08:37:43 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00