Commit Graph

64 Commits

Author SHA1 Message Date
Andrew Trick
e8b0947897 [Exclusivity] Allow testing the -Onone pipeline with access markers.
Markers are always eliminated before -O passes.

At -Onone, markers can be enabled via command line for all -Onone passes.
2017-04-26 17:32:48 -07:00
practicalswift
980391a237 [gardening] Remove redundant include 2017-04-14 17:33:24 +02:00
Andrew Trick
be1881aa1f Remove redundant Transform.getName() definitions.
At some point, pass definitions were heavily macro-ized. Pass
descriptive names were added in two places. This is not only redundant
but a source of confusion. You could waste a lot of time grepping for
the wrong string. I removed all the getName() overrides which, at
around 90 passes, was a fairly significant amount of code bloat.

Any pass that we want to be able to invoke by name from a tool
(sil-opt) or pipeline plan *should* have unique type name, enum value,
commend-line string, and name string. I removed a comment about the
various inliner passes that contradicted that.

Side note: We should be consistent with the policy that a pass is
identified by its type. We have a couple passes, LICM and CSE, which
currently violate that convention.
2017-04-09 15:20:28 -07:00
Andrew Trick
855918c620 [Lowering] Add an AddressLowering pass. 2017-02-13 17:10:02 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
Hugh Bellamy
ac3b56a554 Fix errors and warnings building swift/SILOptimizer on Windows using MSVC
-
https://connect.microsoft.com/VisualStudio/feedback/details/3116505/msvc-fails-to-compile-code-that-compiles-with-clang-reports-attempting-to-reference-a-deleted-function-error-from-destructor
-
https://connect.microsoft.com/VisualStudio/feedback/details/3116636/msvc-reports-ambiguous-symbol-error-for-friend-class-declaration-in-an-anonymous-namespace
2016-12-22 18:26:58 +00:00
Michael Gottesman
483388c9a6 [sil-bug-reducer] Wire up SILPassManager to SILPassManagerPipeline.
We also either remove or make private the addPass* functions on SILPassManager,
so the only way to execute passes via SILPassManager is by creating a
SILPassPipelinePlan. This beyond adding uniformity ensures that we always
resetAndRemoveTransformations properly after a pipeline is run.
2016-12-12 14:42:46 -08:00
Michael Gottesman
3c61f783ea [sil-bug-reducer] Add SILPassPipeline{,Plan}. Add current pass pipelines to it.
This commit adds the functionality, but does not change SILPassManager to use
it. The reason why I am doing this is so I can implement sil-opt pass bisecting
functionality in python using a tool that dumps the current pass pipelines
out. This will ensure that even in the face of changes to the pass pipelines,
everything should just work.
2016-12-12 14:38:56 -08:00
Michael Gottesman
1f3c1c54a8 [sil-bug-reducer] Separate construction of pass pipelines into separate functions.
This is a simple refactoring to make it really easy for me to rip out the pass
pipeline code into a real pass pipeline class that can be
serialized/deserialized. By serializing/deserializing the pass-pipeline
directly, it becomes very easy to write a bug-point like tool in python on top.
Additionally, it allows users who want to manipulate the pipeline by hand to be
able to easily dump out the normal pass pipeline without any work.
2016-12-12 09:18:26 -08:00
Roman Levenstein
354fd29f31 Add a new -assume-single-threaded option
This is a hidden option. It should be used like: -assume-single-threaded

When this function is provided, the compiler assumes that the code will be executed in the single threaded mode. It then performs certain optimizations that can benefit from it, e.g. it  marks as non-atomic all reference counting instructions in the user code being compiled.
2016-12-05 10:05:34 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Michael Gottesman
6f4e2ab391 [semantic-arc] Add a new guaranteed ARC optimization pass.
Often times SILGen wants to hold onto values that have been copied. This causes
an issue, when due to Cleanups firing, SILBuilder inserts destroys and destroys
the copy that produced the value that SILGen held onto. This will then cause
SILGen to emit incorrect code.

There really is no reason to introduce such complexity into SILBuilder when a
small simple guaranteed pass can perform the same work. Thus the introduction of
this pass.

In a later commit, I am going to eliminate the SILBuilder entry points.

