Commit Graph

169 Commits

Author SHA1 Message Date
Roman Levenstein
30b68e5d83 [sil-devirtualizer] Fix dispatching on value_metatype
Dispatching on value_metatype, which happens in cases like obj.dynamicType.method(), was broken.
Fix it and add a corresponding test-case.

Swift SVN r25892
2015-03-09 19:35:47 +00:00
Mark Lacey
c26c15cc9f Don't pass arguments that can be easily derived from other arguments.
Swift SVN r25799
2015-03-06 06:56:56 +00:00
Mark Lacey
0b8c14e9bb Remove check which is subsumed by the call to canDevirtualizeClassMethod.
Shortly after this code we call canDevirtualizeClassMethod, which does
the same test.

Swift SVN r25796
2015-03-06 01:28:15 +00:00
Mark Lacey
99890e4b1d Remove unneeded local variable.
It's only use is to decide whether to assert later, so instead, let's
assert immediately.

Swift SVN r25795
2015-03-06 01:28:13 +00:00
Mark Lacey
757ae5796e First step in splitting out a utility for devirtualizing from the pass.
No functional change here, and this is not in its final form. This is
just cut/paste/tweak to split the code apart in a first reasonable form.

Swift SVN r25769
2015-03-04 22:21:38 +00:00
Mark Lacey
844c2df46f Rename a couple statistics.
Swift SVN r25768
2015-03-04 22:21:37 +00:00
Mark Lacey
a61e85cd51 Fix 80-column violations.
Swift SVN r25752
2015-03-04 08:39:14 +00:00
Roman Levenstein
a5b75b6f06 Oops. Forgot to commit these two lines in my previous commit.
Swift SVN r25718
2015-03-03 20:56:36 +00:00
Roman Levenstein
fcf7053c46 [sil-devirtualizer] Re-factoring of the class_method devirtualization method.
Decouple devirtualizeClassMethod into an analysis part and a part that performs a real transformation.
This allows for early bail outs when trying to devirtualize a class_method call and thus avoids creating a duplicate class_method call invocation, which happened before in certain rare cases.

Swift SVN r25717
2015-03-03 20:32:47 +00:00
Mark Lacey
a9181b08ce Make witness/vtable look-up helper naming more consistent.
Swift SVN r25713
2015-03-03 09:14:18 +00:00
Mark Lacey
10647fc13e More clean-up and renaming in devirtualizer.
I will be moving some of this code into a utility next.

Swift SVN r25712
2015-03-03 06:32:58 +00:00
Mark Lacey
9b7f58fcd5 Whitespace clean-up.
Swift SVN r25674
2015-03-02 06:24:12 +00:00
Mark Lacey
56012f87f6 Mark a free function as static since it is only used within this file.
Swift SVN r25673
2015-03-02 06:08:15 +00:00
Mark Lacey
4518893a3e Simplify witness devirtualization argument passing.
Rely on the type checker and SIL verification pass rather than checking
types explicitly before creating upcasts.

Swift SVN r25672
2015-03-02 05:54:04 +00:00
Mark Lacey
c0ef8dccb4 Update comments and simplify some code in the devirtualizer.
More prep for refactoring into utility functions that can be used
outside of the devirtualization pass.

Swift SVN r25671
2015-03-02 04:30:31 +00:00
Mark Lacey
7b77c87afa Minor reformatting changes.
Swift SVN r25670
2015-03-02 04:30:28 +00:00
Mark Lacey
cd0dfd1c31 Convert bottom-exit-while-true loop to do-while.
Swift SVN r25669
2015-03-02 02:43:33 +00:00
Mark Lacey
c3e83c2625 Remove isClassDeclOracle.
The only use of this was not terribly useful as an early-out since we
immediately test for two of the three cases.

At some point we can extend the code to actually walk back through
projections, but until then this just seems like noise.

Swift SVN r25668
2015-03-02 02:43:32 +00:00
Mark Lacey
82e74a3e10 Fix the comment for getClassFromConstructor.
The previous comment didn't seem to bear much resemblance to what the
function does.

Swift SVN r25667
2015-03-02 02:43:31 +00:00
Mark Lacey
023a4db47e Rename function to make naming consistent.
Swift SVN r25666
2015-03-02 02:43:29 +00:00
Nadav Rotem
e7140012bf Revert "Disable generic specialization in the devirtualizer ..."
The problem was with the testcase that failed verification and not in the devirtualizer.

This reverts commit r25586.

Swift SVN r25594
2015-02-27 05:14:08 +00:00
Nadav Rotem
3f4a5e8612 Disable generic specialization in the devirtualizer because it broke the build.
Swift SVN r25586
2015-02-27 02:04:05 +00:00
Nadav Rotem
2f167a37ca Clean up the GenericSpecializer interface. NFC.
Swift SVN r25580
2015-02-27 00:53:10 +00:00
Nadav Rotem
b6077500e0 Enable generic specialization of devirtualized functions.
We currently run the generic specialize after the devirtualizer because
devirtualization can unblock generic specialization. This patch saves the
newly created ApplyInsts and attempts to specialize only them.

Swift SVN r25576
2015-02-27 00:32:07 +00:00
Nadav Rotem
be032a9bc1 Teach the devirtualizer to return the newly created call (to be optimized later).
Swift SVN r25571
2015-02-27 00:32:00 +00:00
Dmitri Hrybenko
845dd08048 Fix a warning: implicit conversion of nullptr constant to 'bool'
Swift SVN r25543
2015-02-26 06:53:10 +00:00
Roman Levenstein
5bcd4319b8 [sil-devirtualizer] Do not try to devirtualize calls where a class instance is of an unbound generic type.
Devirtualizer should not even try to devirt calls  where a class instance is of an unbound generic type, because there is no support for it yet.

