Skip to content

[CGSCC] Add statistic on largest SCC visited #128073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions llvm/lib/Analysis/CGSCCPassManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions llvm/test/Other/largest-scc-stat.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
; 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

define void @f1() {
%f = bitcast ptr @f2 to ptr
call void %f()
ret void
}

define void @f2() {
%f = bitcast ptr @f1 to ptr
call void %f()
ret void
}