rdar://28685236
2016-11-02 11:24:05 -07:00
Michael Gottesman
e173438d6b [semantic-arc] Even when we are not running diagnostics, run the sil ownership eliminator.
This only happens when we are testing deserialization.
2016-10-29 20:11:08 -07:00
Michael Gottesman
bb9197c7ff [semantic-arc] Move the Ownership Model Eliminator and management of SILFunction::hasQualifiedOwnership in front of SILOptions::EnableSILOwnership.
This is a NFC change, since verification still will be behind the flag. But this
will allow me to move copy_value, destroy_value in front of the
EnableSILOwnership flag and verify via SILGen that we are always using those
instructions.

rdar://28851920
2016-10-23 18:30:43 -07:00
Michael Gottesman
4d370a2814 [semantic-arc] When running the verifier, use the qualified ownership flag on the SILFunction to determine whether ownership is enabled or not.
Previously I was going to just set a flag and run the verifier once with that
flag enabled. Then I realized that given that the OwnershipModelEliminator is a
function pass, I really need to put the state on whether or not ownership is
enabled on functions. Now this commit refactors the verifier to use the state on
the function when determining if it should allow for ownership qualified
instructions or not in a specific function.

rdar://28685236
2016-10-21 17:42:39 -07:00
Michael Gottesman
277528f1ed [semantic-arc] When compiing with -enable-sil-ownership, run the OwnershipModelEliminator right after SILGen and verify with SIL Ownership Enabled.
rdar://28685236
2016-10-15 22:17:28 -07:00
Joe Shajrawi
91bba4d425 Do not emit shadow copied for inout parameters (#5218)
radar rdar://problem/28434323

SILGen has no reason to insert shadow copies for inout parameters any more. They cannot be captured. We still emit these copies. Sometimes deshadowing removes them, but sometimes it does not.

In this PR we just avoid emitting the copies and remove the deshadowing pass.

This PR chery-picked some of @dduan work and built on top of it.
2016-10-13 10:10:59 -07:00
practicalswift
b19481f887 [gardening] Fix 67 recently introduced typos 2016-09-16 11:16:07 +02:00
Erik Eckstein
959e19d7bc Add an optimization to eliminate a partial_apply if all applied arguments are dead in the applied function.
This consists of 3 parts:
1) Extend CallerAnalysis to also provide information if a function is partially applied
2) A new DeadArgSignatureOpt pass, similar to FunctionSignatureOpts, which just specializes for dead arguments of partially applied functions.
3) Let CapturePropagation eliminate such partial_apply instructions and replace them with a thin_to_thick conversion of the specialized functions.

This optimzation improves benchmarks where static struct or class functions are passed as a closure (e.g. -20% for SortStrings).
Such functions have a additional metatype parameter. We used to create a partial_apply in this case, which allocates a context, etc.
But this is not necessary as the metatype parameter is not used in most cases.

rdar://problem/27513085
2016-08-23 07:32:41 -07: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
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
Xin Tong
51b1c0bc68 Implement retain, release code motion.
Iterative data flow retain sinking and release hoisting.

This allows us to sink retains and hoist releases across harmless loops. which is
an improvement on the SILCodeMotion retain sinking and release hoisting.

It also separates the duty of moving retain and release with the duty of eliminating them
in ASO.

This should eventually replace RR code motion in SILcodemotion and insertion point
in ARCsequence opts (ASO).

This is the performance difference i get with retain sinking and release hoisting.
After disabling retain release code motion in ASO and SILCodeMotion. we can start to take
those code out once this lands.

I see that we go from 24.5% of time spent in SILOptimizations w.r.t. the whole stdlib compilation
to 25.1%.

Improvement is better (i.e. retain sinking and hoisting releases result in performance gain).

<details open>
  <summary>Regression (7)</summary>

