Skip to content

Commit 7320ad5

Browse files
authored
Merge pull request swiftlang#26277 from gottesmm/pr-eb6192be214bfccb53ed1addf68ee4ad08e6f0d6
2 parents 2f867eb + 096eda2 commit 7320ad5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/SILOptimizer/Utils/CFG.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,13 @@ void swift::erasePhiArgument(SILBasicBlock *block, unsigned argIndex) {
140140
// Determine the set of predecessors in case any predecessor has
141141
// two edges to this block (e.g. a conditional branch where both
142142
// sides reach this block).
143-
SmallVector<SILBasicBlock *, 8> predBlocks(block->pred_begin(),
144-
block->pred_end());
145-
sortUnique(predBlocks);
143+
//
144+
// NOTE: This needs to be a SmallSetVector since we need both uniqueness /and/
145+
// insertion order. Otherwise non-determinism can result.
146+
SmallSetVector<SILBasicBlock *, 8> predBlocks;
147+
148+
for (auto *pred : block->getPredecessorBlocks())
149+
predBlocks.insert(pred);
146150

147151
for (auto *pred : predBlocks)
148152
deleteEdgeValue(pred->getTerminator(), block, argIndex);

0 commit comments

Comments
 (0)