Commit Graph

2295 Commits

Author SHA1 Message Date
Erik Eckstein
78a3572fa4 Rename NoDTC to NoTypeCheck. NFC.
Swift SVN r26973
2015-04-04 08:24:59 +00:00
Mark Lacey
c1dc4bf76a Reword a couple statistic descriptions.
Swift SVN r26970
2015-04-04 02:29:18 +00:00
Mark Lacey
066274e672 Remove invalidation of loop analysis.
We already invalidate all the analyses for each function we inline into,
so this shouldn't be necessary.

We should also be able to remove the invalidation of dominators for the
same reason, but I am getting one test failure when I do that so it
needs further investigation.

Swift SVN r26939
2015-04-03 14:50:08 +00:00
Erik Eckstein
2f971c22cb re-apply r26871: stdlib: Do the Array fast-path check with a single array property call.
Changes compared to the original version:
I fixed the 2 bugs and added a test for the so far undetected missing range check bug.
To keep the SIL simple (4 basic blocks for arr[x]) I extracted the slow path for getElement into a
non-inlinable function.
On the other hand I inlined _typeCheck into the slow-path function.
This speeds up NSArray accesses because now only a single objectAtIndex is required for both
type checking and element retrieving.

Update on performance: DeltaBlue is now only 12% better (and not 25%). I suspect this is because
now Arnold's tail duplication cannot detect the ObjC call in the slow path.



Swift SVN r26935
2015-04-03 06:48:25 +00:00
Mark Lacey
283b08c511 Properly invalidate analyses when we devirtualize during inlining.
Swift SVN r26934
2015-04-03 06:17:02 +00:00
Andrew Trick
891753747f SILCombine. Bail out of propagateConcreteTypeOfInitExistential on archetypes.
Fixes <rdar://problem/20310739> HELP!!! Xcode 6.3 beta 4: segmentation fault 11.

Swift SVN r26903
2015-04-02 21:50:08 +00:00
Chris Lattner
79ed57f9f2 standardize naming of tuples and tuple patterns on "elements".
Previously some parts of the compiler referred to them as "fields",
and most referred to them as "elements".  Use the more generic 'elements'
nomenclature because that's what we refer to other things in the compiler
(e.g. the elements of a bracestmt).

At the same time, make the API better by providing "getElement" consistently
and using it, instead of getElements()[i].

NFC.



Swift SVN r26894
2015-04-02 20:23:49 +00:00
Mark Lacey
a85cc9c6e9 Update call graph to track FullApplySites rather than ApplyInsts.
Use FullApplySite rather than ApplyInst through data structures and
function signatures.

This change does not update the call graph to actually look at
TryApply. That will happen in a future change.

Swift SVN r26893
2015-04-02 20:22:10 +00:00
Roman Levenstein
55ea9ec0e3 [sil-combine] Minor clean-up of casts optimizations. NFC.
Add more checks and logic into emitSuccessfulIndirectUnconditionalCast and emitSuccessfulScalarUnconditionalCast, so that its clients in sil-combine can be simplified by avoiding looking into special cases.

Swift SVN r26885
2015-04-02 19:57:35 +00:00
Mark Lacey
ea2cbffb31 Remove IgnoreMissing parameter from removeEdgeForApply().
Instead, add a removeEdge() and update code to use
getCallGraphEdge()/removeEdge() in cases where the apply may not be
represented in the call graph.

Swift SVN r26881
2015-04-02 18:59:18 +00:00
Arnold Schwaighofer
e08e118246 SimplifyCFG: Fix Changed handling
Once we changed the CFG we changed it ...

Noticed while looking at other bugs we probably have in the vicinity.
No test case.

Swift SVN r26880
2015-04-02 17:48:55 +00:00
Michael Gottesman
804e93980f Use correct method name. NFC.
Swift SVN r26879
2015-04-02 17:45:09 +00:00
Michael Gottesman
f31ddf309f [sil-combine] Invalidate all analyses except for CallGraphAnalysis which we keep up to date manually.
Swift SVN r26878
2015-04-02 17:32:15 +00:00
Michael Gottesman
557626a964 Instead of using ~0U to signify we have not found a result yet, use an optional.
Swift SVN r26877
2015-04-02 17:24:09 +00:00
Roman Levenstein
a7d0eb17ba [sil-combine] casts to/from existentials cannot be further simplified.
This should fix a bug in Adventure reported in rdar://20396204.