TEST                                                    | OLD_MIN | NEW_MIN | DELTA (%) | SPEEDUP
---                                                     | ---     | ---     | ---       | ---
SetIsSubsetOf                                           | 441     | 510     | +15.7%    | **0.86x**
SetIntersect                                            | 1041    | 1197    | +15.0%    | **0.87x**
BenchLangCallingCFunction                               | 184     | 211     | +14.7%    | **0.87x**
Sim2DArray                                              | 326     | 372     | +14.1%    | **0.88x**
SetIsSubsetOf_OfObjects                                 | 498     | 567     | +13.9%    | **0.88x**
GeekbenchGEMM                                           | 945     | 1022    | +8.2%     | **0.92x**
COWTree                                                 | 3839    | 4181    | +8.9%     | **0.92x(?)**

</details>

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

TEST                                                    | OLD_MIN | NEW_MIN | DELTA (%) | SPEEDUP
---                                                     | ---     | ---     | ---       | ---
ObjectiveCBridgeFromNSDictionaryAnyObjectToString       | 174526  | 165392  | -5.2%     | **1.06x**
RGBHistogram                                            | 3128    | 2957    | -5.5%     | **1.06x**
ObjectiveCBridgeToNSDictionary                          | 16510   | 15494   | -6.2%     | **1.07x**
LuhnAlgoLazy                                            | 2294    | 2120    | -7.6%     | **1.08x**
DictionarySwapOfObjects                                 | 6477    | 5994    | -7.5%     | **1.08x**
StringRemoveDupes                                       | 1610    | 1485    | -7.8%     | **1.08x**
ObjectiveCBridgeFromNSSetAnyObjectToString              | 159358  | 147824  | -7.2%     | **1.08x**
ObjectiveCBridgeToNSSet                                 | 16191   | 14924   | -7.8%     | **1.08x**
DictionaryHashableClass                                 | 1839    | 1704    | -7.3%     | **1.08x**
DictionaryLiteral                                       | 2906    | 2678    | -7.8%     | **1.09x(?)**
StringUtilsUnderscoreCase                               | 10031   | 9187    | -8.4%     | **1.09x**
LuhnAlgoEager                                           | 2320    | 2113    | -8.9%     | **1.10x**
ObjectiveCBridgeFromNSSetAnyObjectToStringForced        | 99553   | 90348   | -9.2%     | **1.10x**
RIPEMD                                                  | 3327    | 3009    | -9.6%     | **1.11x**
Combos                                                  | 595     | 538     | -9.6%     | **1.11x**
Roman                                                   | 10      | 9       | -10.0%    | **1.11x**
StringUtilsCamelCase                                    | 10783   | 9646    | -10.5%    | **1.12x**
SetIntersect_OfObjects                                  | 2511    | 2182    | -13.1%    | **1.15x**
SwiftStructuresTrie                                     | 28331   | 24339   | -14.1%    | **1.16x**
Dictionary2OfObjects                                    | 3748    | 3115    | -16.9%    | **1.20x**
DictionaryOfObjects                                     | 2473    | 2050    | -17.1%    | **1.21x**
Dictionary                                              | 894     | 737     | -17.6%    | **1.21x**
Dictionary2                                             | 2268    | 1859    | -18.0%    | **1.22x**
StringIteration                                         | 8027    | 6344    | -21.0%    | **1.27x**
Phonebook                                               | 8207    | 6436    | -21.6%    | **1.28x**
BenchLangArray                                          | 119     | 91      | -23.5%    | **1.31x**
LinkedList                                              | 8267    | 6297    | -23.8%    | **1.31x**
StrToInt                                                | 5585    | 4180    | -25.2%    | **1.34x**
Dictionary3OfObjects                                    | 1122    | 831     | -25.9%    | **1.35x**
Dictionary3                                             | 731     | 515     | -29.6%    | **1.42x**
SuperChars                                              | 513353  | 258735  | -49.6%    | **1.98x**
2016-04-18 15:39:17 -07:00
Mark Lacey
0bc63c8ce8 Reorder and remove some passes to reduce compile time.
I'm measuring around a 1% reduciton in compile time for the stdlib, with
a handful of improvements on the benchmarks when compiled at -O, and one
small regression on one benchmark.
2016-04-17 23:04:28 -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
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
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
Arnold Schwaighofer
255779082e Add a peephole optimization for the builtin "unsafeGuaranteed"
We can remove the retain/release pair preceeding the builtins based on the
knowledge that the lifetime of the reference is guaranteed by someone hanging on
to the reference elsewhere.
2016-03-27 06:47:16 -07:00
Xin Tong
5907b8a3e2 Rename FunctionSignatureOptCloner to FunctionSignatureOpts
Eventually, we decided to do this

