Commit Graph

193 Commits

Author SHA1 Message Date
Nadav Rotem
d78b376d07 [passes] Replace the old invalidation lattice with a new invalidation scheme.
The old invalidation lattice was incorrect because changes to control flow could cause changes to the
call graph, so we've decided to change the way passes invalidate analysis.  In the new scheme, the lattice
is replaced with a list of traits that passes preserve or invalidate. The current traits are Calls and Branches.
Now, passes report which traits they preserve, which is the opposite of the previous implementation where
passes needed to report what they invalidate.

Node: I tried to limit the changes in this commit to mechanical changes to ease the review. I will cleanup some
of the code in a following commit.

Swift SVN r26449
2015-03-23 21:18:58 +00:00
Nadav Rotem
a50a924e85 Teach the devirtualizer to only invalidate analysis for functions that were modified.
Swift SVN r26372
2015-03-20 22:53:05 +00:00
Mark Lacey
5547dd6047 Enable speculative devirtualization of 'class func' methods.
Swift SVN r26191
2015-03-16 21:13:12 +00:00
Mark Lacey
a30d13b0ce Simplify handling of metatypes in devirtualization.
Make the devirtualization functions take the actual type we're
devirtualizing (or speculatively devirutalizing) to, in order to
simplify the handling of metatypes. Remove the ClassDecl parameter from
these functions since it can always be derived from this type.

These changes set things up for more forthcoming improvements to
metatype handling.

As part of this I've simplified the function that determines if a member
is known to be 'final'. My expectation is that this can be further
simplified by removing the type parameter as part of other improvements
to metatype handling.

Swift SVN r26165
2015-03-15 22:04:46 +00:00
Mark Lacey
ffaa74bfbb Remove DevirtClassMethodInfo.
It turns out we're already at a point where we can easily pass the same
data along to the devirtualization functions, and were already passing
some of it.

Swift SVN r26040
2015-03-12 07:46:10 +00:00
Mark Lacey
f174ad1a2c Replace a dyn_cast with a cast.
We don't test the result, and we immediately dereference it.

Swift SVN r26033
2015-03-12 05:09:46 +00:00
Erik Eckstein
7c5ea453ba Revert "Simplify some of the logic around metatypes in the devirtualizer."
It crashes when compiling the benchmarks.



Swift SVN r25978
2015-03-11 11:44:34 +00:00
Mark Lacey
a9f29281f7 Simplify some of the logic around metatypes in the devirtualizer.
NFC.

Swift SVN r25977
2015-03-11 08:43:40 +00:00
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