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

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 28 11:55: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));
----------------
efriedma-quic wrote:

If the order of the use list isn't determinstic, we consider that a bug. (We output the order of that list if you use --preserve-ll-uselistorder.)

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


More information about the llvm-commits mailing list