@@ -198,7 +198,7 @@ class SROA {
198
198
SmallSetVector<AllocaInst *, 16 > PostPromotionWorklist;
199
199
200
200
// / A collection of alloca instructions we can directly promote.
201
- std::vector <AllocaInst *> PromotableAllocas;
201
+ SmallPtrSet <AllocaInst *, 16 > PromotableAllocas;
202
202
203
203
// / A worklist of PHIs to speculate prior to promoting allocas.
204
204
// /
@@ -4769,9 +4769,8 @@ bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) {
4769
4769
4770
4770
// Finally, don't try to promote any allocas that new require re-splitting.
4771
4771
// They have already been added to the worklist above.
4772
- llvm::erase_if (PromotableAllocas, [&](AllocaInst *AI) {
4773
- return ResplitPromotableAllocas.count (AI);
4774
- });
4772
+ for (auto *RPA : ResplitPromotableAllocas)
4773
+ PromotableAllocas.erase (RPA);
4775
4774
4776
4775
return true ;
4777
4776
}
@@ -4933,7 +4932,7 @@ AllocaInst *SROA::rewritePartition(AllocaInst &AI, AllocaSlices &AS,
4933
4932
}
4934
4933
if (PHIUsers.empty () && SelectUsers.empty ()) {
4935
4934
// Promote the alloca.
4936
- PromotableAllocas.push_back (NewAI);
4935
+ PromotableAllocas.insert (NewAI);
4937
4936
} else {
4938
4937
// If we have either PHIs or Selects to speculate, add them to those
4939
4938
// worklists and re-queue the new alloca so that we promote in on the
@@ -5568,7 +5567,9 @@ bool SROA::promoteAllocas(Function &F) {
5568
5567
LLVM_DEBUG (dbgs () << " Not promoting allocas with mem2reg!\n " );
5569
5568
} else {
5570
5569
LLVM_DEBUG (dbgs () << " Promoting allocas with mem2reg...\n " );
5571
- PromoteMemToReg (PromotableAllocas, DTU->getDomTree (), AC);
5570
+ PromoteMemToReg (
5571
+ std::vector (PromotableAllocas.begin (), PromotableAllocas.end ()),
5572
+ DTU->getDomTree (), AC);
5572
5573
}
5573
5574
5574
5575
PromotableAllocas.clear ();
@@ -5585,7 +5586,7 @@ std::pair<bool /*Changed*/, bool /*CFGChanged*/> SROA::runSROA(Function &F) {
5585
5586
if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
5586
5587
if (DL.getTypeAllocSize (AI->getAllocatedType ()).isScalable () &&
5587
5588
isAllocaPromotable (AI))
5588
- PromotableAllocas.push_back (AI);
5589
+ PromotableAllocas.insert (AI);
5589
5590
else
5590
5591
Worklist.insert (AI);
5591
5592
}
@@ -5609,10 +5610,10 @@ std::pair<bool /*Changed*/, bool /*CFGChanged*/> SROA::runSROA(Function &F) {
5609
5610
// Remove the deleted allocas from various lists so that we don't try to
5610
5611
// continue processing them.
5611
5612
if (!DeletedAllocas.empty ()) {
5612
- auto IsInSet = [&](AllocaInst *AI) { return DeletedAllocas. count (AI); } ;
5613
- Worklist. remove_if (IsInSet );
5614
- PostPromotionWorklist. remove_if (IsInSet);
5615
- llvm::erase_if (PromotableAllocas, IsInSet );
5613
+ Worklist. set_subtract (DeletedAllocas) ;
5614
+ PostPromotionWorklist. set_subtract (DeletedAllocas );
5615
+ for ( auto *DA : DeletedAllocas)
5616
+ PromotableAllocas. erase (DA );
5616
5617
DeletedAllocas.clear ();
5617
5618
}
5618
5619
}
0 commit comments