Commit Graph

467 Commits

Author SHA1 Message Date
Slava Pestov
221df61a6e SILOptimizer: Clean up SubstitutionMap usage in devirtualizer 2017-04-28 13:26:03 -07:00
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
Roman Levenstein
30a50f9ef0 [sil-cast-optimizer] Fix a silly bug related to canonical types
This bug occurs in real projects, when type aliases are involved.
The test-case is a bit hard to provide. I’ll try to provide it later, if I managed to reduce the original project to a small test-case.
But the fix is very obvious.

Fixes rdar://31768258
2017-04-26 09:49:14 -07:00
practicalswift
ab5aaeb359 Merge pull request #9001 from practicalswift/gardening-20170425
[gardening] Unused variables. Unused diagnostics. Namespace comments. Typos.
2017-04-26 09:28:24 +02:00
swift-ci
6ca9bc5b6f Merge pull request #9006 from DougGregor/bridge-cast-optimize-downcast 2017-04-25 14:16:29 -07:00
Doug Gregor
f7e05fd951 [Bridging cast optimization] Unchecked casts can perform a class downcast.
Handle a class downcast following a bridging cast. Fixes
rdar://problem/31791421.
2017-04-25 13:43:06 -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
John McCall
978f0e05fe Add unpaired access marker instructions and use them to implement
dynamic access tracking in materializeForSet.
2017-04-22 22:52:13 -04: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
Joe Groff
3d178be169 Merge pull request #8875 from jckarter/keypaths
Keypaths
2017-04-21 17:51:17 -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
Slava Pestov
f4b91cd118 AST: Remove unused 'resolver' argument from TypeBase::getSuperclass() 2017-04-20 00:37:38 -07:00
Joe Groff
595e0e4ede Merge branch 'master' into keypaths 2017-04-19 18:38: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
Huon Wilson
b59f95418c [SIL] Extract ClassVisibility from SILFunction to SubclassScope in SILLinkage. 2017-04-13 14:17:29 -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
Arnold Schwaighofer
601b1e6bd4 SILOptimizer: Add a zero cost for inlining const_string_literal instructions 2017-04-11 10:11:17 -07:00
Roman Levenstein
7eafb4b75e [sil-devirtualizer] Fix devirtualization of partial_apply on generic witness_methods
Properly cast the result of a devirtualized partial_apply, because this may be required in case of classes implementing protocols. More specifically, it came up when there is a derived class of a class implementing an initializer required by the protocol.

Fixes rdar://31459426 (SR-4501) and rdar://31479426 (SR-3476)
2017-04-10 13:45:56 -07:00
Joe Groff
85ad6b355e Merge branch 'master' into keypaths 2017-04-06 18:02:07 -07:00
Erik Eckstein
1702b831e4 StackNesting: fix use-after-free problem.
rdar://problem/31470661
2017-04-06 08:40:31 -07:00
Erik Eckstein
a43a844838 StackNesting: use the right debug locations for inserted deallocation instructions
Fixes a crash because we used a return-location for a deallocation instruction.

rdar://problem/31458587
rdar://problem/31458617
2017-04-05 18:05:39 -07:00
swift-ci
024033cf97 Merge pull request #8533 from adrian-prantl/28311051 2017-04-05 11:52:50 -07:00
Saleem Abdulrasool
c5c5f4e417 SILOptimizier: add missing include (NFC) 2017-04-05 10:41:00 -07:00
Adrian Prantl
5ea2d13f5e Improve the performance of IRGenDebugInfo
This commit changes how inline information is stored in SILDebugScope
from a tree to a linear chain of inlined call sites (similar to what
LLVM is using). This makes creating inlined SILDebugScopes slightly
more expensive, but makes lowering SILDebugScopes into LLVM metadata
much faster because entire inlined-at chains can now be cached. This
means that SIL is no longer preserve the inlining history (i.e., ((a
was inlined into b) was inlined into c) is represented the same as (a
was inlined into (b was inlined into c)), but this information was not
used by anyone.

On my late 2012 i7 iMac, this saves about 4 seconds when compiling the
RelWithDebInfo x86_64 swift standard library — or 40% of IRGen time.

rdar://problem/28311051
2017-04-05 08:33:55 -07:00
Roman Levenstein
4aaa855da1 Merge pull request #8489 from swiftix/wip-func-sig-opt-generic-functions-3
[sil-function-signature-opt] Support FSO for generic functions
2017-04-04 17:47:22 -07:00
Roman Levenstein
64813b7b4f [sil-function-signature-opt] Support FSO for generic functions
In particular, support the following optimizations:
- owned-to-guaranteed
- dead argument elimination

Argument explosion is disabled for generics at the moment as it usually leads to a slower code.
2017-04-04 12:33:17 -07:00
Joe Groff
af34a326c4 SIL: Inlining cost for KeyPathInst. 2017-04-04 11:44:21 -07:00
Erik Eckstein
805960b0ac ValueLifetimeAnalysis: fix the lifetime computation in case the value definition is in a single-block loop.
This caused DeadObjectElimination to generate a memory leak in case a dead array is in a single-block loop.
rdar://problem/31420889
2017-04-04 10:43:53 -07:00
Slava Pestov
c78e561af9 SILOptimizer: Simplify ReabstractionInfo a bit 2017-04-03 20:41:31 -07:00
practicalswift
288cb35b36 Merge pull request #8495 from practicalswift/gardening-20170402
[gardening] Remove unused variables and methods. Fix \t. Use isa<T>(). Typos.
2017-04-03 09:58:44 +02:00
Michael Gottesman
bd225f9fc4 [capture-promotion] Update capture-promotion for semantic-sil.
rdar://29870610
2017-04-02 11:44:14 -07:00