Commit Graph

115 Commits

Author SHA1 Message Date
Mark Lacey
7b30e832e4 Move contents of CallGraph.h into CallGraphAnalysis.h.
Swift SVN r21393
2014-08-22 00:00:04 +00:00
Nadav Rotem
b432f66c97 Teach the inliner not to inline functions with the @effects attribute during the high-level SSA PM.
This is the current behavior for @semantics("readonly") and it is needed by the high-level
optimization passes because after inlining the semantics/effects information is lost.



Swift SVN r21084
2014-08-07 06:36:44 +00:00
Nadav Rotem
8e44116fe3 Cleanup: change a flag from bool to an enum. NFC.
Swift SVN r21072
2014-08-06 20:26:54 +00:00
Nadav Rotem
898bf23738 Move the CallGraphAnalysis to a new file.
Swift SVN r20714
2014-07-29 23:18:56 +00:00
Mark Lacey
a7556c89f9 Enable transparent inlining of some generic functions.
Fixes part of <rdar://problem/16196801>.

Inline generic functions, but only when:

- There are no unbound archetypes being substituted (due to various
  assumptions in TypeSubstCloner about having all concrete types).

- When no substitution is an existential (due to
  <rdar://problem/17431105>, <rdar://problem/17544901>, and
  <rdar://problem/17714025>).

This gets things limping along, but we really need to fix the above
limitations so that mandatory inlining never fails.

This doesn't enable inlining generics in the performance inliner. There
is no reason it shouldn't work as well, but there is no compelling
reason to do so now and it could have unintended effects on performance.

Some highlights from PreCommitBench -
O0:
            old (ms)   new (ms)  delta (ms)   speedup
ForLoops    1127.00     294.00      833.00     283.3%
LinkedList   828.00     165.00      663.00     401.8%
R17315246    982.00     288.00      694.00     241.0%
SmallPT     3018.00    1388.00     1630.00     117.4%
StringWalk  1276.00      89.00     1187.00    1333.7%
-- most others improve ~10% --

O3:
            old (ms)   new (ms)  delta (ms)   speedup
Ackermann   4138.00    3724.00      414.00      11.1%
Life          59.00      64.00        5.00      -7.8%
Phonebook   2103.00    1815.00      288.00      15.9%
R17315246    430.00     582.00      152.00     -26.1%
StringWalk  1173.00    1097.00       76.00       6.9%

Ofast:
            old (ms)   new (ms)  delta (ms)   speedup
Ackermann   3505.00    3715.00      210.00      -5.7%
Life          49.00      41.00        8.00      19.5%
Memset       684.00     554.00      130.00      23.5%
Phonebook   2166.00    1769.00      397.00      22.4%
StringWalk   829.00     790.00       39.00       4.9%

I've opened the following to track remaining issues that need to be
fixed before we can inline all transparent function applications:
<rdar://problem/17431105>
<rdar://problem/17544901>
<rdar://problem/17714025>
<rdar://problem/17768777>
<rdar://problem/17768931>
<rdar://problem/17769717>

Swift SVN r20378
2014-07-23 06:29:23 +00:00
Andrew Trick
818bc5885d PerformanceInliner; always inline transparent calls. Just to be sure.
Swift SVN r19798
2014-07-10 07:31:41 +00:00
Andrew Trick
ddcd37bfdb NFC: Factor PerformanceInlining profitability logic.
Swift SVN r19793
2014-07-10 06:44:52 +00:00
Andrew Trick
c6356d2461 PerformanceInliner should inline cold transparent calls.
Fixes <rdar://problem/17611447> _fastPath kills optimizer

Swift SVN r19788
2014-07-10 06:04:04 +00:00
Andrew Trick
7f967015c8 Allow ColdBlockInfo to be used conveniently in a SIL module pass.
Swift SVN r19697
2014-07-08 21:43:14 +00:00
Andrew Trick
53cbc3e858 Add a ColdBlockInfo analysis based on DominanceAnalysis.
This will be used by PerformanceInliner, GlobalOpt, and other passes in the future.

Swift SVN r19454
2014-07-02 06:35:09 +00:00
Andrew Trick
23cdbd0f21 Single quotes in comments ruins SIL mode.
Swift SVN r19453
2014-07-02 06:35:08 +00:00
Nadav Rotem
d2019d3e66 Add a an option to the inliner to ignore functions that are marked with the @semantics attribute so that we can perform high-level optimizations on them.
Swift SVN r19441
2014-07-01 23:45:26 +00:00
Manman Ren
7667b829bb [noinline attribute] add noinline attribute.
Propagate it to SILFunction and use it in PerformanceInliner. We also serialize
and parse the attribute.

rdar://15882816


Swift SVN r19150
2014-06-24 23:07:45 +00:00
Mark Lacey
1e87d7aab2 Minor clean-up of inliner code.
Don't pass substitutions as an argument since they are always going to
be from the apply we're passing in.

Swift SVN r18672
2014-05-30 20:24:48 +00:00
Manman Ren
e7f29b154c [SILInliner] stop inlining callees if it is called many times.
To handle recursion and prevent massive code size expansion, we prevent
inlining the same callee many times into the caller.

rdar://16761933


Swift SVN r17635
2014-05-07 18:08:52 +00:00
Manman Ren
c2f32d7e24 [Inliner] revert r17101 since it causes a performance regression on MD5.
See rdar://16676020 for details.
r17101 tries to solve r16761933 by checking non-direct recursions in
the call graph. We are in discussion of solving it in a different way.

Todo: figure out why r17101 causes a preformance regression.


Swift SVN r17265
2014-05-02 19:00:36 +00:00
Nadav Rotem
e406e43060 Disable the inlining of non-direct recursions (where A->B->A).
Swift SVN r17101
2014-04-30 18:45:13 +00:00
Michael Gottesman
30abee8a4c [sil-inliner] Cleanup debug statements and make them more useful. NFC.
Swift SVN r17062
2014-04-30 00:48:13 +00:00
Mark Lacey
1452d24671 Small cleanup: Remove unnecessary calls to getDef(), mostly in dyn_cast<>(...).
Swift SVN r16235
2014-04-11 23:05:16 +00:00
Nadav Rotem
39f50b4f09 Encourage the inliner to inline functions that take closures as arguments.
Swift SVN r14843
2014-03-09 08:26:42 +00:00
Michael Gottesman
90c6c9507b [performance-inliner] Do not inline a callee into a caller if the callee's body references a global/function with less visible linkage than caller.
*NOTE* This is only to keep any less visible items from being exposed by
the inliner. Whether or not the callee has the proper linkage is for the
frontend/etc to ascertain.

Swift SVN r14824
2014-03-08 02:49:36 +00:00
Chris Lattner
001c1890e5 put all the SIL*Transform classes in anonymous namespaces, there is
no need for their symbols to be exported out of their implementation
file.


Swift SVN r14714
2014-03-06 01:49:53 +00:00
Michael Gottesman
87bfe1f5ef Fix performance inliner to actually deserialize functions. Add a test to make sure it always works.
Now the performance inliner properly lazily deserializes empty SILFunctions if
it can deserialize them.

Swift SVN r14579
2014-03-03 03:15:30 +00:00
Michael Gottesman
6e7b77c2ff [deserialization] Change performance inliner to use lazily deserialized functions.
Swift SVN r14491
2014-02-28 01:32:30 +00:00
Andrew Trick
731000b4cd Added -sil-print-all and -sil-verify-all options.
Swift SVN r13662
2014-02-07 23:07:11 +00:00
Andrew Trick
3dbaf8f499 Expose getFunctionCost() so it can be used by other SIL passes.
(devirtualization)

Swift SVN r13641
2014-02-07 19:10:25 +00:00
Andrew Trick
47b936fbae Let passes get their options (current configuration) from the
PassManager.

I think this is much cleaner and more flexible. The various pass
builders have no business marshalling these things around, and they
shouldn't be bound to the pass C'tor. In the future we will be able
override and dynamically modify pass configuration this way.

Swift SVN r13626
2014-02-07 05:01:00 +00:00
Nadav Rotem
1ef0d157ca PassManager: Inject the function/module into the Transformation.
Now the pass does not need to know about the pass manager. We also don't have
runOnFunction or runOnModule anymore because the trnasformation knows
which module it is processing. The Pass itself knows how to invalidate the
analysis, based on the injected pass manager that is internal to the
transformation.

Now our DCE transformation looks like this:

class DCE : public SILModuleTransform {
  void run() {
    performSILDeadCodeElimination(getModule());
    invalidateAnalysis(SILAnalysis::InvalidationKind::All);
  }
};





Swift SVN r13598
2014-02-06 22:11:21 +00:00
Nadav Rotem
4529a4296a Teach the inliner not to invalidate all the analysis if no change was made.
Swift SVN r13581
2014-02-06 17:34:19 +00:00
Nadav Rotem
d6802340fe Change the CallGraph Analysis API and add cacheing and invalidation methods.
Swift SVN r13554
2014-02-06 04:24:51 +00:00
Nadav Rotem
93b5cac34e Remove the top-down call graph ABI and use the reverse bottom-up.
Swift SVN r13544
2014-02-06 01:52:14 +00:00
Nadav Rotem
99b075c32a Rename SILFunctionTrans -> SILFunctionTransform
Swift SVN r13536
2014-02-06 01:32:10 +00:00
Nadav Rotem
f8c7b54d28 Delete the unused performXXX() functions.
Swift SVN r13531
2014-02-06 00:57:28 +00:00
Michael Gottesman
5fa9b88c33 Change createPerfInliner to take in an unsigned threshold value.
Swift SVN r13514
2014-02-05 22:33:33 +00:00
Michael Gottesman
631f9326ab [PM] Change enum => enum class everywhere in the PM code. Additionally fix some typos.
Swift SVN r13507
2014-02-05 21:25:15 +00:00
Nadav Rotem
baa1d1679a Teach some of the passes about the new PM.
Swift SVN r13494
2014-02-05 18:58:23 +00:00
Michael Gottesman
62263c93d3 Remove redundent recursive call check.
We perform the same operation a few lines beneath this instance of the
operation.

Swift SVN r13364
2014-02-03 19:12:57 +00:00
Nadav Rotem
f257537782 Disable the inlining of recursive calls.
We already perform this check in the cost function, but we can also abort early
when we collect the applyinst.


Swift SVN r13362
2014-02-03 18:54:34 +00:00
Michael Gottesman
5d1d37381e [performance-inliner] Simple fix to ensure that we don't get in infinite loops when we inline a recursive function.
This should be expanded to a general manner for preventing the inlining of
callsites that are the result of inlining a different call site.

Swift SVN r13348
2014-02-03 11:11:09 +00:00
Michael Gottesman
70ae7cffaa Remove trailing whitespace.
Swift SVN r13345
2014-02-03 08:16:54 +00:00
Joe Groff
1562e014db PerformanceInliner: Don't inline private references into transparent functions.
Doing so violates the encapsulation of the module exporting the transparent function.

Swift SVN r13283
2014-02-01 03:57:51 +00:00
Jordan Rose
c7f1064527 Extract '-sil-inline-threshold' from the performance inliner.
Plumbing this through to the inliner necessitated the creation of a
SILOptions class (like FrontendOptions and IRGenOptions). I'll move
more things into this soon.

One change: for compatibility with the new driver, the option must be
specified as "-sil-inline-threshold 50" instead of "-sil-inline-threshold=50".
(We're really trying to be consistent about joined-equals vs. separate
in the new frontend.)

Swift SVN r13193
2014-01-31 01:52:12 +00:00
Joe Groff
d6403d707e PerformanceInliner: StringLiterals are also free.
Swift SVN r12788
2014-01-22 21:54:57 +00:00
Michael Gottesman
fe0e7c5703 [performance-inliner] Move SILArgument, SILUndef to end of InlineCost list with the rest of the unreachable cases. Also remove incorrect comment.
Swift SVN r12768
2014-01-22 19:26:28 +00:00
Joe Groff
6fef7ee8d7 PerformanceInliner: Returns and unreachables are free.
Swift SVN r12766
2014-01-22 19:24:16 +00:00
Joe Groff
1a2d08973f PerformanceInliner: Calculate the full cost of functions when DEBUG-ing.
Swift SVN r12765
2014-01-22 19:24:13 +00:00
Michael Gottesman
f44ae51666 [performance-inliner] SILArgument, SILUndef should never be passed in for cost since the function only takes SILInstruction.
Swift SVN r12759
2014-01-22 18:41:26 +00:00
Michael Gottesman
63c2bff313 [performance-inliner] Change instructionInlineCost to return an InlineCost enum to enable easier tweakings of the cost associated with various categories of instructions.
Swift SVN r12756
2014-01-22 18:30:06 +00:00
Joe Groff
287f5071b5 PerformanceInliner: Unchecked casts and thin metatypes are free.
This pushes _convertFromStringLiteral below the inlining threshold.

Swift SVN r12752
2014-01-22 18:19:55 +00:00
Joe Groff
3b0a8c8720 PerformanceInliner: struct, tuple, struct_extract, and tuple_extract are free.
These just shuffle values between explosions in IRGen.

Swift SVN r12747
2014-01-22 17:50:57 +00:00