Commit Graph

13 Commits

Author SHA1 Message Date
Erik Eckstein
b8026d74e6 Revert "Revert "Optimizer: improve the load-copy-to-borrow optimization and implement it in swift""
This reverts commit 0666c446ec.
2024-10-22 08:40:18 +02:00
Erik Eckstein
0666c446ec Revert "Optimizer: improve the load-copy-to-borrow optimization and implement it in swift"
This reverts commit eed8645610.
2024-10-18 10:36:06 +02:00
Erik Eckstein
eed8645610 Optimizer: improve the load-copy-to-borrow optimization and implement it in swift
The optimization replaces a `load [copy]` with a `load_borrow` if possible.

```
  %1 = load [copy] %0
  // no writes to %0
  destroy_value %1
```
->
```
  %1 = load_borrow %0
  // no writes to %0
  end_borrow %1
```

The new implementation uses alias-analysis (instead of a simple def-use walk), which is much more powerful.

rdar://115315849
2024-10-11 09:41:37 +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
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
fa8c9d055a [semantic-arc] Move main optimize loop of SemanticARCOptVisitor into its own file. 2020-09-17 00:18:27 -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
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