Skip to content

Commit 02a3816

Browse files
authored
Merge pull request #59983 from atrick/fix-discovered-blocks
PrunedLiveness fix discoveredBlocks to be unique.
2 parents 09ed0f1 + 1d589ce commit 02a3816

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

include/swift/SIL/PrunedLiveness.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,16 @@ class PrunedLiveBlocks {
180180
protected:
181181
void markBlockLive(SILBasicBlock *bb, IsLive isLive) {
182182
assert(isLive != Dead && "erasing live blocks isn't implemented.");
183-
liveBlocks[bb] = (isLive == LiveOut);
184-
if (discoveredBlocks)
185-
discoveredBlocks->push_back(bb);
183+
bool isLiveOut = (isLive == LiveOut);
184+
auto iterAndInserted =
185+
liveBlocks.insert(std::make_pair(bb, isLiveOut));
186+
if (iterAndInserted.second) {
187+
if (discoveredBlocks)
188+
discoveredBlocks->push_back(bb);
189+
} else if (isLiveOut) {
190+
// Update the existing entry to be live-out.
191+
iterAndInserted.first->getSecond() = true;
192+
}
186193
}
187194

188195
void computeUseBlockLiveness(SILBasicBlock *userBB);

0 commit comments

Comments
 (0)