Skip to content

Commit ab098a7

Browse files
authored
[CGSCC] Add statistic on largest SCC visited (#128073)
To help debugging long compile times.
1 parent 209252f commit ab098a7

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

llvm/lib/Analysis/CGSCCPassManager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "llvm/ADT/SetVector.h"
1414
#include "llvm/ADT/SmallPtrSet.h"
1515
#include "llvm/ADT/SmallVector.h"
16+
#include "llvm/ADT/Statistic.h"
1617
#include "llvm/ADT/iterator_range.h"
1718
#include "llvm/Analysis/LazyCallGraph.h"
1819
#include "llvm/IR/Constant.h"
@@ -33,6 +34,8 @@
3334

3435
using namespace llvm;
3536

37+
STATISTIC(LargestCGSCC, "Number of functions in the largest SCC");
38+
3639
// Explicit template instantiations and specialization definitions for core
3740
// template typedefs.
3841
namespace llvm {
@@ -82,6 +85,8 @@ PassManager<LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &,
8285
if (!PI.runBeforePass(*Pass, *C))
8386
continue;
8487

88+
LargestCGSCC.updateMax(C->size());
89+
8590
PreservedAnalyses PassPA = Pass->run(*C, AM, G, UR);
8691

8792
// Update the SCC if necessary.

llvm/test/Other/largest-scc-stat.ll

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; REQUIRES: asserts
2+
; RUN: opt -passes='no-op-cgscc' -disable-output -stats < %s 2>&1 | FileCheck %s --check-prefix=ONE
3+
; RUN: opt -passes='cgscc(instcombine)' -disable-output -stats < %s 2>&1 | FileCheck %s --check-prefix=TWO
4+
5+
; ONE: 1 cgscc - Number of functions in the largest SCC
6+
; TWO: 2 cgscc - Number of functions in the largest SCC
7+
8+
define void @f1() {
9+
%f = bitcast ptr @f2 to ptr
10+
call void %f()
11+
ret void
12+
}
13+
14+
define void @f2() {
15+
%f = bitcast ptr @f1 to ptr
16+
call void %f()
17+
ret void
18+
}

0 commit comments

Comments
 (0)