mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Turn on +0 self by default.
The only caveat is that: 1. We do not properly recognize when we have a let binding and we perform a guaranteed dynamic call. In such a case, we add an extra retain, release pair around the call. In order to get that case I will need to refactor some code in Callee. I want to make this change, but not at the expense of getting the rest of this work in. 2. Some of the protocol witness thunks generated have unnecessary retains or releases in a similar manner. But this is a good first step. I am going to send a large follow up email with all of the relevant results, so I can let the bots chew on this a little bit. rdar://19933044 Swift SVN r27241
This commit is contained in:
@@ -1053,10 +1053,15 @@ void LifetimeChecker::handleLoadUseFailure(const DIMemoryUse &Use,
|
||||
}
|
||||
}
|
||||
|
||||
// If the upcast is used by a class_method + apply, then this is a call of
|
||||
// a superclass method or property accessor.
|
||||
// If the upcast is used by a class_method + apply, then this is a call of a
|
||||
// superclass method or property accessor. If we have a guaranteed method,
|
||||
// we will have a release due to a missing optimization in SILGen that will
|
||||
// be removed.
|
||||
//
|
||||
// TODO: Implement the SILGen fixes so this can be removed.
|
||||
ClassMethodInst *CMI = nullptr;
|
||||
ApplyInst *AI = nullptr;
|
||||
SILInstruction *Release = nullptr;
|
||||
for (auto UI : SILValue(UCI, 0).getUses()) {
|
||||
auto *User = UI->getUser();
|
||||
if (auto *TAI = dyn_cast<ApplyInst>(User)) {
|
||||
@@ -1072,12 +1077,27 @@ void LifetimeChecker::handleLoadUseFailure(const DIMemoryUse &Use,
|
||||
}
|
||||
}
|
||||
|
||||
if (isa<ReleaseValueInst>(User) || isa<StrongReleaseInst>(User)) {
|
||||
if (!Release) {
|
||||
Release = User;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Not a pattern we recognize, conservatively generate a generic
|
||||
// diagnostic.
|
||||
CMI = nullptr;
|
||||
break;
|
||||
}
|
||||
|
||||
// If we have a release, make sure that AI is guaranteed. If it is not, emit
|
||||
// the generic error that we would emit before.
|
||||
//
|
||||
// That is the only case where we support pattern matching a release.
|
||||
if (Release &&
|
||||
!AI->getSubstCalleeType()->getExtInfo().hasGuaranteedSelfParam())
|
||||
CMI = nullptr;
|
||||
|
||||
if (AI && CMI) {
|
||||
// TODO: Could handle many other members more specifically.
|
||||
auto *Decl = CMI->getMember().getDecl();
|
||||
|
||||
Reference in New Issue
Block a user