@@ -198,7 +198,9 @@ class SROA {
198198 SmallSetVector<AllocaInst *, 16 > PostPromotionWorklist;
199199
200200 // / 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;
202204
203205 // / A worklist of PHIs to speculate prior to promoting allocas.
204206 // /
@@ -4799,9 +4801,7 @@ bool SROA::presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS) {
47994801
48004802 // Finally, don't try to promote any allocas that new require re-splitting.
48014803 // 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);
48054805
48064806 return true ;
48074807}
@@ -4963,7 +4963,7 @@ AllocaInst *SROA::rewritePartition(AllocaInst &AI, AllocaSlices &AS,
49634963 }
49644964 if (PHIUsers.empty () && SelectUsers.empty ()) {
49654965 // Promote the alloca.
4966- PromotableAllocas.push_back (NewAI);
4966+ PromotableAllocas.insert (NewAI);
49674967 } else {
49684968 // If we have either PHIs or Selects to speculate, add them to those
49694969 // worklists and re-queue the new alloca so that we promote in on the
@@ -5598,7 +5598,7 @@ bool SROA::promoteAllocas(Function &F) {
55985598 LLVM_DEBUG (dbgs () << " Not promoting allocas with mem2reg!\n " );
55995599 } else {
56005600 LLVM_DEBUG (dbgs () << " Promoting allocas with mem2reg...\n " );
5601- PromoteMemToReg (PromotableAllocas, DTU->getDomTree (), AC);
5601+ PromoteMemToReg (PromotableAllocas. getArrayRef () , DTU->getDomTree (), AC);
56025602 }
56035603
56045604 PromotableAllocas.clear ();
@@ -5615,7 +5615,7 @@ std::pair<bool /*Changed*/, bool /*CFGChanged*/> SROA::runSROA(Function &F) {
56155615 if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
56165616 if (DL.getTypeAllocSize (AI->getAllocatedType ()).isScalable () &&
56175617 isAllocaPromotable (AI))
5618- PromotableAllocas.push_back (AI);
5618+ PromotableAllocas.insert (AI);
56195619 else
56205620 Worklist.insert (AI);
56215621 }
@@ -5639,10 +5639,9 @@ std::pair<bool /*Changed*/, bool /*CFGChanged*/> SROA::runSROA(Function &F) {
56395639 // Remove the deleted allocas from various lists so that we don't try to
56405640 // continue processing them.
56415641 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);
56465645 DeletedAllocas.clear ();
56475646 }
56485647 }
0 commit comments