Commit Graph

14 Commits

Author SHA1 Message Date
Meghana Gupta
ad170b6758 Update test lexical-lifetimes.swift 2024-01-08 22:22:08 -08:00
Nate Chandler
979196cb16 [Test] For disabling destroy hoisting. 2022-03-17 12:06:53 -07:00
Nate Chandler
f79f26f6ea [Test] Reenabled test.
Added flag to disable destroy hoisting to run line.  Destroy hoisting
will be disabled separately.

rdar://86271875
2022-02-21 08:05:48 -08:00
Nate Chandler
1d939d4201 [Test] Run in right contexts.
The validation-test/SILOptimizer/lexical-lifetimes.swift test uses
concurrency features.  Specified where that means the test can run
appropriately.
2022-01-14 18:31:33 -08:00
Nate Chandler
9b021c9ba7 [Test] Eased check assertion. 2022-01-12 13:15:57 -08:00
Nate Chandler
cb205a6ec0 [Test] Checked variable lifetimes not extend weak.
Verified that lexical lifetimes DO NOT result in a method call to a weak
reference resulting in a strong reference to the object.  Consequently,
even with lexical lifetimes enabled, it is still possible, within a
single scope, for the first method call to an object weakly referenced
to occur but for the second such call not to because the object will
have been deallocated.
2022-01-05 13:00:35 -08:00
Nate Chandler
f48f3ad228 [Test] Checked variable lifetimes extend self.
Verified that when a __consuming method calls a function which takes a
closure that captures self weakly, self is not deallocated until the
call returns.  (Note that this is a behavioral change from what occurs
when lexical borrow scopes are disabled; in that case, self is
deallocated before the call to the function.)
2022-01-05 12:12:01 -08:00
swift-ci
6a752615d6 Merge pull request #40477 from nate-chandler/lexical-lifetimes/reenable-destroy-hoisting 2021-12-09 15:42:02 -08:00
Nate Chandler
59f3b37c35 [SIL] Reenable destroy hoisting under lexical lifetimes.
Until https://github.com/apple/swift/pull/40392 lands, run destroy
hoisting with lexical lifetimes.
2021-12-09 10:42:36 -08:00
Nate Chandler
ea42e2f334 Enabling copy propagation enables lexical lifetimes.
The effect of passing -enable-copy-propagation is both to enable the
CopyPropagation pass to shorten object lifetimes and also to enable
lexical lifetimes to ensure that object lifetimes aren't shortened while
a variable is still in scope and used.

Add a new flag, -enable-lexical-borrow-scopes=true to override
-enable-copy-propagation's effect (setting it to ::ExperimentalLate) on
SILOptions::LexicalLifetimes that sets it to ::Early even in the face of
-enable-copy-propagation.  The old flag -disable-lexical-lifetimes is
renamed to -enable-lexical-borrow-scopes=false but continues to set that
option to ::Off even when -enable-copy-propagation is passed.
2021-12-08 19:13:21 -08:00
Nate Chandler
2356b07427 [Test] Add two lexical lifetime verification tests.
Verify that lexical-lifetimes and copy-propagation interact correctly to
keep objects named by variables alive in a couple interesting cases:
unsafe pointers, synchronization point calls.
2021-12-07 16:29:17 -08:00
Nate Chandler
1961be8845 Renamed flag to -enable-lexical-lifetimes.
Previously, both swift-frontend and sil-opt put lexical lifetimes behind
a flag named -enable-experimental-lexical-lifetimes.  That's redundant.
Here, the experimental portion of the name is dropped.
2021-12-03 17:40:37 -08:00
Nate Chandler
d9b32f243c [Test] Fixed run line for lexical-lifetimes.swift.
rdar://84984903
2021-11-03 16:48:48 -07: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