Swift SVN r26875
2015-04-02 17:20:23 +00:00
Mark Lacey
23b6bd84f6 Do not build the call graph just to maintain it.
Before this commit, passes that were attempting to maintain the call
graph would actually build it if it wasn't already valid, just for the
sake of maintaining it.

Now we only maintain it if we already had a valid call graph built.

Swift SVN r26873
2015-04-02 17:16:01 +00:00
Ted Kremenek
69a12dfcb8 Revert "stdlib: Do the Array fast-path check with a single array property call."
This was causing test '1_stdlib/ArrayTraps.swift.gyb' to fail.

Swift SVN r26872
2015-04-02 14:47:19 +00:00
Erik Eckstein
834645a901 stdlib: Do the Array fast-path check with a single array property call.
Now that we can check isNative and NoDTC (no deffered type check needed) with a single bit-mask operation,
it makes sense to have a single array property call for it.
I replaced the the semantics call array.props.needsElementTypeCheck with array.props.isNativeNoDTC,
which is the combination of isNative && !needsElementTypeCheck. I kept array.props.isNative, which is not used for now,
but might be useful in the future, e.g. for array operations which don't care about type checks.

The optimized SIL for a class array access arr[i] now contains the minimum of 4 basic blocks.
PerfTests show +25% for DeltaBlue and some improvemements for -Onone.



Swift SVN r26871
2015-04-02 14:10:54 +00:00
Mark Lacey
6ec9593a15 Split the worthiness logic away from the mechanics of inlining.
Swift SVN r26870
2015-04-02 07:40:02 +00:00
Mark Lacey
3e4d43be11 Coding style tweaks.
Swift SVN r26868
2015-04-02 07:39:58 +00:00
Roman Levenstein
05bf59ef2b [sil-combine] Inform the CallGraph about newly created ApplyInsts.
We were not updating the CallGraph with new ApplyInsts inside sil-combine yet.

Swift SVN r26867
2015-04-02 07:04:12 +00:00
Michael Gottesman
b122c0da47 [array-semantics] Teach array semantics to update the CallGraph when deleting instructions.
Swift SVN r26859
2015-04-02 05:01:09 +00:00
Michael Gottesman
8b36c031a2 [sil-combine] Update the CallGraph when deleting apply insts.
Swift SVN r26858
2015-04-02 05:01:07 +00:00
Roman Levenstein
b0963b443f [sil-simplify-cfg] Fix a bug in checked_cast_br jump-threading.
If current checked_cast_br is reachable via success, failure and unknown at the same time, then we simply don't know the outcome of the dominating check.
No jump-threading should be performed in this case.

I'll commit the test-case tomorrow. The test-case from the radar depends too much on the stdlib internals. We need something smaller and simpler.

rdar://20389307

Swift SVN r26841
2015-04-02 00:49:35 +00:00
Roman Levenstein
0e47a228e1 [sil-simplify-cfg] Fix a stupid copy/paste bug introduced during recent re-factoring. NFC.
This fix is done as part of the rdar://20389307.

Swift SVN r26840
2015-04-02 00:49:33 +00:00
Arnold Schwaighofer
68a3d0263e Revert "Dominating edge condition based jump threading"
This reverts commit r26815.

It is breaking the bot.

Swift SVN r26837
2015-04-01 23:37:26 +00:00
Michael Gottesman
2c1aed9b27 [cow] Teach uniqueness check hoisting how to ignore guaranteed calls to ArraySemantic functions.
We ignore calls to ArraySemantic functions when we hoist uniqueness checks. With
+0 self, this is disrupted by the release that now is in the caller instead of
the callee.

This patch fixes that problem by teaching COWArrayOpts about "guaranteed call
sequences". This is the following pattern:

