Make the devirtualization functions take the actual type we're
devirtualizing (or speculatively devirutalizing) to, in order to
simplify the handling of metatypes. Remove the ClassDecl parameter from
these functions since it can always be derived from this type.
These changes set things up for more forthcoming improvements to
metatype handling.
As part of this I've simplified the function that determines if a member
is known to be 'final'. My expectation is that this can be further
simplified by removing the type parameter as part of other improvements
to metatype handling.
Swift SVN r26165
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
It turns out we're already at a point where we can easily pass the same
data along to the devirtualization functions, and were already passing
some of it.
Swift SVN r26040
Redefine DevirtClassMethodInfo to carry fewer values in an effort to
reduce the coupling between these functions. Long term I expect this
structure to go away, but that is difficult to do without more
refactoring.
Swift SVN r26034
SIL cloning is not always followed by sil-combine, which could do the clean-up. Therefore, take care of removing the dead code after "unreachable" instructions at the end of the cloning process.
Swift SVN r26029
In the case of a crash in the optimizer or verifier, this prints out information
about the source of the crash. This saves engineering time by allowing one to
get some quick information about the crash without needing to jump into the
buffer.
In the case of a SILFunctionTransform, this prints out the name of the function
being optimized and the name of the transform.
In the case of a SILModuleTransform, this prints out the name of the transform.
<rdar://problem/19946491>
Swift SVN r25831
No functional change here, and this is not in its final form. This is
just cut/paste/tweak to split the code apart in a first reasonable form.
Swift SVN r25769
Currently no passes implement this, but I am going to add support to the
callgraph. I just ran into a callgraph bug that this would have helped
to catch.
rdar://19930214
Swift SVN r25514
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
Rename LateDeadFunctionElimination into ExternalFunctionDefinitionsElimination.
Move ExternalFunctionDefinitionsElimination out of DeadFunctionElimination and make it a separate pass.
Move a common logic shared by DeadFunctionElimination and ExternalFunctionDefinitionsElimination into a newly created base class.
Make ExternalFunctionDefinitionsElimination pass eliminate just those external functions which are only reachable via vtables and witness_tables, but leave directly reachable function definitions in place. This gives LLVM more chances to analyze directly reachable functions for side-effects and perform better optimizations based on this. Once we have a proper IPO support for Swift, we can eliminate all external function definitions, including directly reachable ones, as there will be other ways to get information about their side-effects.
Swift SVN r24546
This pass removes pin/unpin pairs that are not interleaved by a may-release of
the pin's operand.
This will be needed when we turn on John's work on safe array accessors.
Swift SVN r24434
This pass is an extension of the dead function elimination, which additionally performs removal of external function definitions (i.e. function bodies) for a sake of improving the compile times by reducing the amount of code running through IRGen. It is safe, because such functions are defined elsewhere and where required only for analysis and optimization purposes.
This pass is supposed to run very late in the pipeline, after any passes that may need to look at the function bodies, i.e. after devirtualization, inlining and all specialization passes.
Swift SVN r24417
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
This flag enables one to specify a json file that expresses a specific
pipeline in the following format:
[
[
"$PASS_MANAGER_ID",
"run_n_times"|"run_to_fixed_point",
$NUM_ITERATIONS,
"$PASS1", "$PASS2", ...
],
...
]
This will make it easier to experiment with different pass pipelines by
allowing:
1. Automatic generation of pass pipelines without needing to recompile
the compiler itself.
2. Simple scripting of pass pipelines via the json meta language.
3. Enabling the easy expression and reproducability of a specific
pipeline ordering via radar.
In the next commit I will provide a python library for the generation of these
json files with a few types of pipeline generators already created.
Swift SVN r24055
I refactored, generalized, and cleaned up an existing helper.
I also removed hard-coded assumptions about successor indices.
There's no point giving CondBranch a true/false API if we don't respect it.
Swift SVN r24001
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