Commit Graph

11224 Commits

Author SHA1 Message Date
Xin Tong
500acb98e0 Rename LSBase.h to LoadStoreOptUtils.h 2016-06-08 10:57:27 -07:00
Xin Tong
be793d26eb Remove last bit of retain release code motion in SILCodeMotion. All these code are
replaced by retain release code motion. This code has been disabled for sometime now.

This should bring the retain release code motion into a close. The retain release
code motion pipeline looks like this. There could be some minor cleanups after this though.

1. We perform a global data flow for retain release code motion in RRCM (RetainReleaseCodeMotion)
2. We perform a local form of retain release code motion in SILCodeMotion. This is more
for cases which can not be handled in RRCM. e.g. sinking into a switch is more efficiently
done in a local form, the retain is not needed on the None block. Release on SILArgument needs
to be split to incoming values, this can not be done in RRCM and other cases.
3. We do not perform code motion in ASO, only elimination which are very important.

Some modifications to test cases, they look different, but functionally the same.
RRCM has this canonicalization effect, i.e. it uses the rc root, instead of
the SSA value the retain/release is currently using. As a result some test cases need
to be modified.

I also removed some test cases that do not make sense anymore and lot of duplicate test
cases between earlycodemotion.sil and latecodemotion.sil. These tests cases only have retains
and should be used to test early code motion.
2016-06-08 10:49:33 -07:00
practicalswift
8df3859ce7 [gardening] Fix recently introduced typos. 2016-06-05 11:11:44 +02:00
Xin Tong
dde3ce4479 Merge pull request #2819 from trentxintong/ReleaseCM
Hoist release on SILArgument to predecessors
2016-06-01 15:27:18 -07:00
Xin Tong
a3c1c1649e Hoist release on SILArgument to predecessors.
so that they can be potentially paired retains on some paths.

I did not measure real performance difference on my machine

rdar://19011844
2016-06-01 15:26:22 -07:00
practicalswift
d7c55418a3 [gardening] Remove unused identifier. 2016-06-01 14:08:51 +02:00
Jordan Rose
740ddd8400 [SIL] Don't assume we always have an associated DeclContext. (#2730)
...in code that I wrote. The integrated REPL, deprecated though it may
be, does not have an associated DeclContext because its SourceFile is
not considered complete. (The proper LLDB REPL does not suffer from
this problem because they use a new SourceFile for every block of
input.)

Elsewhere, tighten up code that may have hit similar bugs, though we
haven't seen anything hit these yet.

rdar://problem/26476281
2016-05-26 18:31:47 -07:00
Xin Tong
f2954f9235 Merge pull request #2725 from trentxintong/SFSO
Share a few createIncrement/createDecrement functions
2016-05-26 13:58:02 -07:00
Xin Tong
c758848c92 Share a few createIncrement/createDecrement functions 2016-05-26 12:55:25 -07:00
Xin Tong
cc90879b94 Merge pull request #2710 from trentxintong/SFSO
Fix a memory leak in RRCM.
2016-05-25 15:38:14 -07:00
Xin Tong
5b6437fa41 Fix a memory leak in RRCM.
Allow destructors of SmallVectors in BlockState be called when BumpPtrAllocator is destroyed
2016-05-25 15:33:32 -07:00
Xin Tong
35471ab345 Merge pull request #2310 from trentxintong/SFSO
Simplify function signature optimzation and fix a memory leak in function signature.
2016-05-25 15:11:12 -07:00
Xin Tong
db9ee7c614 Fix a memory leak in FSO
Make sure the destructor of the SmallVector in ProjectionTreeNode gets
called when the BumpPtrAllocator is destroy'ed.
2016-05-25 15:08:18 -07:00
Xin Tong
fb3eb0b646 Simplify function signature optimzation.
Several functionalities have been added to FSO over time and the logic has become
muddled.

We were always looking at a static image of the SIL and try to reason about what kind of
function signature related optimizations we can do.

This can easily lead to muddled logic. e.g. we need to consider 2 different function
signature optimizations together instead of independently.

Split 1 single function to do all sorts of different analyses in FSO into several
small transformations, each of which does a specific job. After every analysis, we produce
a new function and eventually we collapse all intermediate thunks to in a single thunk.

With this change, it will be easier to implement function signature optimization as now
we can do them independently now.

