[llvm] [MLInliner] Simplify NodeCount bookkeeping (PR #96576)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 24 16:43:30 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlgo

Author: Arthur Eubanks (aeubanks)

<details>
<summary>Changes</summary>

Rather than doing delta counting of the total number of functions, just increment it when we see a new function.

---
Full diff: https://github.com/llvm/llvm-project/pull/96576.diff


1 Files Affected:

- (modified) llvm/lib/Analysis/MLInlineAdvisor.cpp (+2-2) 


``````````diff
diff --git a/llvm/lib/Analysis/MLInlineAdvisor.cpp b/llvm/lib/Analysis/MLInlineAdvisor.cpp
index 21946572339b9..180fac47760cb 100644
--- a/llvm/lib/Analysis/MLInlineAdvisor.cpp
+++ b/llvm/lib/Analysis/MLInlineAdvisor.cpp
@@ -206,7 +206,6 @@ void MLInlineAdvisor::onPassEntry(LazyCallGraph::SCC *LastSCC) {
   // care about the nature of the Edge (call or ref). `FunctionLevels`-wise, we
   // record them at the same level as the original node (this is a choice, may
   // need revisiting).
-  NodeCount -= static_cast<int64_t>(NodesInLastSCC.size());
   while (!NodesInLastSCC.empty()) {
     const auto *N = *NodesInLastSCC.begin();
     NodesInLastSCC.erase(N);
@@ -215,14 +214,15 @@ void MLInlineAdvisor::onPassEntry(LazyCallGraph::SCC *LastSCC) {
       assert(!N->getFunction().isDeclaration());
       continue;
     }
-    ++NodeCount;
     EdgeCount += getLocalCalls(N->getFunction());
     const auto NLevel = FunctionLevels.at(N);
     for (const auto &E : *(*N)) {
       const auto *AdjNode = &E.getNode();
       assert(!AdjNode->isDead() && !AdjNode->getFunction().isDeclaration());
       auto I = AllNodes.insert(AdjNode);
+      // We've discovered a new function.
       if (I.second) {
+        ++NodeCount;
         NodesInLastSCC.insert(AdjNode);
         FunctionLevels[AdjNode] = NLevel;
       }

``````````

</details>


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


More information about the llvm-commits mailing list