Commit Graph

581 Commits

Author SHA1 Message Date
Erik Eckstein
76eca003bb ArrayElementValuePropagation: explicitly reserve space for new elements when doing the array-content-of optimization
When Array.append(contentOf:) is replaced by individual Array.append(element) calls, an explicit reserveCapacityForAppend is inserted.
2017-04-27 09:06:56 -07:00
Erik Eckstein
e3ae6f29b6 SimplifyCFG: improve jump threading for switch_enum
1) to find a threading candidate for a branch instruction, look through multiple successor blocks and not only in the immediate successor
2) handle SSA-cycles when getting the case for an enum value
2017-04-27 09:06:55 -07:00
Slava Pestov
0290c2d5d8 AST: Make GenericSignature and GenericEnvironment SubstitutionMaps interchangable
SubstitutionMap::lookupConformance() would map archetypes out
of context to compute a conformance path. Do the same thing
in SubstitutionMap::lookupSubstitution().

The DenseMap of replacement types in a SubstitutionMap now
always has GenericTypeParamTypes as keys.

This simplifies some code and brings us one step closer to
a more efficient representation of SubstitutionMaps.
2017-04-24 14:12:36 -07:00
Roman Levenstein
53745e61cf Merge pull request #8961 from swiftix/open-archtypes-tracker-fixes
[sil-opened-archetype-tracker] Improve tracking of archetypes in SILBuilder
2017-04-24 13:52:51 -07:00
Huon Wilson
d08d0ffdb8 Merge pull request #8845 from huonw/private-func-sig-specializations
[SILOpt] Specialized functions are never public.
2017-04-24 10:41:41 -07:00
Roman Levenstein
202de40f05 [sil-opened-archetype-tracker] Improve tracking of archetypes in SILBuilder
Fixes rdar://problem/31749245
2017-04-24 08:50:55 -07:00
Roman Levenstein
a60e037c48 Revert "[sil-opened-archetype-tracker] Improve tracking of archetypes in SILBuilder" 2017-04-22 20:41:31 -07:00
Roman Levenstein
33c8bde859 [sil-opened-archetype-tracker] Improve tracking of archetypes in SILBuilder
Fixes rdar://problem/31749245
2017-04-22 10:03:37 -07:00
Huon Wilson
84035b8bbf [SILOpt] Specialized functions are never public.
Specializations are implementation details, and thus shouldn't be
public, even if they are specializing a public function. Without this
downgrade, the ABI of a module depends on random internal code
(could change inlining decisions etc.), as well as swiftc's optimiser.
2017-04-21 16:58:00 -07:00
Roman Levenstein
e1c3538ecb redundundant-overflow-check-removal improvements
- Code-refactoring
- Support for comparison followed by a cond_fail
- Correctness fixes for relation propagation
2017-04-20 15:28:23 -07:00
practicalswift
7eb7d5b109 [gardening] Fix 100 typos. 2017-04-18 17:01:42 +02:00
Michael Gottesman
ad7705ed42 [semantic-sil] Update OME for having mark_uninitialized on the alloc_box instead of project_box.
This consists of just removing support from OME for ensuring that all uses of a
box go through the project_box that has as its user a mark_uninitialized. Since
the lowering of mark_uninitialized onto the relevant project_box is done by
MarkUninitializedFixup pass, I can just rip out the hacks from the OME!

rdar://31521023
2017-04-17 21:10:24 -07:00
Michael Gottesman
21973e0abc [semantic-sil] Update allocbox-to-stack for the mark_uninitialized begin on the alloc_box instead of the project_box.
This also moves the eliminator pass behind alloc box to stack.

rdar://31521023
2017-04-17 19:09:15 -07:00
Michael Gottesman
aa76c2a5e6 [silgen] (mark_uninitialized (project_box (alloc_box))) -> (project_box (mark_uninitialized (alloc_box)))
I put in a simple fixup pass (MarkUninitializedFixup) for staging purposes. I
don't expect it to be in tree long. I just did not feel comfortable fixing up in
1 commit all of the passes up to DI.

