[llvm] 81f4fb6 - [MLInliner] Simplify NodeCount bookkeeping (#96576)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 1 13:12:14 PDT 2024


Author: Arthur Eubanks
Date: 2024-07-01T13:12:10-07:00
New Revision: 81f4fb65d891902045b795341b3a263abb19d227

URL: https://github.com/llvm/llvm-project/commit/81f4fb65d891902045b795341b3a263abb19d227
DIFF: https://github.com/llvm/llvm-project/commit/81f4fb65d891902045b795341b3a263abb19d227.diff

LOG: [MLInliner] Simplify NodeCount bookkeeping (#96576)

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

Added: 
    

Modified: 
    llvm/lib/Analysis/MLInlineAdvisor.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/MLInlineAdvisor.cpp b/llvm/lib/Analysis/MLInlineAdvisor.cpp
index f4a782b4f168b..652f0d994b29c 100644
--- a/llvm/lib/Analysis/MLInlineAdvisor.cpp
+++ b/llvm/lib/Analysis/MLInlineAdvisor.cpp
@@ -211,7 +211,6 @@ void MLInlineAdvisor::onPassEntry(LazyCallGraph::SCC *CurSCC) {
   // 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);
@@ -220,14 +219,15 @@ void MLInlineAdvisor::onPassEntry(LazyCallGraph::SCC *CurSCC) {
       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;
       }


        


More information about the llvm-commits mailing list