This fixes rdar://19912272

Swift SVN r25491
2015-02-23 23:52:37 +00:00
Dmitri Hrybenko
61286f0260 Fix warnings produced by a newer version of Clang
Swift SVN r25257
2015-02-12 23:50:47 +00:00
Roman Levenstein
8cd35dd701 [sil-devirtualizer] Correctly handle methods whose return types differ in optionality from the overriden methods.
In case when a base method and an overriding derived method differ in the optionality of the return type, devirt should perform the required wrapping after devirtualizing the class_method call.

rdar://19619832

Swift SVN r24768
2015-01-28 00:57:28 +00:00
Mark Lacey
8e7639050c Fix spelling in function name.
Swift SVN r24687
2015-01-23 18:04:05 +00:00
Mark Lacey
f6f73df230 Fix typo in statistic string.
Swift SVN r24686
2015-01-23 18:04:04 +00:00
Mark Lacey
4e335599a3 Better fix for 80 column violation.
Swift SVN r24626
2015-01-22 01:13:45 +00:00
Mark Lacey
680cd3cdae Revert "Fix another 80 column violation."
As Jordan points out this isn't an ideal fix in this case.

This reverts commit r24621.

Swift SVN r24625
2015-01-22 01:13:43 +00:00
Mark Lacey
077a103d07 Fix another 80 column violation.
Swift SVN r24621
2015-01-22 00:44:28 +00:00
Mark Lacey
eebea42401 Fix 80 column violation.
Swift SVN r24620
2015-01-22 00:44:27 +00:00
Mark Lacey
7846a2b3d4 Create applies with the transparent bit set properly during devirtualization.
Fixes rdar://problem/19477863.

Again, no real perf diff here, probably because the next round of
inlining was already inlining these (most of the hits are on setters,
getters, etc. which tend to be quite small).

Having this fixed will be useful in a future where we do some trivial
devirtualization during inlining, in particular mandatory
inlining (rdar://problem/19418937).

Swift SVN r24491
2015-01-17 02:49:15 +00:00
Nadav Rotem
cbf5bf4b89 Fix an unused variable warning.
Swift SVN r24405
2015-01-13 23:55:36 +00:00
Dmitri Hrybenko
e4f8a1cc71 Finish renaming lookUpSILFunctionFromVTable into
lookUpFunctionFromVTable.  Unbreaks the build.

Swift SVN r24270
2015-01-08 04:53:17 +00:00
Michael Gottesman
4b4c32a2b0 Fix build by updating function name.
Swift SVN r24269
2015-01-08 04:52:52 +00:00
Roman Levenstein
e8d6b2e17a [sil-devirtualizer] Improve handling of generics during devirtualization.
This patch provides a more robust way to find proper substitutions for generic classes during devirtualization. It fixes test-cases which were resulting in a compiler crash before. New tests are added to the test-suite to avoid this in the future.

Swift SVN r24040
2014-12-19 22:05:37 +00:00
Michael Gottesman
93b92a8f9f Add in Passes.def for metaprogramming with SILPassKinds.
This simplifies some code in SILOpt and SILPasses. The real reason to do it is
to use it to procedurally generate random pipelines.

Swift SVN r23996
2014-12-17 23:56:26 +00:00
Roman Levenstein
39af94d226 [sil-devirtualizer] The new implementation of witness method devirtualization.
The new simplified design was inspired by a discussion with Michael. Thanks!
This implementation is much simpler and smaller than the old one. The tests are extended to check for more complex cases.

Swift SVN r23909
2014-12-13 03:03:59 +00:00
Roman Levenstein
499e58c5b8 [sil-devirtualizer] Remove the old implementation of witness method devirtualization. It got too over-complicated and will be replaced by a new, much smaller and simpler implementation.
Swift SVN r23908
2014-12-13 03:03:58 +00:00
Roman Levenstein
9764bc2b1e [sil-devirtualizer] Better handle corner-cases in devirtMethod, e.g. metatypes or class_methods invoked on methods with non-bound generic type parameters.
Swift SVN r23907
2014-12-13 03:03:57 +00:00
Roman Levenstein
839699df22 [sil-devirtualizer] Improve checks in upcast upcastArgument.
Swift SVN r23906
2014-12-13 03:03:57 +00:00
Roman Levenstein
0ca09bc581 [sil-devirtualizer] Minor stylistic changes based on the feedback from a ML. NFC.
Swift SVN r23905
2014-12-13 03:03:56 +00:00
Mark Lacey
4a74e94b40 Fix release build warnings about unused variables.
Swift SVN r23893
2014-12-12 20:05:30 +00:00
Roman Levenstein
47651de376 [sil-devirtualizer] Significantly improve devirtualization of inherited and specialized protocol conformances.
This patch improves handling of generic parameters and implements proper handling of metatypes, which were blocking correct devirtualization of inherited and specialized conformances. It enables a corresponding test, because all its blocking issues are resolved now.

Fixes rdar://17823742, rdar://17823746 and rdar://16847192

Swift SVN r23882
2014-12-12 03:58:45 +00:00
Dmitri Hrybenko
f6e926224e Fix warnings about unused variables when assertions are turned off
Swift SVN r23641
2014-12-03 04:48:38 +00:00
Roman Levenstein
2601c4e506 [sil-devirtualizer] Support devirtualization of inherited conformances.
Remove XFAIL from a corresponding test and extend it to cover more test-cases.

rdar://17823742 and rdar://17823746

Swift SVN r23619
2014-12-02 21:00:44 +00:00