Commit Graph

185 Commits

Author SHA1 Message Date
Mark Lacey
b54c45b201 Revert "Revert "Remove subtyping checks that can never actually fail.""
This reverts commit r25946, reinstating r25944.

This had been preemptively reverted fearing it might have broken
test/SILPasses/devirt_value_metatypes.swift, but that turned out to not
have been the case.

Swift SVN r25959
2015-03-10 21:45:16 +00:00
Mark Lacey
cb7df94fc2 Revert "Revert "Hoist more early returns as early as possible.""
This reverts commit r25947, reinstating r25943 with fixes.

This had been preemptively reverted fearing it might have broken
test/SILPasses/devirt_value_metatypes.swift, which it did. One of the
early exits that was hoisted should not have been moved.

I plan on another clean-up for that particular early exit in a
forthcoming commit.

Swift SVN r25958
2015-03-10 21:45:15 +00:00
Mark Lacey
2946d377b6 Revert "Revert "Another small clean-up. Manually copy-forward a value.""
This reverts commit r25948, reinstating r25942.

This had been preemptively reverted fearing it might have broken
test/SILPasses/devirt_value_metatypes.swift, but that turned out to not
have been the case.

Swift SVN r25957
2015-03-10 21:45:13 +00:00
Mark Lacey
d9c40a7f79 Revert "Revert "Simplify some code and make it easier to understand.""
This reverts commit r25949, reinstating r25941.

This had been preemptively reverted fearing it might have broken
test/SILPasses/devirt_value_metatypes.swift, but that turned out to not
have been the case.

Swift SVN r25956
2015-03-10 21:45:12 +00:00
Mark Lacey
3221fdb2a2 Revert "Simplify some code and make it easier to understand."
This reverts commit r25941.

It may have broken a test that was missing a FileCheck.

Swift SVN r25949
2015-03-10 19:59:26 +00:00
Mark Lacey
6a58924730 Revert "Another small clean-up. Manually copy-forward a value."
This reverts commit r25942.

It may have broken a test that was missing a FileCheck.

Swift SVN r25948
2015-03-10 19:59:25 +00:00
Mark Lacey
e3adbc654b Revert "Hoist more early returns as early as possible."
This reverts commit r25943.

It may have broken a test that was missing a FileCheck.

Swift SVN r25947
2015-03-10 19:59:24 +00:00
Mark Lacey
1b4dbf717a Revert "Remove subtyping checks that can never actually fail."
This reverts commit r25944.

It may have broken a test that was missing a FileCheck.

Swift SVN r25946
2015-03-10 19:59:21 +00:00
Mark Lacey
71d17b1a47 Remove subtyping checks that can never actually fail.
It's clear from the surrounding code and our type system that these
checks can never fail. To ensure I wasn't overlooking something I added
asserts to this effect and ran the test suite. I remove the asserts
because they feel like clutter, but if anyone feels strongly I can add
them back.

Swift SVN r25944
2015-03-10 19:27:42 +00:00
Mark Lacey
cf903cc900 Hoist more early returns as early as possible.
Swift SVN r25943
2015-03-10 19:27:41 +00:00
Mark Lacey
a3ddfe4c30 Another small clean-up. Manually copy-forward a value.
We know one value can be substituted for another after a given point, so
instead of conditional assignment, just substitute it.

Swift SVN r25942
2015-03-10 19:27:40 +00:00
Mark Lacey
dd055c3496 Simplify some code and make it easier to understand.
CSE some stripUpCasts() calls and do a little renaming to aid in
understandability. NFC.

Swift SVN r25941
2015-03-10 19:27:38 +00:00
Roman Levenstein
9c0eb2985b Yet another improvement of devirtualization based on metatypes.
Swift SVN r25928
2015-03-10 16:19:43 +00:00
Roman Levenstein
1b6cf90da8 Improvement of devirtualization based on metatypes.
Swift SVN r25927
2015-03-10 16:19:42 +00:00
Mark Lacey
fa7b1f5dcc Move early exit earlier in the function.
Exit as soon as we know we can, simplifying the later exit condition.

Swift SVN r25916
2015-03-10 06:19:26 +00:00
Mark Lacey
5fc5ca4fb8 Remove assert that can never fire.
We would assert in the preceeding cast<> if it were to fail.

Swift SVN r25915
2015-03-10 06:19:25 +00:00
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