Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions llvm/lib/Transforms/Scalar/SROA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,9 @@ class SROA {
SmallSetVector<AllocaInst *, 16> PostPromotionWorklist;

/// A collection of alloca instructions we can directly promote.
std::vector<AllocaInst *> PromotableAllocas;
SetVector<AllocaInst *, SmallVector<AllocaInst *>,
SmallPtrSet<AllocaInst *, 16>, 16>
PromotableAllocas;

/// A worklist of PHIs to speculate prior to promoting allocas.
///
Expand Down Expand Up @@ -4799,9 +4801,7 @@ bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) {

// Finally, don't try to promote any allocas that new require re-splitting.
// They have already been added to the worklist above.
llvm::erase_if(PromotableAllocas, [&](AllocaInst *AI) {
return ResplitPromotableAllocas.count(AI);
});
PromotableAllocas.set_subtract(ResplitPromotableAllocas);

return true;
}
Expand Down Expand Up @@ -4963,7 +4963,7 @@ AllocaInst *SROA::rewritePartition(AllocaInst &AI, AllocaSlices &AS,
}
if (PHIUsers.empty() && SelectUsers.empty()) {
// Promote the alloca.
PromotableAllocas.push_back(NewAI);
PromotableAllocas.insert(NewAI);
} else {
// If we have either PHIs or Selects to speculate, add them to those
// worklists and re-queue the new alloca so that we promote in on the
Expand Down Expand Up @@ -5598,7 +5598,7 @@ bool SROA::promoteAllocas(Function &F) {
LLVM_DEBUG(dbgs() << "Not promoting allocas with mem2reg!\n");
} else {
LLVM_DEBUG(dbgs() << "Promoting allocas with mem2reg...\n");
PromoteMemToReg(PromotableAllocas, DTU->getDomTree(), AC);
PromoteMemToReg(PromotableAllocas.getArrayRef(), DTU->getDomTree(), AC);
}

PromotableAllocas.clear();
Expand All @@ -5615,7 +5615,7 @@ std::pair<bool /*Changed*/, bool /*CFGChanged*/> SROA::runSROA(Function &F) {
if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
if (DL.getTypeAllocSize(AI->getAllocatedType()).isScalable() &&
isAllocaPromotable(AI))
PromotableAllocas.push_back(AI);
PromotableAllocas.insert(AI);
else
Worklist.insert(AI);
}
Expand All @@ -5639,10 +5639,9 @@ std::pair<bool /*Changed*/, bool /*CFGChanged*/> SROA::runSROA(Function &F) {
// Remove the deleted allocas from various lists so that we don't try to
// continue processing them.
if (!DeletedAllocas.empty()) {
auto IsInSet = [&](AllocaInst *AI) { return DeletedAllocas.count(AI); };
Worklist.remove_if(IsInSet);
PostPromotionWorklist.remove_if(IsInSet);
llvm::erase_if(PromotableAllocas, IsInSet);
Worklist.set_subtract(DeletedAllocas);
PostPromotionWorklist.set_subtract(DeletedAllocas);
PromotableAllocas.set_subtract(DeletedAllocas);
DeletedAllocas.clear();
}
}
Expand Down