summaryrefslogtreecommitdiffstats
path: root/llvm/include/llvm/IR/ModuleSummaryIndex.h
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include/llvm/IR/ModuleSummaryIndex.h')
-rw-r--r--llvm/include/llvm/IR/ModuleSummaryIndex.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index c66727b3df2..a7b7560132d 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -375,6 +375,24 @@ public:
GlobalValueMap[ValueGUID].push_back(std::move(Summary));
}
+ /// Find the summary for global \p GUID in module \p ModuleId, or nullptr if
+ /// not found.
+ GlobalValueSummary *findSummaryInModule(GlobalValue::GUID ValueGUID,
+ StringRef ModuleId) const {
+ auto CalleeInfoList = findGlobalValueSummaryList(ValueGUID);
+ if (CalleeInfoList == end()) {
+ return nullptr; // This function does not have a summary
+ }
+ auto Summary =
+ llvm::find_if(CalleeInfoList->second,
+ [&](const std::unique_ptr<GlobalValueSummary> &Summary) {
+ return Summary->modulePath() == ModuleId;
+ });
+ if (Summary == CalleeInfoList->second.end())
+ return nullptr;
+ return Summary->get();
+ }
+
/// Returns the first GlobalValueSummary for \p GV, asserting that there
/// is only one if \p PerModuleIndex.
GlobalValueSummary *getGlobalValueSummary(const GlobalValue &GV,
OpenPOWER on IntegriCloud