[llvm] [GVNSink] Fix non-determinisms by using Depth-First ordering (PR #90995)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 21:18:24 PDT 2024


================
@@ -575,6 +607,13 @@ class GVNSink {
     unsigned NumSunk = 0;
     ReversePostOrderTraversal<Function*> RPOT(&F);
     VN.setReachableBBs(BasicBlocksSet(RPOT.begin(), RPOT.end()));
+    // Populated DFSNumbers ahead of time to avoid updating dominator tree
+    // when CFG is modified. The DFSNumbers of newly created basic blocks
+    // are irrelevant because RPOT is also obtained ahead of time and only
+    // DFSNumbers of original CFG are relevant for sinkable candidates.
+    for (auto *BB : RPOT)
+      if (DT->getNode(BB))
+        DFSNumbers[BB] = DT->getNode(BB)->getDFSNumIn();
----------------
hiraditya wrote:

True, Eli has also noted in a previous comment. I'll update the patch.

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


More information about the llvm-commits mailing list