[llvm] [nfc][mlgo] Incrementally update DominatorTreeAnalysis in FunctionPropertiesAnalysis (PR #104867)

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 21 11:05:37 PDT 2024


================
@@ -356,6 +369,40 @@ FunctionPropertiesUpdater::FunctionPropertiesUpdater(
     FPI.updateForBB(*BB, -1);
 }
 
+DominatorTree &FunctionPropertiesUpdater::getUpdatedDominatorTree(
+    FunctionAnalysisManager &FAM) const {
+  auto &DT =
+      FAM.getResult<DominatorTreeAnalysis>(const_cast<Function &>(Caller));
+
+  DenseSet<const BasicBlock *> NewSucc;
+  NewSucc.insert(succ_begin(&CallSiteBB), succ_end(&CallSiteBB));
+
+  // tell the DomTree about the new edges
+  std::deque<const BasicBlock *> Worklist;
+  Worklist.push_back(&CallSiteBB);
+  while (!Worklist.empty()) {
+    auto *BB = Worklist.front();
+    Worklist.pop_front();
+    assert(DT.getNode(BB));
+
+    for (auto *Succ : NewSucc) {
+      if (!DT.getNode(Succ))
+        Worklist.push_back(Succ);
+      DT.insertEdge(const_cast<BasicBlock *>(BB),
+                    const_cast<BasicBlock *>(Succ));
----------------
mtrofin wrote:

true, and it's more consistent. Done.

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


More information about the llvm-commits mailing list