Commit Graph

136 Commits

Author SHA1 Message Date
Slava Pestov
3130c3cbd7 AST: Remove an overload of GenericSignature::getSubstitutions() 2017-04-28 13:26:02 -07:00
Roman Levenstein
c897316a8c [sil-generic-specializer] Fix bugs in the implementation of partial specialization for partial_apply
Do not forget to map interface types to proper contextual types.
2017-04-26 13:02:24 -07:00
Roman Levenstein
7bc012ab16 [sil-generic-specializer] Set a generic context a bit earlier so that all functions using type-lowering can use it.
Fixes rdar://31838976 (SR-4704)
2017-04-26 11:37:59 -07:00
practicalswift
ff827e0455 [gardening] Fix recently introduced typos 2017-04-25 21:03:44 +02:00
Michael Gottesman
a89752f77a [gardening] Eliminate unused variable warnings from non-asserts build. 2017-04-24 16:08:06 -07:00
Slava Pestov
397d059aaa SILOptimizer: Fix some warnings in recent partial specialization changes 2017-04-23 02:16:07 -07:00
Roman Levenstein
17597f73a8 Merge pull request #8880 from swiftix/partial-specialization
[generic-specializer] Final parts of the partial specialization implementation
2017-04-21 19:15:12 -07:00
Roman Levenstein
7e7252dc4c [generic-specializer] Fix for specializations which are no-return functions
Fixes rdar://31758579
2017-04-21 13:59:02 -07:00
Roman Levenstein
8fb8cc4367 [generic-specializer] Cosmetic renaming of some vars and functions to match the new naming scheme 2017-04-20 08:16:24 -07:00
Roman Levenstein
f1362a3a14 [generic-specializer] Code clean-ups 2017-04-20 08:16:24 -07:00
Roman Levenstein
686b83b6cb [generic-specializer] Improve comments 2017-04-20 08:16:24 -07:00
Roman Levenstein
0ba522f189 [generic-specializer] Fix comments 2017-04-20 08:16:24 -07:00
Roman Levenstein
f28e28c0a8 [generic-specializer] Big re-factoring of the partial specialization implementation
- Introduced a new helper class FunctionSignaturePartialSpecializer which provides most of the functionality required for producing a specialized generic signature based on the provided substitutions or requirements. The class consists of many small functions, which should make it easier to understand the code.

- Added a full support for partial specialization of generic parameters with generic substitutions (use flag `-Xllvm -sil-partial-specialization-with-generic-substitutions` to enable it)

- Removed the simpler version of the partial specializer which could partially specialize only generic parameters with non-generic substitutions. It is not needed anymore, because we can handle any substations now when performing the partial specialization.

- The functionality used by the EagerSpecializer to implement the partial specializations required by @_specialize is expressed in terms of FunctionSignaturePartialSpecializer as well. The code implementing it is much smaller now.

Partial specialization of generic parameters with generic substitutions is fully functional, but it is disabled by default, because it needs some tweaks when it comes to compile times and size of produced code. These issues will be addressed in the subsequent commits.
2017-04-20 08:16:24 -07:00
Roman Levenstein
ce8d986999 [generic-specializer] Rename OriginalF into Callee 2017-04-20 08:16:24 -07:00
Roman Levenstein
76b6647414 [generic-specializer] Fix bugs in the implementation of partial specialization for partial_apply
There were two bugs:
- A proper GenericContextScope was not set for type lowering
- Interface types were not mapped to contextual types before using them in SIL instructions
2017-04-20 08:16:24 -07:00
Roman Levenstein
3d24657b3b [generic-specializer] Fix the condition for bailing on generic substitutions
Also provide more descriptive debug information in this case.
2017-04-20 08:16:24 -07:00
Roman Levenstein
34e366a150 [generic-specializer] Improve debug prints 2017-04-20 08:16:24 -07:00
Roman Levenstein
c23b423bae [generic-specializer] Move checkSpecializationRequirements around 2017-04-20 08:16:24 -07:00
Roman Levenstein
3a9edac4fb [generic-specializer] Remove workarounds
GSB now checks internally that generic signatures it produces are idempotent.
2017-04-20 08:16:24 -07:00
practicalswift
7eb7d5b109 [gardening] Fix 100 typos. 2017-04-18 17:01:42 +02:00
Roman Levenstein
2c87f08e3f [sil-generic-specializer] Don’t build a new generic signature in case of a full specialization. NFC.
In case of a full specialization, the specialized function does not have a generic signature. Therefore there is no need to build it.
This speeds up the compilation by avoiding doing a useless work.
2017-04-14 19:45:04 -07:00
Roman Levenstein
998748e964 [sil-generic-specializer] Print more debug info when asserting 2017-04-14 19:42:04 -07:00
Doug Gregor
faa0401598 [GSB] Allow requirement inference for synthesized requirements. 2017-04-14 17:19:02 -07:00
Doug Gregor
9dde2d7527 [SIL generics utils] Drastically simplify remapRequirements().
remapRequirements() was doing a whole lot of substitution work by
itself that the GenericSignatureBuilder is already capable of
doing. Use the GSB's functionality instead.
2017-04-14 17:19:02 -07:00
Doug Gregor
10ebdcd50a [GSB] Broaden the Boolean result of "add a constraint" operations.
Rather than true (an error occurred) or false (the constraint was
resolved), introduce ConstraintResult to better model what
happened. NFC for now, but the intent here is to report unresolved
constraints through this mechanism.
2017-04-11 14:15:45 -07:00
Slava Pestov
c78e561af9 SILOptimizer: Simplify ReabstractionInfo a bit 2017-04-03 20:41:31 -07:00
practicalswift
00ba5dc248 [gardening] Fix typos 2017-04-02 16:23:45 +02:00
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