@@ -198,7 +198,9 @@ 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
+ SetVector<AllocaInst *, SmallVector<AllocaInst *>,
202
+ SmallPtrSet<AllocaInst *, 16 >, 16 >
203
+ PromotableAllocas;
202
204
203
205
// / A worklist of PHIs to speculate prior to promoting allocas.
204
206
// /
@@ -4799,9 +4801,7 @@ bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) {
4799
4801
4800
4802
// Finally, don't try to promote any allocas that new require re-splitting.
4801
4803
// They have already been added to the worklist above.
4802
- llvm::erase_if (PromotableAllocas, [&](AllocaInst *AI) {
4803
- return ResplitPromotableAllocas.count (AI);
4804
- });
4804
+ PromotableAllocas.set_subtract (ResplitPromotableAllocas);
4805
4805
4806
4806
return true ;
4807
4807
}
@@ -4963,7 +4963,7 @@ AllocaInst *SROA::rewritePartition(AllocaInst &AI, AllocaSlices &AS,
4963
4963
}
4964
4964
if (PHIUsers.empty () && SelectUsers.empty ()) {
4965
4965
// Promote the alloca.
4966
- PromotableAllocas.push_back (NewAI);
4966
+ PromotableAllocas.insert (NewAI);
4967
4967
} else {
4968
4968
// If we have either PHIs or Selects to speculate, add them to those
4969
4969
// worklists and re-queue the new alloca so that we promote in on the
@@ -5598,7 +5598,7 @@ bool SROA::promoteAllocas(Function &F) {
5598
5598
LLVM_DEBUG (dbgs () << " Not promoting allocas with mem2reg!\n " );
5599
5599
} else {
5600
5600
LLVM_DEBUG (dbgs () << " Promoting allocas with mem2reg...\n " );
5601
- PromoteMemToReg (PromotableAllocas, DTU->getDomTree (), AC);
5601
+ PromoteMemToReg (PromotableAllocas. getArrayRef () , DTU->getDomTree (), AC);
5602
5602
}
5603
5603
5604
5604
PromotableAllocas.clear ();
@@ -5615,7 +5615,7 @@ std::pair<bool /*Changed*/, bool /*CFGChanged*/> SROA::runSROA(Function &F) {
5615
5615
if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
5616
5616
if (DL.getTypeAllocSize (AI->getAllocatedType ()).isScalable () &&
5617
5617
isAllocaPromotable (AI))
5618
- PromotableAllocas.push_back (AI);
5618
+ PromotableAllocas.insert (AI);
5619
5619
else
5620
5620
Worklist.insert (AI);
5621
5621
}
@@ -5639,10 +5639,9 @@ std::pair<bool /*Changed*/, bool /*CFGChanged*/> SROA::runSROA(Function &F) {
5639
5639
// Remove the deleted allocas from various lists so that we don't try to
5640
5640
// continue processing them.
5641
5641
if (!DeletedAllocas.empty ()) {
5642
- auto IsInSet = [&](AllocaInst *AI) { return DeletedAllocas.count (AI); };
5643
- Worklist.remove_if (IsInSet);
5644
- PostPromotionWorklist.remove_if (IsInSet);
5645
- llvm::erase_if (PromotableAllocas, IsInSet);
5642
+ Worklist.set_subtract (DeletedAllocas);
5643
+ PostPromotionWorklist.set_subtract (DeletedAllocas);
5644
+ PromotableAllocas.set_subtract (DeletedAllocas);
5646
5645
DeletedAllocas.clear ();
5647
5646
}
5648
5647
}
0 commit comments