mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-25 21:45:21 +00:00
[ThinLTO] Add an option to llvm-lto to print some basic statistics for the index
Differential Revision: https://reviews.llvm.org/D24290 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281537 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
93e6e5414d
commit
e0384663d6
@ -3,6 +3,9 @@
|
|||||||
; RUN: opt -module-summary %p/Inputs/funcimport.ll -o %t2.bc
|
; RUN: opt -module-summary %p/Inputs/funcimport.ll -o %t2.bc
|
||||||
; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
|
; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
|
||||||
|
|
||||||
|
; RUN: llvm-lto -thinlto-index-stats %t3.bc | FileCheck %s -check-prefix=STATS
|
||||||
|
; STATS: Index {{.*}} contains 24 nodes (13 functions, 3 alias, 8 globals) and 19 edges (8 refs and 11 calls)
|
||||||
|
|
||||||
; Ensure statics are promoted/renamed correctly from this file (all but
|
; Ensure statics are promoted/renamed correctly from this file (all but
|
||||||
; constant variable need promotion).
|
; constant variable need promotion).
|
||||||
; RUN: llvm-lto -thinlto-action=promote %t.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=EXPORTSTATIC
|
; RUN: llvm-lto -thinlto-action=promote %t.bc -thinlto-index=%t3.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=EXPORTSTATIC
|
||||||
|
@ -42,6 +42,11 @@ static cl::opt<char>
|
|||||||
"(default = '-O2')"),
|
"(default = '-O2')"),
|
||||||
cl::Prefix, cl::ZeroOrMore, cl::init('2'));
|
cl::Prefix, cl::ZeroOrMore, cl::init('2'));
|
||||||
|
|
||||||
|
static cl::opt<bool>
|
||||||
|
IndexStats("thinlto-index-stats",
|
||||||
|
cl::desc("Print statistic for the index in every input files"),
|
||||||
|
cl::init(false));
|
||||||
|
|
||||||
static cl::opt<bool> DisableVerify(
|
static cl::opt<bool> DisableVerify(
|
||||||
"disable-verify", cl::init(false),
|
"disable-verify", cl::init(false),
|
||||||
cl::desc("Do not run the verifier during the optimization pipeline"));
|
cl::desc("Do not run the verifier during the optimization pipeline"));
|
||||||
@ -264,6 +269,40 @@ getLocalLTOModule(StringRef Path, std::unique_ptr<MemoryBuffer> &Buffer,
|
|||||||
return std::move(*Ret);
|
return std::move(*Ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Print some statistics on the index for each input files.
|
||||||
|
void printIndexStats() {
|
||||||
|
for (auto &Filename : InputFilenames) {
|
||||||
|
CurrentActivity = "loading file '" + Filename + "'";
|
||||||
|
ErrorOr<std::unique_ptr<ModuleSummaryIndex>> IndexOrErr =
|
||||||
|
llvm::getModuleSummaryIndexForFile(Filename, diagnosticHandler);
|
||||||
|
error(IndexOrErr, "error " + CurrentActivity);
|
||||||
|
std::unique_ptr<ModuleSummaryIndex> Index = std::move(IndexOrErr.get());
|
||||||
|
CurrentActivity = "";
|
||||||
|
// Skip files without a module summary.
|
||||||
|
if (!Index)
|
||||||
|
report_fatal_error(Filename + " does not contain an index");
|
||||||
|
|
||||||
|
unsigned Calls = 0, Refs = 0, Functions = 0, Alias = 0, Globals = 0;
|
||||||
|
for (auto &Summaries : *Index) {
|
||||||
|
for (auto &Summary : Summaries.second) {
|
||||||
|
Refs += Summary->refs().size();
|
||||||
|
if (auto *FuncSummary = dyn_cast<FunctionSummary>(Summary.get())) {
|
||||||
|
Functions++;
|
||||||
|
Calls += FuncSummary->calls().size();
|
||||||
|
} else if (isa<AliasSummary>(Summary.get()))
|
||||||
|
Alias++;
|
||||||
|
else
|
||||||
|
Globals++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outs() << "Index " << Filename << " contains "
|
||||||
|
<< (Alias + Globals + Functions) << " nodes (" << Functions
|
||||||
|
<< " functions, " << Alias << " alias, " << Globals
|
||||||
|
<< " globals) and " << (Calls + Refs) << " edges (" << Refs
|
||||||
|
<< " refs and " << Calls << " calls)\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// \brief List symbols in each IR file.
|
/// \brief List symbols in each IR file.
|
||||||
///
|
///
|
||||||
/// The main point here is to provide lit-testable coverage for the LTOModule
|
/// The main point here is to provide lit-testable coverage for the LTOModule
|
||||||
@ -725,6 +764,11 @@ int main(int argc, char **argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IndexStats) {
|
||||||
|
printIndexStats();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (CheckHasObjC) {
|
if (CheckHasObjC) {
|
||||||
for (auto &Filename : InputFilenames) {
|
for (auto &Filename : InputFilenames) {
|
||||||
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
|
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
|
||||||
|
Loading…
Reference in New Issue
Block a user