rdar://31521023
2017-04-17 17:45:54 -07:00
Andrew Trick
095083e0e8 CopyForwarding: new optimization to remove copies into dead temporaries.
A SILGen peephole currently handles the common cases. However, that peephole
is incompatible with memory access enforcement.
2017-04-14 21:05:33 -07:00
Huon Wilson
b59f95418c [SIL] Extract ClassVisibility from SILFunction to SubclassScope in SILLinkage. 2017-04-13 14:17:29 -07:00
practicalswift
27eabd4fb5 Merge pull request #8498 from practicalswift/gardening-20170403
[gardening] Fix typos. Fix headers. Python cleanups.
2017-04-12 16:41:33 +02:00
practicalswift
5e255e07d7 [gardening] Remove redundant logic 2017-04-11 23:04:55 +02:00
practicalswift
520469a61a [gardening] Fix a vs an typo 2017-04-11 09:37:55 +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
Erik Eckstein
ee034d0fcb DeadStoreElimination: fix wrong elimination of dead store before is_unique instruction
fixes SR-4524
2017-04-07 09:31:44 -07:00
Andrew Trick
4f52f84939 [SILOpt] Redundant load elimination. Add debug output. 2017-04-05 19:59:15 -07:00
Roman Levenstein
64813b7b4f [sil-function-signature-opt] Support FSO for generic functions
In particular, support the following optimizations:
- owned-to-guaranteed
- dead argument elimination

Argument explosion is disabled for generics at the moment as it usually leads to a slower code.
2017-04-04 12:33:17 -07:00
Michael Gottesman
43a7f3422e [allocbox-to-stack] Update for semantic sil.
rdar://29870610
2017-04-03 14:38:09 -07:00
Michael Gottesman
c28a62d97c [ome] Make sure to rewire all project_box we insert through the mark_uninitialized project_box to preserve DI behavior.
Once I update DI in a bit, this will no longer be necessary.

rdar://29870610
2017-04-03 12:17:44 -07:00
Michael Gottesman
85688b87bb [ome] Change the eliminator to be a module pass instead of a function pass.
This ensures that the pass manager runs the eliminator on all functions once
before running any further passes. Otherwise, due to the way the pass manager
runs functions, sometimes a function with unqualified ownership is visible from
a function with qualified ownership. This makes it impossible to have an
invariant that a pass either sees an entire qualified or unqualified world. This
is a useful feature that I would like to keep if I can.

rdar://29870610
2017-04-03 09:43:37 -07:00
practicalswift
906c36d209 [gardening] Remove unused method collectForwardableValues() 2017-04-02 16:07:54 +02:00
swift-ci
c8d2f179e7 Merge pull request #8464 from eeckstein/array-append-contentof 2017-03-31 17:59:36 -07:00
Erik Eckstein
777f5aaf7a SILOptimizer: Replace [].append(contentsOf:) with [].append(element:)
if the argument is an array literal.

For example:
  arr += [1, 2, 3]

is replaced by:
  arr.append(1)
  arr.append(2)
  arr.append(3)

This gives considerable speedups up to 10x (for our micro-benchmarks which test this).

This is based on the work of @ben-ng, who implemented the first version of this optimization (thanks!).
2017-03-31 17:16:31 -07:00
swift-ci
7dc7207db9 Merge pull request #8474 from atrick/fix 2017-03-31 17:14:10 -07:00
Andrew Trick
2396e7d3cc [SILOpt][NFC] Print projections readably and efficiently.
Begin to make the RLE pass debuggable.
Overhaul the ProjectionPath printing feature and fixup tests.
2017-03-31 16:51:34 -07:00
Erik Eckstein
dc426bd885 SIL optimizer: add some clean-up passes before the inliner.
This is important in case the inline restarts the pass pipeline.
In a sub-sequent invocation of the inlined it should receive a cleaned-up function so that it can make better estimations for further inlining.

