Use existing machinery of the generic specializer to produce generic specializations of closures referenced by partial_apply instructions. Thanks to the newly introduced ApplyInstBase class, the required changes in the generic specializer are very minimal.
rdar://19290942
Swift SVN r26582
We no longer need or use it since we can always refer to the same bit on
the applied function when deciding whether to inline during mandatory
inlining.
Resolves rdar://problem/19478366.
Swift SVN r26534
When creating a new apply, we were copying the transparent bit from the
old apply, as well as the referenced function from the old apply. We
should just use the transparent bit from that referenced function.
Swift SVN r26384
Transforms :
%1 = alloc_ref $B
checked_cast_br [exact] %1 : $B to $B, bb1, bb2
into
br bb1(%1 : $B)
In case when source and destination types do no match, replace by a branch to the failure bb of the checked_cast_br.
Swift SVN r26275
TerminatorInsts. Now you can walk over the successor list of a terminator
and actually modify the SILSuccessor directly, allowing better CFG
transformations. NFC.
Swift SVN r26140
This is mostly a re-factoring. It creates a new helper class CastOptimizer which contains all the logic for performing type casts optimizations. This logic is a copy of the current logic from sil-combine and simplify-cfg. Those passes will become clients of this new helper class.
Swift SVN r26122
This enables high-level SIL optimizations to speculatively specialize loops into
'fast native swift array' loops vs standard array loops.
This commits adds two semantic calls to Arrays.swift.
@semantics("array.props.isNative")
func _getArrayPropertyIsNative() -> Bool
@semantics("array.props.needsElementTypeCheck")
func _getArrayPropertyNeedsElementTypeCheck() -> Bool
checkSubscript and getElement get extra arguments to pass in the result of above
function calls. This also allow us to communicate that an array that was made
mutable is always native. The array subscript getter is changed to use the
result of these new calls:
public subscript(index: Int) -> Element {
get {
let isNative = _getArrayPropertyIsNative()
let needsTypeCheck = _getArrayPropertyNeedsElementTypeCheck()
_checkSubscript(index, isNative)
return _getElement(index, isNative, needsTypeCheck)
}
mutableAddressWithPinnedNativeOwner {
_makeMutableAndUniqueOrPinned()
// When an array was made mutable we know it is a backed by a native
// array buffer.
_checkSubscript(index, true)
return (_getElementAddress(index),
Builtin.tryPin(Builtin.castToNativeObject(_buffer.owner)))
}
}
High-level SIL optimizations will now see a loop like this:
func f(inout a : A[AClass]) {
for i in 0..a.count {
let b = a.props.isNative()
.. += _getElement(a, i, b)
}
}
After proving that ‘a’ does not escape other than to known safe functions, the
optimizer hoists the array property calls out of the loop in a loop versioned
on the array property.
func f(inout a : A[AClass]) {
let b2 = a.props.isNative()
if (!b2) {
for i in 0..a.count {
.. += _getElement(a, i, false)
}
} else {
for i in 0..a.count {
let b = a.props.isNative
.. += _getElement(a, i, b)
}
}
}
rdar://17955309
Swift SVN r25698
In every instance, we were just creating the StringConcatenationOptimizer and
then invoking optimize on it. This is a cleaner solution since the details of
how we perform the string concatenation are hidden in Local.cpp instead of being
in a header.
NFC.
Swift SVN r25341
This refactors some code out of AllocBoxToStack that computes the
lifetime of a value in the strictess sense, limiting the lifetime to
that value and not anything derived from that value (whether by casting,
projection, etc.).
In the short term this will be used to fix a very rarely hit
optimization in AllocBoxToStack.
Longer term I will replace the other similar code in AllocBoxToStack to
use this instead.
Swift SVN r25176
This utility attempts to delete dead closures with a set of
post-dominating releases using the infrastructure from
getFinalReleasesForValue.
It currently only will eliminate closures that only have retain, release
uses and a final post-dominating release set.
The reason why we need the final post-dominating release set is so that
we can release any captured variables at the points where we would have
deallocated the release. This is b/c captured variables are passed in at
+1 to partial apply.
Swift SVN r25050
Array.init does not have a self argument (it returns the newly created array
@owned). Passes using the ArraySemantic::getSelf() interface must handle it
specially.
rdar://19724033
Swift SVN r25013
Till now, -debug-values-propagate-liveness was only taken into account if the compiler was built with assertions. This led to some problems with bots, which were testing both assertions-enabled and assertions-disables versions of the compiler. It was agreed that we want this experimental flag to be always taken into account when it is provided on the command-line. The default value of this flag is "disabled".
rdar://19674999
Swift SVN r24977
We can not remove unused global initializer function calls. They might have
side-effects.
I measured no regressions at -O.
rdar://19464274
Swift SVN r24513
1. Eliminate unused variable warnings.
2. Change field names to match capitalization of the rest of the field names in the file.
3. Change method names to match rest of the file.
4. Change get,set method for a field to match the field type.
Swift SVN r24501
In order to not completely loose testcoverage while rdar://problem/18709125
is under investiagtion, add a special flag for enabling debug value
liveness.
Patch by Michael Gottesman!
<rdar://problem/19267059>
Swift SVN r24416
It had exposed a problem with the MemBehavior on a couple SIL
instructions which resulted in code motion moving a retain across an
instruction that can release (fixed in r23722).
From the original commit message:
Remove restriction on substituting existentials during mandatory inlining.
Issues around this have now been resolved, so we should now support
anything that Sema lets through.
Fixes rdar://problem/17769717.
Swift SVN r23729
"array.props.isCocoa/needsElementTypeCheck" semantic calls will mark calls that
return array properties: isCocoa and needsElementTypeCheck. We know that said
states can only transfer in certain directions (a native swift array that does
not need an element type check stays in this state) enabling us to version loops
based on the state of said array array properties.
rdar://17955309
Swift SVN r23688
without a valid SILDebugScope. An assertion in IRGenSIL prevents future
optimizations from regressing in this regard.
Introducing SILBuilderWithScope and SILBuilderwithPostprocess to ease the
transition.
This patch is large, but mostly mechanical.
<rdar://problem/18494573> Swift: Debugger is not stopping at the set breakpoint
Swift SVN r22978
I also extracted out an additional method clearBlockBody() from the body
of removeDeadBlocks() since I need that functionality exposed in
Function Signature Opts.
Swift SVN r22560
Now the SILLinkage for functions and global variables is according to the swift visibility (private, internal or public).
In addition, the fact whether a function or global variable is considered as fragile, is kept in a separate flag at SIL level.
Previously the linkage was used for this (e.g. no inlining of less visible functions to more visible functions). But it had no effect,
because everything was public anyway.
For now this isFragile-flag is set for public transparent functions and for everything if a module is compiled with -sil-serialize-all,
i.e. for the stdlib.
For details see <rdar://problem/18201785> Set SILLinkage correctly and better handling of fragile functions.
The benefits of this change are:
*) Enable to eliminate unused private and internal functions
*) It should be possible now to use private in the stdlib
*) The symbol linkage is as one would expect (previously almost all symbols were public).
More details:
Specializations from fragile functions (e.g. from the stdlib) now get linkonce_odr,default
linkage instead of linkonce_odr,hidden, i.e. they have public visibility.
The reason is: if such a function is called from another fragile function (in the same module),
then it has to be visible from a third module, in case the fragile caller is inlined but not
the specialized function.
I had to update lots of test files, because many CHECK-LABEL lines include the linkage, which has changed.
The -sil-serialize-all option is now handled at SILGen and not at the Serializer.
This means that test files in sil format which are compiled with -sil-serialize-all
must have the [fragile] attribute set for all functions and globals.
The -disable-access-control option doesn't help anymore if the accessed module is not compiled
with -sil-serialize-all, because the linker will complain about unresolved symbols.
A final note: I tried to consider all the implications of this change, but it's not a low-risk change.
If you have any comments, please let me know.
Swift SVN r22215
This encapsulates common operations on array semantic calls like identifying
them or hoisting/copying them.
Will be used by follow-up commits. NFC.
Swift SVN r21926
This looks for @effects(readnone) on functions. A follow up commit will mark
_swift_isClassOrObjCExistential as readnone allowing us to CSE it.
rdar://17961249
Swift SVN r21285