Commit Graph

11224 Commits

Author SHA1 Message Date
John McCall
2df6880617 Introduce ProtocolConformanceRef. NFC.
The main idea here is that we really, really want to be
able to recover the protocol requirement of a conformance
reference even if it's abstract due to the conforming type
being abstract (e.g. an archetype).  I've made the conversion
from ProtocolConformance* explicit to discourage casual
contamination of the Ref with a null value.

As part of this change, always make conformance arrays in
Substitutions fully parallel to the requirements, as opposed
to occasionally being empty when the conformances are abstract.

As another part of this, I've tried to proactively fix
prospective bugs with partially-concrete conformances, which I
believe can happen with concretely-bound archetypes.

In addition to just giving us stronger invariants, this is
progress towards the removal of the archetype from Substitution.
2016-01-08 00:19:59 -08:00
Michael Gottesman
7b17debfbd Revert "[loop-region] Add in an assert that we should always have a block result for getRegionForNonLocalSuccessors. NFC."
This reverts commit 81e7bdfe1b.

This is not true in non-loop canonicalized SIL. It is true in loop-canonicalized
SIL though. So I need to fix the test to avoid the assert.
2016-01-07 20:46:12 -08:00
Michael Gottesman
81e7bdfe1b [loop-region] Add in an assert that we should always have a block result for getRegionForNonLocalSuccessors. NFC. 2016-01-07 20:32:05 -08:00
Michael Gottesman
385c4a54dc [passmanager] When visiting functions in runFunctionPasses, make sure to check continueTransforming.
While debugging some code I noticed that we were not checking
continueTransforming everywhere that we needed to. This commit adds the missing
check.
2016-01-07 19:22:47 -08:00
Slava Pestov
046606a8f4 SIL: Add a new alloc_global instruction
If a global variable in a module we are compiling has a type containing
a resilient value type from a different module, we don't know the size
at compile time, so we cannot allocate storage for the global statically.

Instead, we will use a buffer, just like alloc_stack does for archetypes
and resilient value types.

This adds a new SIL instruction but does not yet make use of it.
2016-01-07 13:40:48 -08:00
Mark Lacey
176ba99c84 Don't run the stand-alone devirtualization and specialization passes.
They aren't needed at the moment, and running the specialization pass
early might have resulted in some performance regressions.

We can add these back in (and in the appropriate place in the pipeline)
when the changes to unbundle this functionality from the inliner goes in.
2016-01-07 10:36:28 -08:00
Erik Eckstein
9ad406d5d6 Remove the local_storage type attribute and SIL value category.
They are not used anymore as alloc_stack now returns a single value.
2016-01-06 17:35:27 -08:00
Erik Eckstein
c3a769e1bd Fix code examples with alloc_stack in comments.
Reflecting the change that alloc_stack now returns a single value. NFC.
2016-01-06 17:35:27 -08:00
Erik Eckstein
6ff2f09796 [SIL] Let alloc_stack return a single value.
Having a separate address and container value returned from alloc_stack is not really needed in SIL.
Even if they differ we have both addresses available during IRGen, because a dealloc_stack is always dominated by the corresponding alloc_stack in the same function.

Although this commit quite large, most changes are trivial. The largest non-trivial change is in IRGenSIL.