retain(x)
... nothing that decrements reference counts ...
call f1(@guaranteed_self x)
... nothing that decrements or uses ref counts ...
call f2(@guaranteed_self x)
... nothing that decrements or uses ref counts ...
...
... nothing that decrements or uses ref counts ...
call f$(n-1)(@guaranteed_self x)
... nothing that decrements or uses ref counts ...
call fn(@guaranteed_self x)
... nothing that uses ref counts ...
release(x)

This pattern is created when there are a bunch of guaranteed calls together in a
row (which seems to happen at the "semantic" SIL level). We pattern match the
sequence and then verify that all of the calls are semantic calls. If the
verification succeeds, we can hoist the uniqueness check.

rdar://20340699

Swift SVN r26835
2015-04-01 23:30:03 +00:00
Mark Lacey
13bbd3b11e Move generic specializer cloning code into GenericCloner.h/GenericCloner.cpp.
This leaves nothing but the helper for specializing an ApplySite in
Generics.h/Generics.cpp, and I expect to rename these files accordingly
at some point.

Swift SVN r26827
2015-04-01 22:01:32 +00:00
Mark Lacey
6e02f6bf21 More formatting tweaks needed after previous refactoring.
Swift SVN r26826
2015-04-01 22:01:30 +00:00
Mark Lacey
3199515717 Move all GenericSpecializer code into GenericSpecializer.cpp.
Another refactoring step towards splitting the generic specializer into
a pass vs. the cloner vs. a utility that can specialize a given
ApplySite.

Swift SVN r26817
2015-04-01 19:16:58 +00:00
Mark Lacey
d1cb9bd11a Rename SpecializingCloner to GenericCloner.
We have several cloners for different kinds of specialization at this
point.

Swift SVN r26816
2015-04-01 18:40:19 +00:00
Arnold Schwaighofer
9d81bf8b24 Dominating edge condition based jump threading
The classical jump threading that we have not been doing.

No performance impact measured.

Swift SVN r26815
2015-04-01 18:27:40 +00:00
Arnold Schwaighofer
885afc9043 SimplifyCFG: Tail duplicate when coming from objc-method call blocks
This can expose a path the ARC optimizer can push a retain/release into.

Improves DeltaBlue by 15% in optimized builds.

Swift SVN r26812
2015-04-01 15:01:34 +00:00
Erik Eckstein
5712a7eeaa SimplifyCFG: rewrite the dominator based condition simplification.
The optimization simplifies a condition if it is dominated by a terminating instruction with the same condition.
With this change we can also simplify non-terminator instructions, e.g. a cond_fail which is dominated by a cond_br,
or a select_enum which is dominated by a switch_enum.

I do not handle the pattern cond_br(select_enum) anymore, because SILCombine converts this to switch_enum anyway.

There is no notable effect on the benchmarks. But it simplifies the class array code a bit.



Swift SVN r26809
2015-04-01 10:50:46 +00:00
Mark Lacey
af7a07b0f2 Remove the post-inliner runs of the devirtualization pass.
They have no effect. The pre-inliner run may be enabling some
specialization at this point. If it turns out that is not the case, I'll
remove those runs and delete the pass.

Swift SVN r26792
2015-04-01 02:11:00 +00:00
Mark Lacey
f90de4e2b8 Split trySpecializeApplyOfGeneric() from specializeApplyInstGroup().
More refactoring of generic specializer, on the path to making the this
new function the primary utility that can be used from other passes.

Swift SVN r26791
2015-04-01 02:10:59 +00:00
Mark Lacey
315a645e05 Remove AIList from Generics.h.
There was only one remaining user since it was removed from any function
interfaces, and that should really just use SmallVector directly.

Swift SVN r26790
2015-04-01 02:10:55 +00:00
Mark Lacey
07a5ebed66 Rename devirtualizeApply to tryDevirtualizeApply.
This is more consistent with the other naming in the devirtualization
code for things that might fail.