1. Have the function signature opts (used to be called the cloner to create
the optimized function.
2. Mark the thunk as always_inline
3. Rely on the inliner to inline the thunk to get the benefit of calling optimized
function directly.
2016-03-24 12:50:12 -07:00
Xin Tong
2a63907a17 Make FSO thunks always_inline.
This forces the callsites to be rewritten by the inliner.

we have the issue that the thunk changes from the time the its created to
the time its reread to figure out what we have done to the original function

This results in missed opportunities.

This solution solves the problem gracefully, because the thunk carries the information
on how to set up the call to the optimized functions.

Inlining the thunk makes the callsite calling the optimized function for free. i.e.
without any rewriting.

I did not measure any regression with this change.
2016-03-24 09:18:13 -07:00
Andrew Trick
482b264afc Reapply "Merge pull request #1725 from atrick/specialize"
This was mistakenly reverted in an attempt to fix buildbots.
Unfortunately it's now smashed into one commit.

---
Introduce @_specialize(<type list>) internal attribute.

This attribute can be attached to generic functions. The attribute's
arguments must be a list of concrete types to be substituted in the
function's generic signature. Any number of specializations may be
associated with a generic function.

This attribute provides a hint to the compiler. At -O, the compiler
will generate the specified specializations and emit calls to the
specialized code in the original generic function guarded by type
checks.

The current attribute is designed to be an internal tool for
performance experimentation. It does not affect the language or
API. This work may be extended in the future to add user-visible
attributes that do provide API guarantees and/or direct dispatch to
specialized code.

This attribute works on any generic function: a freestanding function
with generic type parameters, a nongeneric method declared in a
generic class, a generic method in a nongeneric class or a generic
method in a generic class. A function's generic signature is a
concatenation of the generic context and the function's own generic
type parameters.

e.g.

struct S<T> {
var x: T
@_specialize(Int, Float)
mutating func exchangeSecond<U>(u: U, _ t: T) -> (U, T) {
x = t
return (u, x)
}
}
// Substitutes: <T, U> with <Int, Float> producing:
// S<Int>::exchangeSecond<Float>(u: Float, t: Int) -> (Float, Int)

---
[SILOptimizer] Introduce an eager-specializer pass.

This pass finds generic functions with @_specialized attributes and
generates specialized code for the attribute's concrete types. It
inserts type checks and guarded dispatch at the beginning of the
generic function for each specialization. Since we don't currently
expose this attribute as API and don't specialize vtables and witness
tables yet, the only way to reach the specialized code is by calling
the generic function which performs the guarded dispatch.

In the future, we can build on this work in several ways:
- cross module dispatch directly to specialized code
- dynamic dispatch directly to specialized code
- automated specialization based on less specific hints
- partial specialization
- and so on...

I reorganized and refactored the optimizer's generic utilities to
support direct function specialization as opposed to apply
specialization.
2016-03-21 12:43:05 -07:00
Xin Tong
cff61d7fe7 Implement a function signature cloner and rewriter.
This split the function signature module pass into 2 functin passes.

By doing so,  this allows us to rewrite to using the FSO-optimized
function prior to attempting inlining, but allow us to do a substantial
amount of optimization on the current function before attempting to do
FSO on that function.

And also helps us to move to a model which module pass is NOT used unless
necesary.

I do not see regression nor improvement for on the performance test suite.

functionsignopts.sil and functionsignopt_sroa.sil are modified because the
mangler now takes into account of information in the projection tree.
2016-03-19 23:57:37 -07:00
Andrew Trick
5bda28e1cb Revert "Merge pull request #1725 from atrick/specialize"
Temporarily reverting @_specialize because stdlib unit tests are
failing on an internal branch during deserialization.

This reverts commit e2c43cfe14, reversing
changes made to 9078011f93.
2016-03-18 22:31:29 -07:00
Erik Eckstein
6d654aa3e8 Debugging on SIL level.
This change follows up on an idea from Michael (thanks!).
It enables debugging and profiling on SIL level, which is useful for compiler debugging.

There is a new frontend option -gsil which lets the compiler write a SIL file and generated debug info for it.
For details see docs/DebuggingTheCompiler.rst and the comments in SILDebugInfoGenerator.cpp.
2016-03-18 14:02:06 -07:00
Andrew Trick
295dc96fb6 [SILOptimizer] Introduce an eager-specializer pass.
This pass finds generic functions with @_specialized attributes and
generates specialized code for the attribute's concrete types. It
inserts type checks and guarded dispatch at the beginning of the
generic function for each specialization. Since we don't currently
expose this attribute as API and don't specialize vtables and witness
tables yet, the only way to reach the specialized code is by calling
the generic function which performs the guarded dispatch.

In the future, we can build on this work in several ways:
- cross module dispatch directly to specialized code
- dynamic dispatch directly to specialized code
- automated specialization based on less specific hints
- partial specialization
- and so on...

I reorganized and refactored the optimizer's generic utilities to
support direct function specialization as opposed to apply
specialization.
2016-03-18 10:18:55 -07:00
Mark Lacey
75cdaa327f Run more function passes in a single run of the pass manager.
This commit moves the SILLinker pass out of AddSSAPasses, so that we run
more function passes on each function before moving up to it's callers.

Now the only remaining module passes in AddSSAPasses are GlobalOpt and
LetPropertiesOpt, which run only when we call AddSSAPasses for the
MidLevel optimizations.

This commit also adds the high level loop opt passes onto the same pass
run. As a result of this and moving SILLinker out of AddSSAPasses, we
now run far more passes together on a given function before moving up
the call graph to the callers.

The net result is that I am now seeing approximately a 2% reduction in
stdlib compile times, with only a single significant performance
regression (there are some other minor improvements and regressions, and
some major improvements with -Ounchecked).

The 2% reduction appears to come largely from the mechanism in the pass
manager that skips running passes if we've not made any changes to a
function since the last time the pass was run.
2016-03-10 13:07:38 -08:00
Mark Lacey
27b63abeda Move RLE after inlining.
In theory we should be able to eliminate more loads if we run this after
the mem2reg that is after inlining. We aren't really relying heavily on
having promoted values like this prior to inlining.

Again, I see no significant performance delta, but this seems like the
best place to put this pass if we're only running it once per run of the
SSA passes.
2016-03-01 15:30:37 -08:00
Mark Lacey
014e312a2e Run redundant load elimination earlier in the pipeline.
Doing this earlier means that optimizations that are looking at SIL
values (rather than memory) have more opportunities earlier.

Minimal impact at the moment, but this may allow for removing some later
passes that are repeated.
2016-03-01 14:06:49 -08:00
Mark Lacey
fa4e499e0e Fix comments. 2016-02-26 22:40:11 -08:00
Mark Lacey
f288c6c645 Remove two runs of the passes in AddSSAPasses.
Re-apply b00dcbe with a small test update, and a small change in pass
ordering.

I measure around a 10% reduction in compile times of release no-assert
builds of the stdlib and StdlibUnitTest.

For release + debug-swift builds, I see 20% reduction in stdlib compile
time.

My latest measurements show a few regressions at -O:
  Calculator
  NSError
  SetIsSubsetOf
  Sim2DArray

There is a small (0.1%) reduction in the libswiftCore.dylib size.

Being able to remove these is a consequence of the reordering that
happened in e50daa6.
2016-02-26 21:03:58 -08:00
Mark Lacey
b6de7239e6 Revert "Remove two runs of the passes in AddSSAPasses."
This reverts commit b00dcbebbf due to a
test failure.
2016-02-24 22:12:29 -08:00
Mark Lacey
b00dcbebbf Remove two runs of the passes in AddSSAPasses.
I measure around a 10% reduction in compile times of release no-assert
builds of the stdlib and StdlibUnitTest.

For release + debug-swift builds, I see 20% reduction in stdlib compile
time.

I saw no reproducible regressions in the benchmarks, and a few
improvements.

There is a small (0.1%) reduction in the libswiftCore.dylib size.

Being able to remove these is a consequence of the reordering that
happened in e50daa6.
2016-02-24 21:54:27 -08:00
Mark Lacey
e50daa6e3b Shuffle around some of the optimization passes.
The end goal here is to end up with a good pass ordering that will allow
us to only run one set of these passes, rather than running them
twice. This is a start in that direction.

No real impact measured on compile times as of this change. On
benchmarks I see a mix of regressions and improvements.

-O improvements:
  Calculator           -17.6%     1.21x
  Chars                -54.4%     2.19x
  PolymorphicCalls     -14.7%     1.17x
  SetIsSubsetOf        -14.1%     1.16x
  Sim2DArray           -14.1%     1.16x
  StrToInt             -30.4%     1.44x

-O regressions:
  CaptureProp          +32.9%     0.75x
  DictionarySwap       +36.0%     0.74x
  XorLoop              +39.8%     0.72x

-Ounchecked improvements:
  Chars                -58.0%     2.38x

-Ounchecked regressions:
  CaptureProp          +33.3%     0.75x

-Onone improvements:
  StrToInt             -14.9%     1.18x
  StringWalk           -47.6%     1.91x
  StringWithCString    -17.2%     1.21x
  (many more smaller improvements)

-Onone regressions:
  Calculator           +21.5%     0.82x
  OpenClose            +10.1%     0.91x
2016-02-24 14:18:08 -08:00
Mark Lacey
594a0d8c08 Use AddSSAPasses to add low-level passes.
This eliminates a pretty similar list of passes added in a similar order
with just re-using the ordering from AddSSAPasses. Beyond the particular
inliner pass (which is maintained with this change), there was nothing
really specific to low-level code with the order that was present before.

I measure a 1% increase in compile time of the stdlib, no perf
regressions (at -O), and a few decent improvements:
 19 CaptureProp                           5233             4129     -1104    -21.1%     1.27x
 30 ErrorHandling                         3053             2678      -375    -12.3%     1.14x
 65 Sim2DArray                             610              518       -92    -15.1%     1.18x

I expect to be able to get back the 1% compile-time hit (and probably
more) with future changes.
2016-02-20 14:38:21 -08:00
Xin Tong
79c1f38724 Remove 1/5 iterations of redundant load elim. I do not see performance
regression. but do see a compilation time improvement
2016-02-09 22:20:10 -08:00
Xin Tong
4837889e63 Reapply Add a dead function elimination pass before we run SIL highlevel optimizations
I see improvement in compiling stdlib -O.

=== Before adding the pass ===
real time: 1m3.472s

=== After adding the pass ===
real time: 1m1.793s
2016-02-05 22:19:02 -08:00
Slava Pestov
f2157c93d1 Revert "Add a dead function elimination pass before we run SIL highlevel optimizations."
This reverts commit 909c3b28c4 because it
broke SILOptimizer/sil_witness_tables_external_witnesstable.swift.
2016-02-05 20:57:11 -08:00
Xin Tong
909c3b28c4 Add a dead function elimination pass before we run SIL highlevel optimizations.
I see slight compilation time improvements.
2016-02-05 20:22:35 -08:00
Mark Lacey
82fd057eaf Remove devirtualization and specialization from the inliner.
Now that we process functions in bottom-up order in the pass manager and
have a mechanism to restart the pass pipeline on the current
function (or on a newly created callee function), we can split these
passes back out from the inliner and end up with the same benefits we
had from initially integrating them. We get the further benefit of fully
optimizing newly created callee functions before continuing with the
function that resulted in the creation of those callee
functions (e.g. as a result of a specialization pass running).
2016-02-04 08:52:01 -08:00
Xin Tong
f73626eb28 Remove 4/5 runs of dead store elimination. I did not measure a real performance difference on
my local machine.

rdar://24392141

This is going to cut compilation time spent in dead store elim by 5X

The last iteration of dead store ran just before the last iteration of arc-sequence-opt
allows us to catch some opportunites passes like Mem2Reg can not eliminate. And this allows
more code motion freedom.

Stdlib -O after removing 4/5 dead stores.
=========================================

Running Time	Self (ms)		Symbol Name
22082.0ms   37.1%	0.0	 	    swift::runSILOptimizationPasses(swift::SILModule&)
21905.0ms   36.8%	0.0	 	     swift::SILPassManager::runOneIteration()
17616.0ms   29.6%	35.0	 	      swift::SILPassManager::runFunctionPasses(llvm::ArrayRef<swift::SILFunctionTransform*>)
16667.0ms   28.0%	55.0	 	       swift::SILPassManager::runPassesOnFunction(llvm::ArrayRef<swift::SILFunctionTransform*>, swift::SILFunction*)
3063.0ms    5.1%	7.0	 	        (anonymous namespace)::SimplifyCFGPass::run()
2936.0ms    4.9%	20.0	 	        (anonymous namespace)::ARCSequenceOpts::run()
2343.0ms    3.9%	3.0	 	        (anonymous namespace)::SILCombine::run()
1900.0ms    3.1%	110.0	 	        (anonymous namespace)::SILCSE::run()
1642.0ms    2.7%	43.0	 	        (anonymous namespace)::RedundantLoadElimination::run()
1113.0ms    1.8%	6.0	 	        (anonymous namespace)::GenericSpecializer::run()
788.0ms    1.3%	120.0	 	        (anonymous namespace)::DCE::run()
495.0ms    0.8%	3.0	 	        (anonymous namespace)::SILCodeMotion::run()
304.0ms    0.5%	1.0	 	        (anonymous namespace)::StackPromotion::run()
292.0ms    0.4%	1.0	 	        (anonymous namespace)::ConstantPropagation::run()
269.0ms    0.4%	5.0	 	        (anonymous namespace)::ABCOpt::run()
236.0ms    0.3%	35.0	 	        (anonymous namespace)::SILSROA::run()
192.0ms    0.3%	2.0	 	        (anonymous namespace)::SILMem2Reg::run()
146.0ms    0.2%	65.0	 	        (anonymous namespace)::SILLowerAggregate::run()
132.0ms    0.2%	5.0	 	        (anonymous namespace)::LICM::run()
132.0ms    0.2%	7.0	 	        (anonymous namespace)::DeadStoreElimination::run()
96.0ms    0.1%	65.0	 	        (anonymous namespace)::Devirtualizer::run()
67.0ms    0.1%	59.0	 	        (anonymous namespace)::DeadObjectElimination::run()
62.0ms    0.1%	44.0	 	        (anonymous namespace)::RemovePinInsts::run()

StdlibUnitTest -O after removing 4/5 dead stores.
=================================================

Running Time	Self (ms)		Symbol Name
6958.0ms   26.9%	0.0	 	    swift::runSILOptimizationPasses(swift::SILModule&)
6923.0ms   26.8%	0.0	 	     swift::SILPassManager::runOneIteration()
5638.0ms   21.8%	5.0	 	      swift::SILPassManager::runFunctionPasses(llvm::ArrayRef<swift::SILFunctionTransform*>)
5363.0ms   20.7%	8.0	 	       swift::SILPassManager::runPassesOnFunction(llvm::ArrayRef<swift::SILFunctionTransform*>, swift::SILFunction*)
1535.0ms    5.9%	1.0	 	        (anonymous namespace)::ARCSequenceOpts::run()
789.0ms    3.0%	2.0	 	        (anonymous namespace)::SimplifyCFGPass::run()
704.0ms    2.7%	0.0	 	        (anonymous namespace)::SILCombine::run()
615.0ms    2.3%	36.0	 	        (anonymous namespace)::SILCSE::run()
506.0ms    1.9%	14.0	 	        (anonymous namespace)::RedundantLoadElimination::run()
224.0ms    0.8%	44.0	 	        (anonymous namespace)::DCE::run()
150.0ms    0.5%	1.0	 	        (anonymous namespace)::SILCodeMotion::run()
113.0ms    0.4%	1.0	 	        (anonymous namespace)::StackPromotion::run()
98.0ms    0.3%	4.0	 	        (anonymous namespace)::DeadStoreElimination::run()
80.0ms    0.3%	3.0	 	        (anonymous namespace)::ABCOpt::run()
74.0ms    0.2%	5.0	 	        (anonymous namespace)::LICM::run()
2016-02-01 12:52:36 -08:00