Skip to content

Commit 4ec86f2

Browse files
committed
[DI] InitAccessor: Ignore a load of "self" introduced by a partial apply of a setter
`nonmutating set` needs to load of "self" but that load could be ignored safely because it's only viable when self is determined to be fully initialized by DI. The same applies to `assign_by_wrapper`.
1 parent fc8da01 commit 4ec86f2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -658,16 +658,16 @@ bool LifetimeChecker::shouldEmitError(const SILInstruction *Inst) {
658658
}))
659659
return false;
660660

661-
// Ignore loads used only by an assign_by_wrapper setter. This
662-
// is safe to ignore because assign_by_wrapper will only be
663-
// re-written to use the setter if the value is fully initialized.
661+
// Ignore loads used only by an assign_by_wrapper or assign_or_init setter.
662+
// This is safe to ignore because assign_by_wrapper/assign_or_init will
663+
// only be re-written to use the setter if the value is fully initialized.
664664
if (auto *load = dyn_cast<SingleValueInstruction>(Inst)) {
665665
if (auto Op = load->getSingleUse()) {
666666
if (auto PAI = dyn_cast<PartialApplyInst>(Op->getUser())) {
667-
if (std::find_if(PAI->use_begin(), PAI->use_end(),
668-
[](auto PAIUse) {
669-
return isa<AssignByWrapperInst>(PAIUse->getUser());
670-
}) != PAI->use_end()) {
667+
if (std::find_if(PAI->use_begin(), PAI->use_end(), [](auto PAIUse) {
668+
return isa<AssignByWrapperInst>(PAIUse->getUser()) ||
669+
isa<AssignOrInitInst>(PAIUse->getUser());
670+
}) != PAI->use_end()) {
671671
return false;
672672
}
673673
}

0 commit comments

Comments
 (0)