diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-03-27 15:27:30 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-03-27 15:27:30 +0000 |
commit | d29478f70ed60a34e5737c4f48be638ef35f3c41 (patch) | |
tree | 6acde4398a57f947b921fdcaef7d97fd02a7917f /llvm/lib/Transforms/IPO/FunctionImport.cpp | |
parent | 9aae395fa809aa07dcceafc2552cca45205c43bd (diff) | |
download | bcm5719-llvm-d29478f70ed60a34e5737c4f48be638ef35f3c41.tar.gz bcm5719-llvm-d29478f70ed60a34e5737c4f48be638ef35f3c41.zip |
[ThinLTO] Add optional import message and statistics
Summary:
Add a statistic to count the number of imported functions. Also, add a
new -print-imports option to emit a trace of imported functions, that
works even for an NDEBUG build.
Note that emitOptimizationRemark does not work for the above printing as
it expects a Function object and DebugLoc, neither of which we have
with summary-based importing.
This is part 2 of D18487, the first part was committed separately as
r264536.
Reviewers: joker.eph
Subscribers: llvm-commits, joker.eph
Differential Revision: http://reviews.llvm.org/D18487
llvm-svn: 264537
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionImport.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionImport.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index 896ac5d3003..a99739c9ae8 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -14,6 +14,7 @@ #include "llvm/Transforms/IPO/FunctionImport.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringSet.h" #include "llvm/IR/AutoUpgrade.h" #include "llvm/IR/DiagnosticPrinter.h" @@ -31,6 +32,8 @@ using namespace llvm; +STATISTIC(NumImported, "Number of functions imported"); + /// Limit on instruction count of imported functions. static cl::opt<unsigned> ImportInstrLimit( "import-instr-limit", cl::init(100), cl::Hidden, cl::value_desc("N"), @@ -43,6 +46,9 @@ static cl::opt<float> "`import-instr-limit` threshold by this factor " "before processing newly imported functions")); +static cl::opt<bool> PrintImports("print-imports", cl::init(false), cl::Hidden, + cl::desc("Print imported functions")); + // Load lazily a module from \p FileName in \p Context. static std::unique_ptr<Module> loadFile(const std::string &FileName, LLVMContext &Context) { @@ -348,6 +354,12 @@ bool FunctionImporter::importFunctions( if (renameModuleForThinLTO(*SrcModule, Index, &GlobalsToImport)) return true; + if (PrintImports) { + for (const auto *GV : GlobalsToImport) + dbgs() << DestModule.getSourceFileName() << ": Import " << GV->getName() + << " from " << SrcModule->getSourceFileName() << "\n"; + } + if (TheLinker.linkInModule(std::move(SrcModule), Linker::Flags::None, &GlobalsToImport)) report_fatal_error("Function Import: link error"); @@ -355,6 +367,8 @@ bool FunctionImporter::importFunctions( ImportedCount += GlobalsToImport.size(); } + NumImported += ImportedCount; + DEBUG(dbgs() << "Imported " << ImportedCount << " functions for Module " << DestModule.getModuleIdentifier() << "\n"); return ImportedCount; |