This commit is a NFC regarding the generated code. Even the generated SIL is the same (except removed #0, #1 and @local_storage).
2016-01-06 17:35:27 -08:00
Doug Gregor
1a38e0ad3b Merge branch 'master' into swift-3-api-guidelines 2016-01-06 15:32:55 -08:00
Erik Eckstein
3ce4fbfbaa Let the ComputeDominanceInfo pass also compute post-dominance info.
And use this in the recently added test.
2016-01-06 09:40:46 -08:00
practicalswift
e0eba97b98 Fix typos. 2016-01-06 00:48:22 +01:00
practicalswift
44c2cbc582 Use correct formatting for start-of-file header. 2016-01-05 09:48:47 +01:00
Xin Tong
6ce0f00f54 Remove a *pass* keyword for consistency 2016-01-04 22:21:03 -08:00
Mark Lacey
cdc41078bd Move cases for switch_enum_addr and checked_cast_addr_br in switch.
These should be with the other cases we do not expect block arguments
for.
2016-01-04 15:40:11 -08:00
Nadav Rotem
b8c4eddf27 Merge pull request #873 from practicalswift/typo-fixes-20160104b
[gardening] Fix recently introduced typos
2016-01-04 15:07:43 -08:00
Nadav Rotem
ff5de10dee Merge pull request #875 from practicalswift/consistent-headers-final-pr
[gardening] Use consistent formatting of header comments
2016-01-04 15:07:24 -08:00
practicalswift
ca92efc8e6 Use consistent formatting of header comments.
Correct format:
```
//===--- Name of file - Description ----------------------------*- Lang -*-===//
```

Notes:
* Comment line should be exactly 80 chars.
* Padding: Pad with dashes after "Description" to reach 80 chars.
* "Name of file", "Description" and "Lang" are all optional.
* In case of missing "Lang": drop the "-*-" markers.
* In case of missing space: drop one, two or three dashes before "Name of file".
2016-01-04 23:00:53 +01:00
Max Moiseev
f51e708a8f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-04 12:25:25 -08:00
practicalswift
7b2bc2a0f4 Fix recently introduced typos. 2016-01-04 21:22:33 +01:00
practicalswift
dee6922037 Update copyright notice. 2016-01-04 21:18:31 +01:00
Xin Tong
ba40b3f1a7 Take a more displined approach in DSE as to how to a function is optimized.
Now we have 3 cases.

1. OptimizeNone (for functions with too many basicblocks and too many locations). Simply return.
2. Pessimisitc single iteration data flow (for functions with many basic blocks and many locations).
3. Optimistic multiple iteration data flow (for functions with some basic blocks and some locations
   and require iterative data flow).

With this change stdlib and stdlibunittest has some changes in dead store(DS)
eliminated.

stdlib: 202 -> 203 DS.
stdlibunittest: 42 - 39 DS.

Compilation time improvement: with this change on a RELEASE+ASSERT compiler for stdlibunittest.

Running Time        Self (ms)               Symbol Name
5525.0ms    5.3%    25.0                     (anonymous namespace)::ARCSequenceOpts::run()
3500.0ms    3.4%    25.0                     (anonymous namespace)::RedundantLoadElimination::run()
3050.0ms    2.9%    25.0                     (anonymous namespace)::SILCombine::run()
2700.0ms    2.6%    0.0                      (anonymous namespace)::SimplifyCFGPass::run()
2100.0ms    2.0%    75.0                     (anonymous namespace)::SILCSE::run()
1450.0ms    1.4%    0.0                      (anonymous namespace)::DeadStoreElimination::run()
750.0ms    0.7%     75.0                     (anonymous namespace)::DCE::run()

Compilation time improvement: with this change on a DEBUG compiler for stdlibunittest.

Running Time        Self (ms)               Symbol Name
42300.0ms    4.9%   50.0                      (anonymous namespace)::ARCSequenceOpts::run()
35875.0ms    4.1%   0.0                       (anonymous namespace)::RedundantLoadElimination::run()
30475.0ms    3.5%   0.0                       (anonymous namespace)::SILCombine::run()
19675.0ms    2.3%   0.0                       (anonymous namespace)::SILCSE::run()
18150.0ms    2.1%   25.0                      (anonymous namespace)::SimplifyCFGPass::run()
12475.0ms    1.4%   0.0                       (anonymous namespace)::DeadStoreElimination::run()
5775.0ms    0.6%    0.0                       (anonymous namespace)::DCE::run()

I do not see a compilation time change in stdlib.

Existing tests ensure correctness.
2016-01-04 10:04:54 -08:00
Erik Eckstein
f1f4c69476 SILCombine: fix non-deterministic compilation
This is another bug exposed by changing the instruction allocation.
Depending on the allocated address of new SILBuilder instructions, those instructions were added to the SILCombiner worklist or not.
This bug didn't cause any crashes or miscombiles, but resulted in a non-deterministic result of SILCombine.
2016-01-04 09:39:58 -08:00
Erik Eckstein
9e2e24b7d8 SILCombine: add debug message. NFC. 2016-01-04 09:31:01 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
practicalswift
fd608f3d85 Fix incorrect file names in file headers. 2016-01-04 10:02:46 +01:00
practicalswift
f91525a10f Consistent placement of "-*- [language] -*-===//" in header. 2016-01-04 09:46:20 +01:00
Chris Lattner
5b327770aa Merge pull request #865 from practicalswift/consistent-headers
[gardening] Use consistent formatting for all top of file headers in the project
2016-01-03 20:27:17 -08:00
practicalswift
50baf2e53b Use consistent formatting in top of file headers. 2016-01-04 02:17:48 +01:00
Michael Gottesman
80e5854e88 [codegardening] Add a new pass called RCIdentityDumper that dumps the RCIdentity of all values in all functions.
This allows for the RCIdentityAnalysis to be tested independent of other
passes.

Also add some initial tests for RCIdentity. I am stepping through "strip by
strip" but I did not have time to finish the coverage.
2016-01-03 19:04:54 -06:00
Michael Gottesman
0e865e873c [codegardening] Separate MemBehaviorDumper and AADumper... again. 2016-01-03 18:50:35 -06:00
Michael Gottesman
606df10725 doxygenify file level comment. 2016-01-03 18:44:31 -06:00
Michael Gottesman
e1ef60987c Revert "[codegardening] Move MemBehaviorDumper from AADumper.cpp into its own file MemoryBehaviorDumper.cpp."
Revert "Make AADumper and MemoryBehaviorDumper function passes. They do not need to be module passes."

This reverts commit a503269e2d.
This reverts commit 375f525c51.

Turns out we /do/ want these two passes to be module passes so that their output
is independent of how the pass manager schedules function passes.

I tried to just fix the issue in MemBehaviorDumper/AADumper without reverting,
but somehow this caused their tests to start failing?!

I will try separating them again in a subsequent commit.
2016-01-03 18:41:34 -06:00
practicalswift
31ff35e1dd Use 80 column headers consistently. 2016-01-04 01:35:02 +01:00
Michael Gottesman
a503269e2d [codegardening] Move MemBehaviorDumper from AADumper.cpp into its own file MemoryBehaviorDumper.cpp. 2016-01-03 16:32:59 -06:00
Michael Gottesman
375f525c51 Make AADumper and MemoryBehaviorDumper function passes. They do not need to be module passes. 2016-01-03 16:27:02 -06:00
Michael Gottesman
11b2a7d29c [arc-sequence-opts] Add more log output.
This makes it easy to see which individual retains/releases are partial/known
safe so one can reason about why the final set is partial/known safe (or not).
2016-01-03 16:02:41 -06:00
Mark Lacey
149e1e4059 Fix 80-column violations. 2016-01-03 13:15:56 -08:00
practicalswift
6c32688275 Fix recently introduced typos. 2016-01-03 21:16:23 +01:00
Xin Tong
4ea79fec2b There are simply too many locations and too many basic blocks in some
functions for dead store elimination to handle.  In the worst case, The number of
memory behavior or alias queries we need to do is roughly linear to
the # BBs x(times) # of locations.

Put in some heuristic to trade off accuracy for compilation time.

NOTE: we are not disabling DSE for these offending functions. instead we are running
a one iteration pessimistic data flow as supposed to the multiple iteration optimistic
data flow we've done previously.

With this change. I see compilation time on StdlibUnitTest drops significantly.
50%+ drop in time spent in DSE in StdlibUnit with a release compiler.

I will update more Instruments data post-commit once i get close to my desktop.

I see a slight drop in # of dead stores (DS) elimination in stdlib and stdlibUnit test.

stdlib: 203 DS -> 202 DS. (RLE is affected slightly as well. 6313 -> 6295 RL).

stdlibunittest :  43 DS -> 42. (RLE is not affected).

We are passing all existing dead store tests.
2016-01-03 10:48:02 -08:00
Xin Tong
013d08d439 Add a bailout location # threshold in DSE.
In StdlibUnitTest, there is this function that has too many (2450) LSLocations
and the data flow in DSE takes too long to converge.

StdlibUnittest.TestSuite.(addForwardRangeReplaceableCollectionTests <A, B where A: Swift.RangeReplaceableCollectionType, B: Swift.RangeReplaceableCollectionType, A.SubSequence: Swift.CollectionType, B.Generator.Element: Swift.Equatable, A.SubSequence == A.SubSequence.SubSequence, A.Generator.Element == A.SubSequence.Generator.Element> (Swift.String, makeCollection : ([A.Generator.Element]) -> A, wrapValue : (StdlibUnittest.OpaqueValue<Swift.Int>) -> A.Generator.Element, extractValue : (A.Generator.Element) -> StdlibUnittest.OpaqueValue<Swift.Int>, makeCollectionOfEquatable : ([B.Generator.Element]) -> B, wrapValueIntoEquatable : (StdlibUnittest.MinimalEquatableValue) -> B.Generator.Element, extractValueFromEquatable : (B.Generator.Element) -> StdlibUnittest.MinimalEquatableValue, checksAdded : StdlibUnittest.Box<Swift.Set<Swift.String>>, resiliencyChecks : StdlibUnittest.CollectionMisuseResiliencyChecks, outOfBoundsIndexOffset : Swift.Int) -> ()).(closure #18)

This function alone takes ~20% of the total amount of time spent in DSE in StdlibUnitTest.

And DSE does not eliminate any dead store in the function either. I added this threshold
to abort on functions that have too many LSLocations.

I see no difference in # of dead store eliminated in the Stdlib.
2016-01-02 17:37:53 -08:00
Michael Gottesman
9e551dd237 Doxygenify file level comment. 2016-01-02 16:41:36 -06:00
Michael Gottesman
3d8433b7f6 [arc] Add in a new semantics attribute called "arc.programtermination_point" and document it.
If this semantic tag is applied to a function, then we know that:

- The function does not touch any reference counted objects.
- After the function is executed, all reference counted objects are leaked
  (most likely in preparation for program termination).

This allows one, when performing ARC code motion, to ignore blocks that contain
an apply to this function as long as the block does not have any other side
effect having instructions.

I have wanted to do this for a while but was stymied by lacking the ability to
apply multiple @_semantics attributes. This is now committed to trunk so I added
this attribute instead of pattern matching against fatalError (since there could
be other functions with this property).

rdar://19592537
2016-01-02 16:22:06 -06:00
Michael Gottesman
389238e801 Add support for multiple @_semantics attributes at the SIL level.
This is something that we have wanted for a long time and will enable us to
remove some hacks from the compiler (i.e. how we determine in the ARC optimizer
that we have "fatalError" like function) and also express new things like
"noarc".
2016-01-02 04:17:07 -06:00
Xin Tong
310f48eab0 Improve dead store elimination compilation time.
If we know a function is not a one iteration function which means its
its BBWriteSetIn and BBWriteSetOut have been computed and converged,
and a basic block does not even have StoreInsts, there is no point
in processing every instruction in the last iteration of the data flow
again as no store will be eliminated.

We can simply skip the basic block and rely on the converged BBWriteSetIn
to process its predecessors.

Compilation time improvement: 1.7% to 1.5% of overall compilation time.
on stdlib -O. This represents a 4.0% of all SILOptimzations(37.2%)

Existing tests ensure correctness.
2016-01-01 10:16:42 -08:00
Chris Lattner
2af78aede1 forward declare ASTWalker in ASTNode.h instead of including its header, NFC. 2015-12-31 21:05:13 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
practicalswift
2e995a8ba4 Fix recently introduced typos. 2015-12-31 15:28:54 +01:00
Xin Tong
a35eabd6f7 Instead of enumerating all the LSValues before RLE is ran on the function. we
enumerate them lazily.

This leads to compilation time improvement, as some of the LSValues previously
enumerated do not be created in this approach.

i.e. we enumerate LSValues created by loads previously, but the LoadInsts could be
target for RLE. In such case, the enumerated LSValues are not used.

Compilation time improvement: 1775ms to 1721ms (2.7% to 2.6% of the entire
compilation time for stdlib -O).

Existing tests ensure correctness.

Note: we still enumerate locations, as we need to know how many locations there are
in the function to resize the bitvector appropriately before the data flow runs.
2015-12-30 14:35:59 -08:00
Michael Gottesman
a06cacbfcb [projection] Introduce two new types NewProjection and NewProjectionPath.
NewProjection is a re-architecting of Projection that supports all of
the same functionality as Projection but in 1/3 of the original size (in
the common case). It is able to accomplish this by removing the base
type out of NewProjection itself and into users such as
NewProjectionPath. Thus NewProjection is now strictly an index from some
parent type rather than being a parent type and an index.

NewProjectionPath also has all of the same functionality as
ProjectionPath, but due to NewProjection being smaller than Projection
is smaller than ProjectionPath.

Used together NewProjection/NewProjectionPath yields the same output as
Projection/ProjectionPath when evaluating the LSLocation dumping tests.

Additionally, NewProjection is more flexible than Projection and will
for free give us the ability to perform AA on index_addr/index_raw_addr
as well as be able to integrate casts into the projection paradigm.

rdar://22484381
2015-12-29 22:31:09 -06:00