Commit Graph

10 Commits

Author SHA1 Message Date
Michael Gottesman
1e6187c4f4 [sil] Update all usages of old API SILValue::getOwnershipKind() in favor of new ValueBase::getOwnershipKind().
Andy some time ago already created the new API but didn't go through and update
the old occurences. I did that in this PR and then deprecated the old API. The
tree is clean, so I could just remove it, but I decided to be nicer to
downstream people by deprecating it first.
2022-07-26 11:46:23 -07:00
Nate Chandler
f0bd5839a2 [OwnershipUtils] Extracted utility for common use.
Promoted isRedundantLexicalBeginBorrow function to OwnershipUtils so
that it can be used in more than just SemanticARCOpts.
2021-12-07 17:51:18 -08:00
Nate Chandler
75b351eda0 [Gardening] Updated comment. 2021-12-07 17:04:49 -08:00
Nate Chandler
5e8f369d06 [Gardening] Merged two conditions. 2021-12-07 17:04:49 -08:00
Nate Chandler
bfd78d669b [SemanticARCOpts] Strip some lexical borrow scopes.
If a value's lifetime is preserved by a different lexical scope, it is
fine to strip a different scope.  Specifically, if it is preserved by
being a guaranteed argument or a nested borrow of an outer lexical
scope, allow a lexical borrow scope to be stripped.
2021-12-07 09:43:58 -08:00
Nate Chandler
3bb1766a5f [SILOptimizer] Keep lexical lifetime markers.
Previously, TempRValueElimination would peephole simple alloc_stacks,
even when they were lexical; here, they are left for Mem2Reg to properly
handle.

Previously, SemanticARCOpts would eliminate lexical begin_borrows,
incorrectly allowing the lifetime of the value borrowed by them to be
observably shortened.  Here, those borrow scopes are not eliminated if
they are lexical.

Added an executable test that verifies that a local variable strongly
referencing a delegate object keeps that delegate alive through the call
to an object that weakly references the delegate and calls out to it.
2021-10-22 15:00:23 -07: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
a294ab61ad [ownership] Eliminate OperandOwnershipKindMap in favor of OwnershipConstraint.
I also used this as a moment to clarify the lattice that related
ValueOwnershipKind and OwnershipConstraint.
2020-11-10 19:07:30 -08:00
Michael Gottesman
642a993702 [ownership] Rename Operand::isConsumingUse() -> Operand::isLifetimeEnding().
This makes it clearer that isConsumingUse() is not an owned oriented API and
returns also for instructions that end the lifetime of guaranteed values like
end_borrow.
2020-11-08 13:23:17 -08:00
Michael Gottesman
7c12c7f466 [semantic-arc] Extract out borrow scope optimizations into its own file. 2020-08-31 14:12:23 -07:00