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

via llvm-commits llvm-commits at lists.llvm.org
Fri May 3 14:16:13 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.
----------------
hiraditya wrote:

That makes sense. I see the code around `SplitBlockPredecessors`  has no test. And i'm not sure if this is a useful case either. I'm fine removing that part of code altogether. WDYT?

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


More information about the llvm-commits mailing list