mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
introduce a new abstraction for handling the memory object being
analyzed, and use it as common currency between the element use collector and its clients. Element collection is about to become more nuanced. NFC. Swift SVN r10781
This commit is contained in:
@@ -939,27 +939,29 @@ static void optimizeMemoryAllocations(SILFunction &Fn) {
|
||||
auto I = BB.begin(), E = BB.end();
|
||||
while (I != E) {
|
||||
SILInstruction *Inst = I;
|
||||
if (isa<AllocBoxInst>(Inst) || isa<AllocStackInst>(Inst)) {
|
||||
DEBUG(llvm::errs() << "*** DI Optimize looking at: " << *Inst << "\n");
|
||||
|
||||
// Set up the datastructure used to collect the uses of the allocation.
|
||||
SmallVector<DIMemoryUse, 16> Uses;
|
||||
SmallVector<SILInstruction*, 4> Releases;
|
||||
|
||||
// Walk the use list of the pointer, collecting them.
|
||||
collectDIElementUsesFromAllocation(Inst, Uses, Releases, true);
|
||||
|
||||
AllocOptimize(Inst, Uses, Releases).doIt();
|
||||
|
||||
// Carefully move iterator to avoid invalidation problems.
|
||||
if (!isa<AllocBoxInst>(Inst) && !isa<AllocStackInst>(Inst)) {
|
||||
++I;
|
||||
if (Inst->use_empty()) {
|
||||
Inst->eraseFromParent();
|
||||
++NumAllocRemoved;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
DEBUG(llvm::errs() << "*** DI Optimize looking at: " << *Inst << "\n");
|
||||
DIMemoryObjectInfo MemInfo(Inst);
|
||||
|
||||
// Set up the datastructure used to collect the uses of the allocation.
|
||||
SmallVector<DIMemoryUse, 16> Uses;
|
||||
SmallVector<SILInstruction*, 4> Releases;
|
||||
|
||||
// Walk the use list of the pointer, collecting them.
|
||||
collectDIElementUsesFrom(MemInfo, Uses, Releases, true);
|
||||
|
||||
AllocOptimize(Inst, Uses, Releases).doIt();
|
||||
|
||||
// Carefully move iterator to avoid invalidation problems.
|
||||
++I;
|
||||
if (Inst->use_empty()) {
|
||||
Inst->eraseFromParent();
|
||||
++NumAllocRemoved;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user