Commit Graph

11224 Commits

Author SHA1 Message Date
Dmitri Gribenko
3e708a9328 Merge commit '8e292daec1bc790c96b5ee39b8d55dadcac6ce1b' into swift-3-indexing-model 2016-04-14 15:10:26 -07:00
Xin Tong
31b6c65039 Fix a logic error in eraseUseOfValue.
I failed to create a test case. And we hav existing tests in FSO that will
exercise this.

rdar://25559780
2016-04-13 20:53:28 -07:00
swiftix
46e359041d Merge pull request #2176 from swiftix/master
Improve the implementation of pre-specializations
2016-04-13 19:16:20 -07:00
Mark Lacey
00d8635fab Merge pull request #2145 from rudkx/later-dce
Move DCE to later in the SSA passes.
2016-04-13 17:25:56 -07:00
Roman Levenstein
27bcabcde3 Improve handling of pre-specializations.
This commit does not result in any visible functionality changes yet.
This is a preparation for some changes on the swift-3-indexing branch.
2016-04-13 15:49:36 -07:00
Roman Levenstein
932108b073 [pre-specializations] Update the whitelist to match the recent stdlib's re-factoring.
Fix for a test failure reported in rdar://25664645.
2016-04-13 15:23:07 -07:00
Roman Levenstein
e4f0338b40 Improve handling of pre-specializations.
This commit does not result in any visible functionality changes yet.
This is a preparation for some changes on the swift-3-indexing branch.
2016-04-13 14:04:28 -07:00
Erik Eckstein
b8feb278dc DeadObjectElemination: fix two problems with handling of the tuple_extract following an array init call
1) handle cases where the tuple_extract is not in the same basic block as the init call. This is not a correctness issue, but might miss some opportunities.
2) bail if there are multiple tuple_extract. This is a correctness issue, but a theoretical one. I don't think that in reality we will ever get multiple tuple_extracts out of SILGen.
2016-04-13 13:28:29 -07:00
Erik Eckstein
3e52d24853 add a debug dump function for ValueLifetimeAnalysis 2016-04-13 13:22:30 -07:00
Arnold Schwaighofer
d97e7d93c7 UnsafeGuaranteedPeephole: Also use RCIdentity for matching retains 2016-04-13 09:11:27 -07:00
Arnold Schwaighofer
7d86d6f664 UnsafeGuaranteedPeephole: Use RCIdentityFunctionInfo when matching release 2016-04-13 08:46:31 -07:00
Xin Tong
1a4f567685 More conservative about when we can move a release across an instruction
We now consider effect of deinit in addition to the released value.

rdar://25362826

This is the only 10%+ regression i measured on my machine. no performance improvement.

Sim2DArray                                              | 326     | 366     | +12.3%    | **0.89x**
2016-04-12 20:39:30 -07:00
Mark Lacey
07fb2909d7 Move DCE to later in the SSA passes.
Doing it later doesn't get in the way of other optimizations, and could
result in removing more things that become dead in the meantime.
2016-04-11 15:27:37 -07:00
Ted Kremenek
35a99b2b5a Merge pull request #2129 from jdhealy/gardening-deindent-comment-RedundantOverflowCheckRemovalPass
[gardening] De-indent comment in `RedundantOverflowCheckRemovalPass`.
2016-04-10 15:07:27 -07:00
J.D. Healy
c809ca1469 [gardening] De-indent comment in RedundantOverflowCheckRemovalPass.
[ci skip]
2016-04-10 17:47:08 -04:00
Arnold Schwaighofer
75100a9598 UnsafeGuaranteedPeephole: Also skip sideeffect free instructions 2016-04-10 14:28:02 -07:00
practicalswift
872070900d [gardening] Consistent formatting of STATISTIC(…, "…"); 2016-04-09 23:51:23 +02:00
practicalswift
0e91354da3 [gardening] Fix recently introduced typo: "domiator" → "dominator" 2016-04-09 12:19:21 +02:00
Mark Lacey
de884107c8 We need to be very careful in generic specialization of recurisive functions.
We were waiting to delete old apply / try_apply instructions until after
fully specializing all the apply / try_apply in the function. This is
problematic when we have a recursive call and specializing the function
that we're currently processing, since we end up cloning the function
with the old apply / try_apply present.

Rather than doing this, clean up the old apply / try_apply immediately
after processing each one.

Resolves SR-1114 / rdar://problem/25455308.
2016-04-08 23:30:01 -07:00
Arnold Schwaighofer
be7ddc69d9 UnsafeGuaranteedPeephole: Skip debug instructions and ignore retain/release uses 2016-04-08 17:54:39 -07:00
Erik Eckstein
1eab8aa955 Re-instate "StackPromotion: Ignore unreachable blocks in post-dominator tree."
With a bug fix which should ensure that it doesn't violate the stack nesting.

