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

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Fri May 3 13:54:37 PDT 2024


================
@@ -886,8 +919,12 @@ void GVNSink::sinkLastInstruction(ArrayRef<BasicBlock *> Blocks,
 } // end anonymous namespace
 
 PreservedAnalyses GVNSinkPass::run(Function &F, FunctionAnalysisManager &AM) {
-  GVNSink G;
+  auto &DT = AM.getResult<DominatorTreeAnalysis>(F);
+  GVNSink G(&DT);
   if (!G.run(F))
     return PreservedAnalyses::all();
+
+  // PHI nodes get inserted which haven't been added to the Dominator Tree.
----------------
efriedma-quic wrote:

PHI nodes aren't represented in the dominator tree.  The issue is the call to SplitBlockPredecessors().  (You probably could preserve the domtree without much effort; SplitBlockPredecessors() has code to preserve it if you pass in a DomTreeUpdater.)

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


More information about the llvm-commits mailing list