[llvm] [CGSCC] Add statistic on largest SCC visited (PR #128073)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 20 13:22:43 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Arthur Eubanks (aeubanks)
<details>
<summary>Changes</summary>
To help debugging long compile times.
---
Full diff: https://github.com/llvm/llvm-project/pull/128073.diff
2 Files Affected:
- (modified) llvm/lib/Analysis/CGSCCPassManager.cpp (+5)
- (added) llvm/test/Other/largest-scc-stat.ll (+21)
``````````diff
diff --git a/llvm/lib/Analysis/CGSCCPassManager.cpp b/llvm/lib/Analysis/CGSCCPassManager.cpp
index 948bc2435ab27..ab3a721d874a5 100644
--- a/llvm/lib/Analysis/CGSCCPassManager.cpp
+++ b/llvm/lib/Analysis/CGSCCPassManager.cpp
@@ -13,6 +13,7 @@
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Analysis/LazyCallGraph.h"
#include "llvm/IR/Constant.h"
@@ -33,6 +34,8 @@
using namespace llvm;
+STATISTIC(LargestCGSCC, "Number of functions in the largest SCC");
+
// Explicit template instantiations and specialization definitions for core
// template typedefs.
namespace llvm {
@@ -82,6 +85,8 @@ PassManager<LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &,
if (!PI.runBeforePass(*Pass, *C))
continue;
+ LargestCGSCC.updateMax(C->size());
+
PreservedAnalyses PassPA = Pass->run(*C, AM, G, UR);
// Update the SCC if necessary.
diff --git a/llvm/test/Other/largest-scc-stat.ll b/llvm/test/Other/largest-scc-stat.ll
new file mode 100644
index 0000000000000..814f4dbe6b80b
--- /dev/null
+++ b/llvm/test/Other/largest-scc-stat.ll
@@ -0,0 +1,21 @@
+; REQUIRES: asserts
+; RUN: opt -passes='no-op-cgscc' -disable-output -stats < %s 2>&1 | FileCheck %s --check-prefix=ONE
+; RUN: opt -passes='cgscc(instcombine)' -disable-output -stats < %s 2>&1 | FileCheck %s --check-prefix=TWO
+
+; ONE: 1 cgscc - Number of functions in the largest SCC
+; TWO: 2 cgscc - Number of functions in the largest SCC
+
+ at g1 = constant ptr @f1
+ at g2 = constant ptr @f2
+
+define void @f1() {
+ %f = load ptr, ptr @g2
+ call void %f()
+ ret void
+}
+
+define void @f2() {
+ %f = load ptr, ptr @g1
+ call void %f()
+ ret void
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/128073
More information about the llvm-commits
mailing list