summaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index e65b9dad1380..a3ca910a6b15 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -104,6 +104,12 @@ static cl::opt<std::string> MemProfImportSummary(
cl::desc("Import summary to use for testing the ThinLTO backend via opt"),
cl::Hidden);
+// Indicate we are linking with an allocator that supports hot/cold operator
+// new interfaces.
+cl::opt<bool> SupportsHotColdNew(
+ "supports-hot-cold-new", cl::init(false), cl::Hidden,
+ cl::desc("Linking with hot/cold operator new interfaces"));
+
/// CRTP base for graphs built from either IR or ThinLTO summary index.
///
/// The graph represents the call contexts in all memprof metadata on allocation
@@ -3190,6 +3196,17 @@ bool MemProfContextDisambiguation::processModule(
if (ImportSummary)
return applyImport(M);
+ // TODO: If/when other types of memprof cloning are enabled beyond just for
+ // hot and cold, we will need to change this to individually control the
+ // AllocationType passed to addStackNodesForMIB during CCG construction.
+ // Note that we specifically check this after applying imports above, so that
+ // the option isn't needed to be passed to distributed ThinLTO backend
+ // clang processes, which won't necessarily have visibility into the linker
+ // dependences. Instead the information is communicated from the LTO link to
+ // the backends via the combined summary index.
+ if (!SupportsHotColdNew)
+ return false;
+
ModuleCallsiteContextGraph CCG(M, OREGetter);
return CCG.process();
}
@@ -3241,6 +3258,14 @@ void MemProfContextDisambiguation::run(
ModuleSummaryIndex &Index,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
isPrevailing) {
+ // TODO: If/when other types of memprof cloning are enabled beyond just for
+ // hot and cold, we will need to change this to individually control the
+ // AllocationType passed to addStackNodesForMIB during CCG construction.
+ // The index was set from the option, so these should be in sync.
+ assert(Index.withSupportsHotColdNew() == SupportsHotColdNew);
+ if (!SupportsHotColdNew)
+ return;
+
IndexCallsiteContextGraph CCG(Index, isPrevailing);
CCG.process();
}