Skip to content

Commit b0e3b7e

Browse files
committed
[SROA] Use SetVector for PromotableAllocas
Signed-off-by: Bartłomiej Chmiel <[email protected]>
1 parent 54bbd11 commit b0e3b7e

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

llvm/lib/Transforms/Scalar/SROA.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ class SROA {
198198
SmallSetVector<AllocaInst *, 16> PostPromotionWorklist;
199199

200200
/// A collection of alloca instructions we can directly promote.
201-
SmallPtrSet<AllocaInst *, 16> 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,8 +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-
for (auto *RPA : ResplitPromotableAllocas)
4803-
PromotableAllocas.erase(RPA);
4804+
PromotableAllocas.set_subtract(ResplitPromotableAllocas);
48044805

48054806
return true;
48064807
}
@@ -5597,9 +5598,7 @@ bool SROA::promoteAllocas(Function &F) {
55975598
LLVM_DEBUG(dbgs() << "Not promoting allocas with mem2reg!\n");
55985599
} else {
55995600
LLVM_DEBUG(dbgs() << "Promoting allocas with mem2reg...\n");
5600-
PromoteMemToReg(
5601-
std::vector(PromotableAllocas.begin(), PromotableAllocas.end()),
5602-
DTU->getDomTree(), AC);
5601+
PromoteMemToReg(PromotableAllocas.getArrayRef(), DTU->getDomTree(), AC);
56035602
}
56045603

56055604
PromotableAllocas.clear();
@@ -5642,8 +5641,7 @@ std::pair<bool /*Changed*/, bool /*CFGChanged*/> SROA::runSROA(Function &F) {
56425641
if (!DeletedAllocas.empty()) {
56435642
Worklist.set_subtract(DeletedAllocas);
56445643
PostPromotionWorklist.set_subtract(DeletedAllocas);
5645-
for (auto *DA : DeletedAllocas)
5646-
PromotableAllocas.erase(DA);
5644+
PromotableAllocas.set_subtract(DeletedAllocas);
56475645
DeletedAllocas.clear();
56485646
}
56495647
}

0 commit comments

Comments
 (0)