Small modifications to the test cases.
2016-05-25 11:12:27 -07:00
Xin Tong
5b79cb7cfb Remove a obsolete RC identity cache, we have a cache in the RCIdentity analysis itself now 2016-05-25 09:29:06 -07:00
Xin Tong
b5b905e3cc Bring back rc identity cache.
This takes off 0.7% of the 27.7% of the time we spent in SILoptimizer when building
Stdlib.
2016-05-25 09:25:27 -07:00
practicalswift
5a3067e24e [gardening] Fix plural issues. 2016-05-21 18:45:31 +02:00
Chris Lattner
0b847899f6 Refactor DI a bit to simplify it, NFC. 2016-05-19 22:58:34 -07:00
Chris Lattner
8c3bcddb92 Merge pull request #2540 from nubbel/pr/sr-1469
[SilOptimizer] SR-1469: Issue diagnostic for `init?` at early return statement
2016-05-19 22:11:29 -07:00
Roman Levenstein
bffa6b1759 [sil-combine] Properly form conformances when propagating a concrete type into an existential.
This fixes an optimization bug that resulted in an IRGen crash.

rdar://26286278
2016-05-18 15:59:02 -07:00
Roman Levenstein
48f7941f70 [sil-combine] Fix a stack_alloc peephole.
Fix a bug in the stack_alloc peephole, which was producing a code using opened archetypes before they were actually defined.

rdar://26309488
2016-05-17 19:31:23 -07:00
Xin Tong
2fb823e070 Merge pull request #2573 from trentxintong/MemLeak
Fix a memory leak in DSE
2016-05-17 16:28:34 -07:00
Xin Tong
46436d5caa Fix a memory leak in DSE 2016-05-17 15:39:59 -07:00
Xin Tong
260f75d314 Fix a non-deterministic load forwarding in RLE 2016-05-17 10:54:08 -07:00
Xin Tong
f9d227616b Merge pull request #2391 from trentxintong/InsertPoint
Remove code motion in ASO.
2016-05-16 08:13:52 -07:00
Dominique d'Argent
9115003882 [SilOptimizer] SR-1469: Issue diagnostic for init? at early return statement
In failable initializers the "return from initializer without initializing all stored properties" (resp. "return from enum initializer method without storing to 'self'" for enums) diagnostic is now reported at the early return instead of the end of the initializer.
2016-05-15 20:22:09 +02:00
Michael Gottesman
da9c13a9f8 [upstream-update] SmallPtrSet can now only have at most 32 elements inline.
(cherry picked from commit 88250e0e69)
(cherry picked from commit 4008ec83f6)
(cherry picked from commit 3a031eb1f8548e5ce55fb323118fbd05b5929a33)
2016-05-13 22:04:12 -07:00
Michael Gottesman
00edc61f85 [upstream-update] API rename llvm::DenseMap::reserve => llvm::DenseMap::resize.
(cherry picked from commit b11f7a0727)
(cherry picked from commit 39eab3ad30724cc95d1873ca818bb38e92428254)
2016-05-13 22:04:07 -07:00
Erik Eckstein
4c17897285 SimplifyCFG: fix crash in case an enum payload is an enum
fixes rdar://problem/26251856
2016-05-12 23:12:13 -07:00
Michael Gottesman
0d82712750 [constant-prop] Do not crash on frem.
Even though FRem was added as a builtin, this switch was not updated
accordingly. Update the switch and add a test case.

We really should transition all of the switches in this code to be covered
switches so that when builtins are added, it is obvious to know where things
need to be updated...

