From c76fad87c63133cfa3bffb061ebdbf423f532e50 Mon Sep 17 00:00:00 2001 From: Jamie <2119834+jamieQ@users.noreply.github.com> Date: Tue, 11 Nov 2025 07:17:04 -0600 Subject: [PATCH] [NFC][DI]: remove getLivenessAtNonTupleInst method from definite init The method originally special-cased logic that would provide a meaningful speedup and simplification, but IIUC the history, this has no longer been the case for many years, so we might as well remove it to make the code more straightforward. --- .../Mandatory/DefiniteInitialization.cpp | 46 ------------------- 1 file changed, 46 deletions(-) diff --git a/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp b/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp index 4df93a776435e..860084a1688c9 100644 --- a/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp +++ b/lib/SILOptimizer/Mandatory/DefiniteInitialization.cpp @@ -474,9 +474,6 @@ namespace { AvailabilitySet getLivenessAtInst(SILInstruction *Inst, unsigned FirstElt, unsigned NumElts); - AvailabilitySet getLivenessAtNonTupleInst(SILInstruction *Inst, - SILBasicBlock *InstBB, - AvailabilitySet &CurrentSet); int getAnyUninitializedMemberAtInst(SILInstruction *Inst, unsigned FirstElt, unsigned NumElts); @@ -3592,43 +3589,6 @@ void LifetimeChecker::getOutSelfInitialized(SILBasicBlock *BB, Result = mergeKinds(Result, getBlockInfo(Pred).OutSelfInitialized); } -AvailabilitySet -LifetimeChecker::getLivenessAtNonTupleInst(swift::SILInstruction *Inst, - swift::SILBasicBlock *InstBB, - AvailabilitySet &Result) { - // If there is a store in the current block, scan the block to see if the - // store is before or after the load. If it is before, it produces the value - // we are looking for. - if (getBlockInfo(InstBB).HasNonLoadUse) { - for (auto BBI = Inst->getIterator(), E = InstBB->begin(); BBI != E;) { - --BBI; - SILInstruction *TheInst = &*BBI; - - if (TheInst == TheMemory.getUninitializedValue()) { - Result.set(0, DIKind::No); - return Result; - } - - if (NonLoadUses.count(TheInst)) { - // We've found a definition, or something else that will require that - // the memory is initialized at this point. - Result.set(0, DIKind::Yes); - return Result; - } - } - } - - getOutAvailability(InstBB, Result); - - // If the result element wasn't computed, we must be analyzing code within - // an unreachable cycle that is not dominated by "TheMemory". Just force - // the unset element to yes so that clients don't have to handle this. - if (!Result.getConditional(0)) - Result.set(0, DIKind::Yes); - - return Result; -} - /// getLivenessAtInst - Compute the liveness state for any number of tuple /// elements at the specified instruction. The elements are returned as an /// AvailabilitySet. Elements outside of the range specified may not be @@ -3648,12 +3608,6 @@ AvailabilitySet LifetimeChecker::getLivenessAtInst(SILInstruction *Inst, SILBasicBlock *InstBB = Inst->getParent(); - // The vastly most common case is memory allocations that are not tuples, - // so special case this with a more efficient algorithm. - if (TheMemory.getNumElements() == 1) { - return getLivenessAtNonTupleInst(Inst, InstBB, Result); - } - // Check locally to see if any elements are satisfied within the block, and // keep track of which ones are still needed in the NeededElements set. SmallBitVector NeededElements(TheMemory.getNumElements());