[llvm] [SSAUpdater] Fix nondeterministic phi instruction order in bitcode (PR #151006)

Michael Hackner via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 28 11:50:24 PDT 2025


================
@@ -122,7 +122,14 @@ Value *SSAUpdater::GetValueInMiddleOfBlock(BasicBlock *BB) {
     }
   } else {
     bool isFirstPred = true;
-    for (BasicBlock *PredBB : predecessors(BB)) {
+
+    // Sort predecessors to get deterministic PHI operand ordering.
+    SmallVector<BasicBlock *, 8> SortedPreds(predecessors(BB));
----------------
HackAttack wrote:

The problem is not with `predecessors()`, but with the contents of the use list itself. The insertion order into that underlying list is (I guess) what’s nondeterministic.

https://github.com/llvm/llvm-project/pull/151006


More information about the llvm-commits mailing list