Skip to content

Commit eaa7ee5

Browse files
committed
[RLE-DSE] Revert to use a vector of BBState. SmallDenseMap grows quadratically
everytime and BBState is too big for that. Instead, use std::vector<BBState> to preallocate based on the # of basic blocks in the function.
1 parent fd48bb5 commit eaa7ee5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/SILPasses/Scalar/DeadStoreElimination.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class DSEContext {
278278
llvm::BumpPtrAllocator BPA;
279279

280280
/// Map every basic block to its location state.
281-
llvm::SmallDenseMap<SILBasicBlock *, BBState, 4> BBToLocState;
281+
llvm::DenseMap<SILBasicBlock *, BBState *> BBToLocState;
282282

283283
/// Keeps the actual BBStates.
284284
std::vector<BBState> BBStates;
@@ -295,7 +295,7 @@ class DSEContext {
295295
MemLocationIndexMap LocToBitIndex;
296296

297297
/// Return the BBState for the basic block this basic block belongs to.
298-
BBState *getBBLocState(SILBasicBlock *B) { return &BBToLocState[B]; }
298+
BBState *getBBLocState(SILBasicBlock *B) { return BBToLocState[B]; }
299299

300300
/// Return the BBState for the basic block this instruction belongs to.
301301
BBState *getBBLocState(SILInstruction *I) {
@@ -854,8 +854,13 @@ void DSEContext::run() {
854854
// than 64 basic blocks. Therefore, allocate the BBState in a vector and use
855855
// pointer in BBToLocState to access them.
856856
for (auto &B : *F) {
857-
BBToLocState[&B] = BBState(&B);
858-
BBToLocState[&B].init(MemLocationVault.size());
857+
BBStates.push_back(BBState(&B));
858+
BBStates.back().init(MemLocationVault.size());
859+
}
860+
861+
// Initialize the BBToLocState mapping.
862+
for (auto &S : BBStates) {
863+
BBToLocState[S.getBB()] = &S;
859864
}
860865

861866
// Generate the genset and killset for each basic block.

0 commit comments

Comments
 (0)