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:
Chris Lattner
2014-09-01 05:19:25 +00:00
parent f154cb1961
commit ffdba8fd36
3 changed files with 66 additions and 6 deletions

View File

@@ -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