Commit Graph

23 Commits

Author SHA1 Message Date
Erik Eckstein
51e3e5ed80 Optimizer: rename BorrowArgumentsUpdater -> GuaranteedPhiUpdater
NFC
2024-11-12 09:26:59 +01:00
Erik Eckstein
6b8c6a3c3b SIL: rename updateBorrowedFrom to updateBorrowArguments
NFC
2024-11-12 09:26:58 +01:00
Erik Eckstein
656e6cd4bb SemanticARCOpts: update borrowed-from instructions when changes are made
Fixes a SIL verifier error

rdar://134728428
2024-08-27 13:28:40 +02:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Erik Eckstein
e14c1d1f62 SIL, Optimizer: update and handle borrowed-from instructions
Compute, update and handle borrowed-from instruction in various utilities and passes.
Also, used borrowed-from to simplify `gatherBorrowIntroducers` and `gatherEnclosingValues`.
Replace those utilities by `Value.getBorrowIntroducers` and `Value.getEnclosingValues`, which return a lazily computed Sequence of borrowed/enclosing values.
2024-04-10 13:38:10 +02:00
Nate Chandler
5f561ed596 [SAO] Add RedundantMoveValueElimination.
Adds to SemanticARCOpts a new step of removing move_value instructions
if they are redundant.  A move_value is redundant if it adds no new
information or optimization opportunities.

An example of adding information: a lifetime becoming lexical.  The new
lifetime's destroys cannot be hoisted over deinit barriers.

An example of adding an optimization opportunity: the original value
escapes but the value produced by the move_value does not escape.  So
destroys of the new value can be hoisted more aggressively.
2023-03-10 10:49:53 -08:00
Andrew Trick
b689b1dabe Rename GuaranteedARCOpts to MandatoryARCOpts.
This bleeds into the implementation where "guaranteed" is used
everywhere to talk about optimization of guaranteed values. We need to
use mandatory to indicate we're talking about the pass pipeline.
2021-03-02 22:20:13 -08:00
Michael Gottesman
4a71042d31 [ownership] Add a DeadEndBlocksAnalysis that vends/saves DeadEndBlocks in between passes.
Importantly this also lets us use the analysis framework to validate that we do
properly invalidate DeadEndBlocks, preventing bugs.

I did not thread this all over the compiler. Instead I just used it for now in
SemanticARCOpts just to add some coverage without threading it into too many
places.
2021-01-18 15:23:14 -08:00
Slava Pestov
e675bee26c AST: Split off DependencyCollector.h from EvaluatorDependencies.h
Also remove some unnecessary #includes from DependencyCollector.h,
which necessitated adding #includes in various other files.
2020-12-23 00:00:25 -05:00
Michael Gottesman
6bd4a8e384 [semantic-arc] Eliminate unneeded unchecked_ownership_conversion from owned/guaranteed -> unowned.
Specifically, we check that all of the unowned's value uses are within the
lifetime of the unchecked_ownership_conversion's operand. If so, we eliminate
it.
2020-12-09 11:29:36 -08:00
Michael Gottesman
56664088ec [semantic-arc] Expand out the infrastructure for disabling/enabling specific opts and use that to add new split up semantic-arc tests.
This split will ensure we are testing only what a specific optimization is doing
rather than all together.

NOTE: The way I split up the tests is I first split up each of the tests by
subject area by hand that I thought were specifically testing one pass. Then any
tests where the FileCheck tests started to fail due to us not running the other
passes, I put back a copy in the original semantic-arc-opts.sil to ensure we do
not regress.

Note, the tests that I copied for each of these passes
are originally from semantic-arc-opts.sil. I left them there as well so we could
see all of the opts together. I also only copied the ones that were testing pass
specific functionality.
2020-11-25 19:32:01 -08:00
Michael Gottesman
4a52f5afa3 [ownership] Add another run of SemanticARCOpts right before eliminating ARC on the stdlib functions.
This just canonicalizes the ARC before we lower OME in the face of ARC twiddles
by other passes.
2020-10-23 13:57:50 -07:00
Michael Gottesman
58508783b0 [semantic-arc] Add the ability to at the command line run a subset of semantic-arc optimizations.
SemanticARCOpts for maintainance reasons is becoming a series of small
optimization passes with a little pass manager that runs them. Given that, I
want to be able to be able to run subsets of these transforms for testing
reasons while normally running them in series.

This is in preparation for landing the coroutine lifetime extender and the
auto-coroutinizer.
2020-09-17 00:18:27 -05:00
Michael Gottesman
fa8c9d055a [semantic-arc] Move main optimize loop of SemanticARCOptVisitor into its own file. 2020-09-17 00:18:27 -05:00
Michael Gottesman
8d898e5180 [semantic-arc] Extract owned phi to guaranteed phi conversion from the visitor to its own function that works on the SemanticARCContext. 2020-09-17 00:18:26 -05:00
Michael Gottesman
915ccc0854 [semantic-arc] Extract out from the main visitor a context object for individual sub optimizations.
This patch moves state from the main SemanticARCOptVisitor struct to instead be
on a context object. Sub-transformations should not need to know about the
visitor since how it processes things is orthogonal from the transformations
themselves.
2020-09-16 19:11:07 -05:00
Michael Gottesman
04da864090 [semantic-arc] Split out owned -> guaranteed phi opt into its own file. 2020-09-01 12:25:46 -07:00
Michael Gottesman
d26f336b0b [semantic-arc] Split out copy_value optimizations (except phi elimination) into its own file. 2020-08-31 17:57:02 -07:00
Michael Gottesman
7c12c7f466 [semantic-arc] Extract out borrow scope optimizations into its own file. 2020-08-31 14:12:23 -07:00
Michael Gottesman
ba6dc1724b [semantic-arc] Split load [copy] -> load_borrow opt into its own file. 2020-08-31 10:07:59 -07:00
Michael Gottesman
96feb2dedd [ownership] Extract out the main visitor SemanticARCOptVisitor from SemanticARCOpts.h into its own header.
This is so I can move individual sub-optimizations on SemanticARCOptVisitor into
their own files. So for instance, there will be one file containing the load
[copy] optimization and another containing the phi optimization, etc.
2020-08-30 01:05:53 -07:00
Michael Gottesman
364b7c742c [ownership] Refactor OwnershipLiveRange and OwnershipPhiOperand into separate files from SemanticARCOpts.cpp 2020-08-29 21:39:34 -07:00
Michael Gottesman
1132cda811 [ownership] Move SemanticARCOpts into a separate folder in preparation for splitting into multiple small pseudo-passes.
SemanticARCOpts keeps on growing with various optimizations attached to a single
"optimization" manager. Move it to its own folder in prepation for splitting it
into multiple different optimizations and utility files.
2020-08-27 23:58:14 -07:00