The old invalidation lattice was incorrect because changes to control flow could cause changes to the
call graph, so we've decided to change the way passes invalidate analysis. In the new scheme, the lattice
is replaced with a list of traits that passes preserve or invalidate. The current traits are Calls and Branches.
Now, passes report which traits they preserve, which is the opposite of the previous implementation where
passes needed to report what they invalidate.
Node: I tried to limit the changes in this commit to mechanical changes to ease the review. I will cleanup some
of the code in a following commit.
Swift SVN r26449
Make the SILCombine logic aware of memory behavior.
This fixes performance issues exposed by copy forwarding.
By itself, there is one confirmed speedup:
StdlibSort +12.3%
Swift SVN r23607
This will hopefully make it clearer as we onboard people that
SimplifyInstruction should not add instructions to the IR by making it clearer
that it is an analysis, not a pass.
Swift SVN r21752
This reverts commit r21480. There are other parts of the compiler which pattern
match on retain_value, release_value but don't strip off RC identity preserving
ops. Since the values no longer naively match up, the optimizations fail.
Swift SVN r21503
This is always good to do since it makes it clearer what the ARC optimizer is
doing. I have not decided how I want to strip off arguments from strong_retain,
strong_release since I may necessarily convert the strong_{retain,release} back
to a {retain,release}_value.
Swift SVN r21480
Previously we were attempting to look for a store before the switch_enum_addr
and were performing some sort of simplistic store forwarding. This is
unnecessary and causes us to miss potential opportunities to promote
switch_enum_addr of loadable types.
With this patch we always promote switch_enum_addr of loadable types to a load +
switch_enum. This ensures we canonicalize all switch_enum_addr of loadable types
to switch_enum and leaves the load-store forwarding issue to mem2reg and load
store forwarding.
Swift SVN r21479
Really we want to only cast between equally sized types. SIL does not really
have a concept of types of the same size so this solution is a workaround
(temporary) for acutal code in the standard library which casts a pointer of an
UTF16 type to a pointer of an UTF8 type.
rdar://18118602
Swift SVN r21470
Replace the true/maybe state that Builtin.canBeClass was returning by a
tri-state (yes, no, maybe) allowing the optimizer to use the definite no
answer. This removes the need of the sizeof check that we had in
isClassOrObjCExistential. It also removes the need to CSE this function since
in most cases we will be able to instantiate canBeClass to yes or no (vs maybe)
at compile time.
benchmark``````````````,``baserun0``,``optrun2``,``delta,``speedup
ClassArrayGetter```````,``988.00````,``337.00```,``644.00``,````````191.7%
DeltaBlue``````````````,``2429.00```,``1927.00``,``460.00``,````````23.9%
Dictionary`````````````,``1374.00```,``1231.00``,``129.00``,````````10.9%
Havlak`````````````````,``1079.00```,``911.00```,``124.00``,````````13.7%
Rectangles`````````````,``924.00````,``541.00```,``379.00``,````````70.1%
radar://16823238
Swift SVN r21331
We currently only sink retains to successor BBs.
However, if a retain can't be moved to a successor, we may still want to move it as late in the current BB as
possible. For example, we want retains after called to _swift_isUniquelyReferenced and not before it.
Here are performance numbers for -O. Note that i'm about to commit improvements to enum_is_tag which fixes the
regressions here.
Ackermann``````,``````````1413.00```,`````````````````1566.00```,``````````153.00``,`````````````````-9.8%
ArrayLiteral```,``````````834.00````,`````````````````859.00````,``````````25.00```,`````````````````-2.9%
Ary````````````,``````````1110.00```,`````````````````1121.00```,``````````11.00```,`````````````````-1.0%
Ary2```````````,``````````1092.00```,`````````````````1105.00```,``````````13.00```,`````````````````-1.2%
Ary3```````````,``````````1164.00```,`````````````````1193.00```,``````````29.00```,`````````````````-2.4%
DeltaBlue``````,``````````2195.00```,`````````````````2204.00```,``````````9.00````,`````````````````-0.4%
Dictionary`````,``````````502.00````,`````````````````512.00````,``````````10.00```,`````````````````-2.0%
Dictionary2````,``````````884.00````,`````````````````895.00````,``````````11.00```,`````````````````-1.2%
Dictionary3````,``````````859.00````,`````````````````870.00````,``````````11.00```,`````````````````-1.3%
EditDistance```,``````````1344.00```,`````````````````1344.00```,``````````0.00````,`````````````````0.0%
Fibonacci``````,``````````1382.00```,`````````````````1309.00```,``````````73.00```,`````````````````5.6%
ForLoops```````,``````````1318.00```,`````````````````1324.00```,``````````6.00````,`````````````````-0.5%
Forest`````````,``````````757.00````,`````````````````775.00````,``````````18.00```,`````````````````-2.3%
GlobalClass````,``````````1617.00```,`````````````````1620.00```,``````````3.00````,`````````````````-0.2%
Hash```````````,``````````660.00````,`````````````````718.00````,``````````58.00```,`````````````````-8.1%
HeapSort```````,``````````1256.00```,`````````````````1292.00```,``````````36.00```,`````````````````-2.8%
Histogram``````,``````````313.00````,`````````````````296.00````,``````````17.00```,`````````````````5.7%
InsertionSort``,``````````1223.00```,`````````````````1351.00```,``````````128.00``,`````````````````-9.5%
Life```````````,``````````69.00`````,`````````````````70.00`````,``````````1.00````,`````````````````-1.4%
LinkedList`````,``````````1516.00```,`````````````````1529.00```,``````````13.00```,`````````````````-0.9%
MatMul`````````,``````````224.00````,`````````````````239.00````,``````````15.00```,`````````````````-6.3%
Memset`````````,``````````43.00`````,`````````````````43.00`````,``````````0.00````,`````````````````0.0%
MonteCarloE````,``````````905.00````,`````````````````900.00````,``````````5.00````,`````````````````0.6%
MonteCarloPi```,``````````643.00````,`````````````````654.00````,``````````11.00```,`````````````````-1.7%
NBody``````````,``````````42.00`````,`````````````````41.00`````,``````````1.00````,`````````````````2.4%
NestedLoop`````,``````````931.00````,`````````````````876.00````,``````````55.00```,`````````````````6.3%
NopDeinit``````,``````````1119.00```,`````````````````1117.00```,``````````2.00````,`````````````````0.2%
Phonebook``````,``````````1424.00```,`````````````````1395.00```,``````````29.00```,`````````````````2.1%
PrimeNum```````,``````````214.00````,`````````````````219.00````,``````````5.00````,`````````````````-2.3%
Prims``````````,``````````1182.00```,`````````````````1198.00```,``````````16.00```,`````````````````-1.3%
QuickSort``````,``````````1196.00```,`````````````````1166.00```,``````````30.00```,`````````````````2.6%
R17315246``````,``````````798.00````,`````````````````798.00````,``````````0.00````,`````````````````0.0%
RC4````````````,``````````25.00`````,`````````````````25.00`````,``````````0.00````,`````````````````0.0%
RIPEMD`````````,``````````724.00````,`````````````````746.00````,``````````22.00```,`````````````````-2.9%
Random`````````,``````````960.00````,`````````````````963.00````,``````````3.00````,`````````````````-0.3%
Rectangles`````,``````````836.00````,`````````````````849.00````,``````````13.00```,`````````````````-1.5%
Richards```````,``````````220.00````,`````````````````225.00````,``````````5.00````,`````````````````-2.2%
SelectionSort``,``````````931.00````,`````````````````932.00````,``````````1.00````,`````````````````-0.1%
SmallPT````````,``````````1014.00```,`````````````````1039.00```,``````````25.00```,`````````````````-2.4%
StdlibSort`````,``````````1617.00```,`````````````````1602.00```,``````````15.00```,`````````````````0.9%
StrCat`````````,``````````1061.00```,`````````````````1121.00```,``````````60.00```,`````````````````-5.4%
StrSplitter````,``````````1607.00```,`````````````````1533.00```,``````````74.00```,`````````````````4.8%
StrToInt```````,``````````616.00````,`````````````````612.00````,``````````4.00````,`````````````````0.7%
StringBuilder``,``````````701.00````,`````````````````682.00````,``````````19.00```,`````````````````2.8%
StringWalk`````,``````````1165.00```,`````````````````1182.00```,``````````17.00```,`````````````````-1.4%
Totals`````````,``````````42392.00``,`````````````````42778.00``,``````````386.00``,`````````````````-0.9%
TwoSum`````````,``````````581.00````,`````````````````564.00````,``````````17.00```,`````````````````3.0%
Walsh``````````,``````````105.00````,`````````````````104.00````,``````````1.00````,`````````````````1.0%
Swift SVN r21133
Expose Substitution's archetype, replacement, and conformances only through getters so we can actually assert invariants about them. To start, require replacement types to be materializable in order to catch cases where the type-checker tries to bind type variables to lvalue or inout types, and require the conformance array to match the number of protocol conformances required by the archetype. This exposes some latent bugs in the test suite I've marked as failures for now:
- test/Constraints/overload.swift was quietly suffering from <rdar://problem/17507421>, but we didn't notice because we never tried to codegen it.
- test/SIL/Parser/array_roundtrip.swift doesn't correctly roundtrip substitutions, which I filed as <rdar://problem/17781140>.
Swift SVN r20418
additional instructions. This helps to remove a comparison of
a pointer to zero inside the Array implementation.
This patch improves both NBody and SmallPt by about 30%.
Swift SVN r19878
This commit enables support in the optimizer for promoting the following
unchecked_addr_cast kinds to object bit casts:
1. (Trivial => Trivial) yields a trivial bit cast.
2. (Non-Trivial => Trivial) yields a trivial bit cast.
3. (Non-Trivial => Non-Trivial) yields a ref bit cast.
We do not promote conversions in between trivial and non-trivial types
since a trivial bit cast must have a trivial output and if we allowed
for ref bit casts in between the two, we would be breaking the rule that
ref bit casts do not change the reference semantics of its input, output
types. Technically, we could lower trivial => trivial as a ref cast and
then simplify later but that is unnecessary currently.
<rdar://problem/17373087>
Swift SVN r19784
Fixes <rdar://problem/17579272> SILCombine assert: ty->isLegalSILType() constructing SILType with type that should have been eliminated by SIL lowering.
Fix suggested by MikeG.
Swift SVN r19701
For example, we want to remove this code:
@semantics("pure") func pure_func() -> Foo {
return Foo()
}
func baz() {
let unused = pure_func() // Remove this code.
}
Swift SVN r19656
In a few places we were calling into a function that just returned
T->hasArchetype(). This just changes those places to test it directly.
Swift SVN r19427
This is tested by an assertion in IRGen. After Beta3, this code is going
to go away and be replaced by just always promoting the cast. Then the
IRGen assertion will be replaced by propagating undef. The assertion in
the stdlib will still fire in that case since the assertion is based on
the tops not the given value implying that we will not lose any
correctness.
Swift SVN r19272
A first element field of a nominal type is either the first element of a
struct or the first payload of an enum. We currently allow the stdlib to
rappel into struct heirarchies using reinterpretCast. This patch teaches
the optimizer how to rewrite such unchecked_addr_cast into
unchecked_enum_data_addr and struct_element_addr instructions. Then
Mem2Reg and Load Store Forwarding will remove the allocation generated
by such uses of reinterpret cast.
<rdar://problem/16703656>
Swift SVN r18977