Swift SVN r26788
2015-04-01 02:10:52 +00:00
Michael Gottesman
cb1bd848dc Sort some headers and change the ordering to match LLVM style. NFC.
Swift SVN r26775
2015-03-31 19:59:01 +00:00
Roman Levenstein
0b12af7225 Really use covered switches this time (no default cases!). NFC.
Swift SVN r26766
2015-03-31 18:32:00 +00:00
Mark Lacey
f9d0329c9d Remove the remaining bucketing in the generic specializer.
As with r26754, this is another step towards simplifying the generic
specializer interface. Since we now properly mangle and can therefore
test if we already have a specialization of this function, we no longer
need to do the bucketing to avoid duplicated work.

The stdlib build is as fast or faster, and the only diffs I see appear
to be either function ordering, UUIDs, or the bit of non-determinism
I've seen in block ordering.

Swift SVN r26765
2015-03-31 17:14:07 +00:00
Chris Lattner
a7a54734c8 revert rr26760: SILPassManager: Further reduce the number of pass runs
this unbreaks the stdlib build with assertions enabled.


Swift SVN r26763
2015-03-31 16:47:15 +00:00
Erik Eckstein
1110dc6cd4 SILPassManager: Further reduce the number of pass runs.
Avoid running a pass a second time if the pass has its own optimize-until-no-more-changes loop.
This pass property can be configured.
Currently I assume that all our function passes don't need to run a second time (without other changes in between).

It further reduces the number of pass runs by about 6%. But this improvement is cosmetic. There is no significant compile time reduction.

There are no performance changes.



Swift SVN r26760
2015-03-31 15:54:42 +00:00
Erik Eckstein
160b8e07db SILPassManager: A new method to reduce the number of SIL pass runs.
It avoids that a pass runs a second time if didn't make any changes in the previous run and no other pass changed the function in between.
rdar://problem/20336764

In this change I also removed the CompleteFunctions analysis which is now obsolete.

Some measurements with swiftbench (-wmo, single threaded):
It reduces the number of pass runs by about 28%. Because only passes are skipped that don't do anything, the effect on compile time is not so dramatic.
The time spent in runSILOptimizationPasses is reduced by ~9% which gives a total compile time reduction of about 3%.




Swift SVN r26757
2015-03-31 14:19:51 +00:00
Erik Eckstein
f520ef894a Add the PassKind as a property in SILTransform.
To set the PassKind automatically, I needed to refactor some code of the pass manager and the pass definitions.
The main changes are:
1) SILPassManager now has an add-function for each pass: PM.add(createP()) -> PM.addP()
2) I removed the ARGS argument in Passes.def, which we didn't use anyway.



Swift SVN r26756
2015-03-31 14:08:19 +00:00
Mark Lacey
d481991b6c First steps at simplifying generic specializer interface.
This change removes some of the bucketing that was happening as part of
generic specialization. Now that we can properly mangle the specialized
function names and look up the previously specialized functions, this is
not necessary.

I verified that stdlib build times do not get longer with this change,
and that the generated SIL is virtually the same (virtually because we
have some non-determinism in our build at the moment:
rdar://problem/20304012).

Swift SVN r26754
2015-03-31 07:15:37 +00:00
Mark Lacey
1312dc36ef Remove unused entrypoint in generic specializer.
Swift SVN r26753
2015-03-31 07:15:36 +00:00
Mark Lacey
a97992b5f5 Change a condition to an assert.
We're never called to specialize functions unless we know we have a
definition.

Swift SVN r26752
2015-03-31 06:27:11 +00:00
John McCall
6d8fff9c06 Parsing and basic structure of try_apply. Not yet properly
threaded into IRGen; tests to follow when that's done.

I made a preliminary effort to make the inliner do the
right thing with try_apply, but otherwise tried to avoid
touching the optimizer any more than was required by the
removal of ApplyInstBase.

Swift SVN r26747
2015-03-31 02:41:03 +00:00
Michael Gottesman
1c8fcec3b9 Convert code that was using ~0 as a failure value to use llvm::Optional instead.
Also remove some redundent includes.

Swift SVN r26746
2015-03-31 01:25:14 +00:00