Skip to content

Commit 8e45771

Browse files
committed
[CGSCC] Add statistic on largest SCC visited
To help debugging long compile times.
1 parent 9ba438d commit 8e45771

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-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.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
@g1 = constant ptr @f1
9+
@g2 = constant ptr @f2
10+
11+
define void @f1() {
12+
%f = load ptr, ptr @g2
13+
call void %f()
14+
ret void
15+
}
16+
17+
define void @f2() {
18+
%f = load ptr, ptr @g1
19+
call void %f()
20+
ret void
21+
}

0 commit comments

Comments
 (0)