summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/FunctionImport.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2018-04-01 15:54:40 +0000
committerTeresa Johnson <tejohnson@google.com>2018-04-01 15:54:40 +0000
commit974706ebf76100f0cccf680bf4a4ad9649e39e94 (patch)
tree95934117d7910415e1159ae711a3bc997d76396d /llvm/lib/Transforms/IPO/FunctionImport.cpp
parentf80ebc8d214115c1887854aa37965fb799c8b6ef (diff)
downloadbcm5719-llvm-974706ebf76100f0cccf680bf4a4ad9649e39e94.tar.gz
bcm5719-llvm-974706ebf76100f0cccf680bf4a4ad9649e39e94.zip
[ThinLTO] Add an import cutoff for debugging/triaging
Summary: Adds -import-cutoff=N which will stop importing during the thin link after N imports. Default is -1 (no limit). Reviewers: wmi Subscribers: inglorion, llvm-commits Differential Revision: https://reviews.llvm.org/D45127 llvm-svn: 328934
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionImport.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionImport.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index d021b4a59a8..26d7db10880 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -71,6 +71,10 @@ static cl::opt<unsigned> ImportInstrLimit(
"import-instr-limit", cl::init(100), cl::Hidden, cl::value_desc("N"),
cl::desc("Only import functions with less than N instructions"));
+static cl::opt<int> ImportCutoff(
+ "import-cutoff", cl::init(-1), cl::Hidden, cl::value_desc("N"),
+ cl::desc("Only import first N functions if N>=0 (default -1)"));
+
static cl::opt<float>
ImportInstrFactor("import-instr-evolution-factor", cl::init(0.7),
cl::Hidden, cl::value_desc("x"),
@@ -276,11 +280,18 @@ static void computeImportForFunction(
StringMap<FunctionImporter::ExportSetTy> *ExportLists = nullptr) {
computeImportForReferencedGlobals(Summary, DefinedGVSummaries, ImportList,
ExportLists);
+ static int ImportCount = 0;
for (auto &Edge : Summary.calls()) {
ValueInfo VI = Edge.first;
DEBUG(dbgs() << " edge -> " << VI.getGUID() << " Threshold:" << Threshold
<< "\n");
+ if (ImportCutoff >= 0 && ImportCount >= ImportCutoff) {
+ DEBUG(dbgs() << "ignored! import-cutoff value of " << ImportCutoff
+ << " reached.\n");
+ continue;
+ }
+
VI = updateValueInfoForIndirectCalls(Index, VI);
if (!VI)
continue;
@@ -343,6 +354,8 @@ static void computeImportForFunction(
// Mark this function as imported in this module, with the current Threshold
ProcessedThreshold = AdjThreshold;
+ ImportCount++;
+
// Make exports in the source module.
if (ExportLists) {
auto &ExportList = (*ExportLists)[ExportModulePath];
OpenPOWER on IntegriCloud