mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Teach the derived init class 'self' analyzer to look at the refcount result of the
self box as well as the address result, so that it picks up retains and releases. Classify releases as interesting usepoints, and ignore the dealloc_stack. Similarly, teach the logic in DefiniteInit's conditional destruction stuff to handle the derived self case (basically, teaching it to special case the self box). Swift SVN r21622
This commit is contained in:
@@ -817,7 +817,7 @@ void ElementUseCollector::collectClassSelfUses() {
|
||||
// 4) Potential escapes after super.init, if self is closed over.
|
||||
// Handle each of these in turn.
|
||||
//
|
||||
for (auto UI : SelfBox.getUses()) {
|
||||
for (auto UI : SelfBox.getDef()->getUses()) {
|
||||
SILInstruction *User = UI->getUser();
|
||||
|
||||
// Ignore the initialization store.
|
||||
@@ -829,8 +829,16 @@ void ElementUseCollector::collectClassSelfUses() {
|
||||
continue;
|
||||
}
|
||||
|
||||
// destroyaddr on the box is load+release, which is ignored.
|
||||
if (isa<DestroyAddrInst>(User)) continue;
|
||||
// destroyaddr on the box is load+release, which is treated as a release.
|
||||
if (isa<DestroyAddrInst>(User) || isa<StrongReleaseInst>(User)) {
|
||||
Releases.push_back(User);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore the deallocation of the stack box. Its contents will be
|
||||
// uninitialized by the point it executes.
|
||||
if (isa<DeallocStackInst>(User))
|
||||
continue;
|
||||
|
||||
// We can safely handle anything else as an escape. They should all happen
|
||||
// after super.init is invoked. As such, all elements must be initialized
|
||||
|
||||
Reference in New Issue
Block a user