rdar://26250330
2016-05-12 13:33:53 -07:00
Roman Levenstein
1494d155c6 Don't sink open_existential instructions.
We don't sink open_existential_* instructions, because there may be some instructions depending on them, e.g. ametatype_inst, etc. But this kind of dependency cannot be expressed in SIL as a use yet. As a result, sinking open_existential may break the invariant that these instructions should dominate their uses.
2016-05-12 12:05:49 -07:00
Roman Levenstein
2eff3a1e9b Do not hoist metatype instructions with opened existentials.
Hoisting this instructions may break the invariant that each such instruction should be dominated by an open_existential instruction.
2016-05-12 12:05:20 -07:00
Erik Eckstein
db288e958b SimplifyCFG: fix a crash in debug output 2016-05-12 08:38:38 -07:00
swiftix
4eaed25a5e Merge pull request #2491 from swiftix/devirtualizer-fixes
Small fixes for the sil-devirtualizer
2016-05-11 21:35:46 -07:00
Mark Lacey
921dededad Use a bump pointer allocator in the callee set creation.
Shaves about 19% of the time from the construction of these sets. The
SmallVector size was chosen to minimize the number of dynamic
allocations we end up doing while building the stdlib. This should be a
reasonable size for most projects, too. It's a bit wasteful in space,
but the total amount of allocated space here is pretty small to begin
with.
2016-05-11 17:07:27 -07:00
Roman Levenstein
73b6a38edc [sil-devirtualizer] Do not perform a speculative devirtualization for no-opt callees. 2016-05-11 16:28:50 -07:00
Roman Levenstein
28f7b09c1d Add a more strict check for conversions between metatypes.
Now it is more inline with the check performed by the verifier.
2016-05-11 15:25:08 -07:00
Roman Levenstein
f200dfdc72 Addresses are always ABI compatible.
Now it is more inline with the check performed by the verifier.
2016-05-11 15:25:08 -07:00
Arnold Schwaighofer
4df87a6554 Refactor unsafeGuaranteed code into utility functions.
NFC.
2016-05-08 08:10:43 -07:00
practicalswift
c262b42ae0 [gardening] Fix recently introduced whitespace typos. (#2443) 2016-05-06 23:49:39 -07:00
eeckstein
180098ea2e Merge pull request #2436 from eeckstein/abcopt-fix
ABCOpt: we should not hoist bounds/overflow checks if the loop has mu…
2016-05-06 17:44:10 -07:00
Arnold Schwaighofer
0883a96c13 UnsafeGuaranteedPeephole: Fix obvious mistake
Caught by ASAN.
2016-05-06 15:59:48 -07:00
Erik Eckstein
0c97cfa6a8 ABCOpt: we should not hoist bounds/overflow checks if the loop has multiple exit edges.
fixes rdar://problem/26126534
2016-05-06 15:07:17 -07:00
practicalswift
68b148cfb1 [gardening] Fix recently introduced typos. 2016-05-06 20:31:38 +02:00
practicalswift
1a4cf40a30 [gardening] Fix recently introduced top of file headers. 2016-05-06 19:56:26 +02:00
Xin Tong
af64977121 Merge pull request #2414 from trentxintong/CString
Add 1 more iteration of release hoisting
2016-05-06 00:26:48 -07:00
Xin Tong
392a957202 Add 1 more iteration of release hoisting.
I see that we go from 24.9% of time spent in SILOptimizations in stdlib compilation
to 25.2%.

This brings back 50% of the regression for StringWithCString.

  <summary>Regression (3)</summary>

TEST                                                    | OLD_MIN | NEW_MIN | DELTA (%) | SPEEDUP
---                                                     | ---     | ---     | ---       | ---
NSError                                                 | 255     | 296     | +16.1%    | **0.86x**
ObjectiveCBridgeStubToArrayOfNSString                   | 25087   | 27733   | +10.6%    | **0.90x**
SwiftStructuresInsertionSort                            | 4292    | 4557    | +6.2%     | **0.94x**

</details>

<details >
  <summary>Improvement (7)</summary>

TEST                                                    | OLD_MIN | NEW_MIN | DELTA (%) | SPEEDUP
---                                                     | ---     | ---     | ---       | ---
MatMul                                                  | 1135    | 1071    | -5.6%     | **1.06x**
ObjectiveCBridgeToNSArray                               | 27090   | 25566   | -5.6%     | **1.06x**
ObjectiveCBridgeFromNSArrayAnyObjectToString            | 155362  | 145067  | -6.6%     | **1.07x**
OpenClose                                               | 47      | 44      | -6.4%     | **1.07x**
StringHasSuffix                                         | 695     | 642     | -7.6%     | **1.08x**
Calculator                                              | 34      | 30      | -11.8%    | **1.13x**
StringWithCString                                       | 336135  | 164974  | -50.9%    | **2.04x**
2016-05-06 00:24:59 -07:00
eeckstein
9435633f40 Merge pull request #2398 from eeckstein/some-cfg-opts
Some simplify-cfg opts and ConditionalForwarding
2016-05-05 13:17:13 -07:00
Slava Pestov
0280ed7ec5 SIL Optimizer: Remove some dead code, NFC 2016-05-05 12:25:05 -07:00
Erik Eckstein
d6e86b7c4b Add a new SIL pass to move conditions closer to switch_enum to enable jump threading.
For details see the comment in ConditionForwarding.cpp.
This optimization pass helps to optimize loops iterating over closed ranges, e.g. for i in 0...n { }
2016-05-05 10:34:08 -07:00