Original commit: 3d050f7b43
2016-04-08 10:20:47 -07:00
Erik Eckstein
911b05ab71 Fix comment 2016-04-08 10:20:47 -07:00
Slava Pestov
8f038cead4 SIL: Stricter asserts for non-fragile references from fragile functions
Building off of the previous patches, add stricter assertions to
inlining passes and SIL serialization.
2016-04-08 02:16:30 -07:00
Slava Pestov
d8e1e2e289 SILOptimizer: Fixes for non-fragile references in fragile functions
Two fixes to optimization passes to maintain restrictions about what
[fragile] functions can reference:

- When devirtualizing witness methods, don't devirtualize if the caller
  is fragile and the callee is not. This matches existing logic in
  class devirtualization.

- When performing generic or function signature specialization, don't
  specialize non-fragile functions referenced from fragile functions.

Since @_transparent functions are allowed to call 'static inline'
imported functions, also be sure to mark the foreign-to-native thunk
for such a function as [fragile].

With this patch, the standard library and performance test suite
now build with -enable-resilience.

No new tests for this stuff here -- the existing tests together
with an -enable-resilience build provide coverage.

Closes out <https://bugs.swift.org/browse/SR-267> and
<https://bugs.swift.org/browse/SR-268>.
2016-04-08 02:14:33 -07:00
Slava Pestov
5aa99fa346 SILOptimizer: Create non-[fragile] specializations of [fragile] functions where possible
Change the optimizer to only make specializations [fragile] if both the
original callee is [fragile] *and* the caller is [fragile].

Otherwise, the specialized callee might be [fragile] even if it is never
called from a [fragile] function, which inhibits the optimizer from
devirtualizing calls inside the specialization.

This opens up some missed optimization opportunities in the performance
inliner and devirtualization, which currently reject fragile->non-fragile
references:

TEST                                                    | OLD_MIN | NEW_MIN | DELTA (%) | SPEEDUP
---                                                     | ---     | ---     | ---       | ---
DictionaryRemoveOfObjects                               | 38391   | 35859   | -6.6%     | **1.07x**
Hanoi                                                   | 5853    | 5288    | -9.7%     | **1.11x**
Phonebook                                               | 18287   | 14988   | -18.0%    | **1.22x**
SetExclusiveOr_OfObjects                                | 20001   | 15906   | -20.5%    | **1.26x**
SetUnion_OfObjects                                      | 16490   | 12370   | -25.0%    | **1.33x**

Right now, passes other than performance inlining and devirtualization
of class methods are not checking invariants on [fragile] functions
at all, which was incorrect; as part of the work on building the
standard library with -enable-resilience, I added these checks, which
regressed performance with resilience disabled. This patch makes up for
these regressions.

Furthermore, once SIL type lowering is aware of resilience, this will
allow the stack promotion pass to make further optimizations after
specializing [fragile] callees.
2016-04-08 02:10:31 -07:00
Slava Pestov
a656fcdc8e Fix some compiler warnings with asserts disabled 2016-04-07 11:14:22 -07:00
swiftix
baf8e7d7cb Merge pull request #2067 from swiftix/SR-249
Add [nonatomic] attribute to all SIL reference counting instructions.

Support this attribute at SIL level,  IRGen and LLVM-based ARC passes.
2016-04-06 23:56:43 -07:00
eeckstein
2de4dbb765 Merge pull request #2084 from eeckstein/remove_from_parent
Remove removeFromParent
2016-04-06 16:43:11 -07:00
Jordan Rose
52b961de61 Revert "Fix post-dominator tree in stack promotion"
This broke the test suite under optimizations with a SIL verifier error: "stack dealloc does
not match most recent stack alloc".

This reverts commit 7a2ca23bc2, reversing
changes made to 4c55e8d7a7.
2016-04-06 16:02:20 -07:00
Erik Eckstein
0f1a89d5dc SpeculativeDevirtualizer: erase a dead block and not just remove it from the function.
And add a few asserts to make the code clearer.
2016-04-06 14:55:47 -07:00
Erik Eckstein
3d050f7b43 StackPromotion: Ignore unreachable blocks in post-dominator tree.
Unreachable blocks prevented stack promotion in some cases.
Now we use our own post-dominator tree which ignores unreachable blocks instead of the standard post-dominator tree provided by the PostDominanceAnalysis.
Unreachable blocks (better: unreachable sub-graphs) are of no interrest because we don't have to insert the dealloc instructions in unreachable blocks anyway.
2016-04-06 11:11:13 -07:00
Erik Eckstein
936b0acbef fix a comment 2016-04-06 11:11:13 -07:00
Doug Gregor
eac994bdff [Definite initialization] Recognize delegation to a C function imported as an initializer.
Add yet one more flavor of hack to DI to recognize where we are
delegating the initialization of 'self'. The existing hack in this
area (for Objective-C factory initializers) is based on recognizing
the value_metatype instruction that feeds into the application of the
factory initializer. C functions imported as initializers don't have a
metatype argument, so instead tag the assignment into the self box as
the initialization of self.