As a compensation, reduce the caller-block limit of the inliner.
And add an overall block limit which is also taken into account for always-inline functions.
2017-03-31 15:31:57 -07:00
Erik Eckstein
2cb998f09c PerformanceInliner: add a debug message for an always-inline decision. 2017-03-31 15:31:57 -07:00
Erik Eckstein
9ce3df106e Add two new array semantics functions.
array.append_element(newElement: Element)
array.append_contentsOf(contentsOf newElements: S)

And allow early inlining of them.
Those functions will be needed to optimize Array.append(contentsOf)
2017-03-31 15:31:57 -07:00
Erik Eckstein
e9b4db13ee Reinstate "AllocBoxToStack: Improve alloc_stack/dealloc_stack scoping"
This reverts commit c7ef60c7ed.

It also contains an additional test for the fix in StackNesting
2017-03-30 09:40:09 -07:00
Erik Eckstein
c7ef60c7ed Revert "AllocBoxToStack: Improve alloc_stack/dealloc_stack scoping"
It broke some bots.

This reverts commit 43ddc2a643.
2017-03-30 07:59:05 -07:00
Slava Pestov
695a8d2065 Merge pull request #8407 from slavapestov/rename-everything-without-asking-permission
SIL: Terminology change: [fragile] => [serialized]
2017-03-29 20:08:15 -07:00
Erik Eckstein
43ddc2a643 AllocBoxToStack: Improve alloc_stack/dealloc_stack scoping
Instead of inserting all alloc_stack/dealloc_stack instructions at the begin/end of the function, insert them at the actual lifetime boundaries.

rdar://problem/16723128
2017-03-29 17:23:16 -07:00
Slava Pestov
8fe8b89b0f SIL: Terminology change: [fragile] => [serialized]
Also, add a third [serializable] state for functions whose bodies we
*can* serialize, but only do so if they're referenced from another
serialized function.

This will be used for bodies synthesized for imported definitions,
such as init(rawValue:), etc, and various thunks, but for now this
change is NFC.
2017-03-29 16:47:28 -07:00
Michael Gottesman
f301044384 [ownership-model] Teach the ownership model eliminator how to eliminate the default argument of a switch_enum and tighten up assertions in SILVerifier.
rdar://31145255
2017-03-27 16:25:37 -07:00
swift-ci
d12334301e Merge pull request #8236 from hughbe/clang-latest-error-fixes 2017-03-21 06:04:17 -07:00
Hugh Bellamy
d1849d7c28 Fix top of tree Clang compilation errors 2017-03-21 19:16:39 +07:00
Hugh Bellamy
d9879522fb Fix top of tree Clang unused lambda capture warnings 2017-03-21 19:15:08 +07:00
practicalswift
83526fe224 [gardening] Use .is<T>() instead of .getAs<T>() if the result is not needed 2017-03-20 22:54:01 +01:00
Erik Eckstein
d70bfc5de2 rename namespace NewMangling -> Mangle 2017-03-20 10:09:30 -07:00
Erik Eckstein
1625345b90 Remove the old mangler.
NFC
2017-03-17 16:10:36 -07:00
Erik Eckstein
d93167f326 No need to preserve BasicCalleeAnalysis from invalidation in FunctionSignatureOpts and GenericSpecializer anymore.
Because now the BasicCalleeAnalysis is not invalidated anyway by these optimizations.
It’s only invalidated by DeadFunctionElimination.
2017-03-14 13:00:55 -07:00
Erik Eckstein
a0079ba5be SIL optimizations: Implement the new API for analysis invalidation.
There are now separate functions for function addition and deletion instead of InvalidationKind::Function.
Also, there is a new function for witness/vtable invalidations.

rdar://problem/29311657
2017-03-14 13:00:54 -07:00
John McCall
3c5de5fa0a Preserve type canonicality better in several places and
idiomatize some uses of SILType::getSwiftRValueType().
2017-03-14 14:59:43 -04:00
Roman Levenstein
3738b00b6f Merge pull request #7973 from swiftix/wip-fso-fixes
[function-signature-opt] Allow FSO on witness_methods when performing  the dead argument signature optimization for partial_apply instructions
2017-03-09 23:18:57 -08:00