As a minor cleanup in this area, don't emit the dead value_metatype
instruction when invoking a C-imported factory initializer.
2016-04-06 09:55:55 -07:00
Roman Levenstein
2e77b3990b Add [nonatomic] attribute to all SIL reference counting instructions. 2016-04-06 01:52:43 -07:00
Andrew Trick
6ffafe4dd3 NFC: Remove a dead call in the DeadObjectElimination pass.
Cleanup after a pasto. Thanks Roman.
2016-04-05 16:28:27 -07:00
Roman Levenstein
c8f6a06c02 Add the frontend option -disable-sil-perf-optzns.
Useful when you want to enable -O LLVM opts but not -O SIL opts.
2016-04-05 11:09:24 -07:00
practicalswift
b01c615e0d Merge pull request #2053 from practicalswift/spacing
[gardening] if ([space]…[space]) → if (…), for(…) → for (…), while(…) → while (…), [[space]x, y[space]] → [x, y]
2016-04-05 00:01:14 +02:00
Adrian Prantl
1dff26abb8 Remove accidentally committed debug code. 2016-04-04 14:08:43 -07:00
practicalswift
abfecfde17 [gardening] if ([space]…[space]) → if (…), for(…) → for (…), while(…) → while (…), [[space]x, y[space]] → [x, y] 2016-04-04 16:22:11 +02:00
Slava Pestov
3e12eccb56 SIL: Fix miscompiles with @effects(readonly) functions that have indirect results
When resilience is enabled, some functions in the standard library that
are marked @effects(readonly) now have indirect results.

The SILCombiner pass doesn't handle @effects(readonly) with @out results
correctly, so just disable the optimizations temporarily to avoid a
mis-compile when resilience is enabled.

The LLVM readonly attribute can never be applied to such functions, so
don't set it either.

Should not have an effect when resilience is disabled.
2016-04-04 00:05:01 -07:00
practicalswift
798877ae77 [gardening] "if (foo)[SPACE][SPACE]{" → "if (foo)[SPACE]{" 2016-04-03 22:57:05 +02:00
Chris Lattner
4c57791516 Merge pull request #2025 from wxxsw/pull
[gardening] Put white spaces in between if/while clauses and braces where it is missing.
2016-04-02 10:46:18 -07:00
Dmitri Gribenko
14197f63a0 Merge pull request #2015 from practicalswift/gardening-20160401
[gardening] Friday gardening: typos, file headers & PEP-8
2016-04-02 01:58:37 -07:00
Ge Sen
5ad36b2962 [gardening] Put white spaces in between if/while clauses and braces where it is missing.
For instance:

'if (foo){' => 'if (foo) {'
2016-04-02 14:43:45 +08:00
Michael Gottesman
7361e35bb9 Revert "Putting white spaces in between if/while clauses and braces." 2016-04-01 22:00:25 -07:00
Ge Sen
7dd61bdfa9 [gardening] Put white spaces in between if/while clauses and braces where it is missing.
For instance:

'if (foo){' => 'if (foo) {'
2016-04-02 08:22:23 +08:00
Erik Eckstein
dd124ae4e9 Add SILCombine+SimplifyCFG passes between the ClosureSpecializer (and other passes) and the last inliner.
Without this we can end up not inlining in some trivial cases.
For example, the ClosureSpecializer may generate a function_ref - convert_function - apply sequence.
This must be cleaned up by SILCombine before we can inline the function.

rdar://problem/22309472
2016-04-01 15:26:36 -07:00
practicalswift
a7acb1a12a [gardening] Fix file header formatting. 2016-04-01 23:14:16 +02:00
practicalswift
fa1d5d231a [gardening] Fix recently introduced typo: "althouth" → "although" 2016-04-01 23:14:16 +02:00
Xin Tong
89bc2a46ef Merge pull request #1888 from trentxintong/RLE
remove an empty test case and pretty up some other and rename LSBase.cpp
2016-03-31 22:27:59 -07:00