forked from OSchip/llvm-project
Store the child function analysis maps of a ModuleAnalysisManager by unique_ptr instead of by-value.
-- PiperOrigin-RevId: 248456926
This commit is contained in:
parent
742863b497
commit
b3888fa9cc
|
@ -242,7 +242,7 @@ public:
|
|||
auto it = functionAnalyses.find(function);
|
||||
if (it == functionAnalyses.end())
|
||||
return llvm::None;
|
||||
return it->second.getCachedAnalysis<AnalysisT>();
|
||||
return it->second->getCachedAnalysis<AnalysisT>();
|
||||
}
|
||||
|
||||
/// Query for the analysis for the module. The analysis is computed if it does
|
||||
|
@ -269,7 +269,8 @@ public:
|
|||
|
||||
private:
|
||||
/// The cached analyses for functions within the current module.
|
||||
llvm::DenseMap<Function *, detail::AnalysisMap<Function>> functionAnalyses;
|
||||
llvm::DenseMap<Function *, std::unique_ptr<detail::AnalysisMap<Function>>>
|
||||
functionAnalyses;
|
||||
|
||||
/// The analyses for the owning module.
|
||||
detail::AnalysisMap<Module> moduleAnalyses;
|
||||
|
|
|
@ -468,11 +468,15 @@ PassInstrumentor *FunctionAnalysisManager::getPassInstrumentor() const {
|
|||
}
|
||||
|
||||
/// Create an analysis slice for the given child function.
|
||||
FunctionAnalysisManager ModuleAnalysisManager::slice(Function *function) {
|
||||
assert(function->getModule() == moduleAnalyses.getIRUnit() &&
|
||||
FunctionAnalysisManager ModuleAnalysisManager::slice(Function *func) {
|
||||
assert(func->getModule() == moduleAnalyses.getIRUnit() &&
|
||||
"function has a different parent module");
|
||||
auto it = functionAnalyses.try_emplace(function, function);
|
||||
return {this, &it.first->second};
|
||||
auto it = functionAnalyses.find(func);
|
||||
if (it == functionAnalyses.end()) {
|
||||
it = functionAnalyses.try_emplace(func, new AnalysisMap<Function>(func))
|
||||
.first;
|
||||
}
|
||||
return {this, it->second.get()};
|
||||
}
|
||||
|
||||
/// Invalidate any non preserved analyses.
|
||||
|
@ -493,7 +497,7 @@ void ModuleAnalysisManager::invalidate(const detail::PreservedAnalyses &pa) {
|
|||
|
||||
// Otherwise, invalidate each function analyses.
|
||||
for (auto &analysisPair : functionAnalyses)
|
||||
analysisPair.second.invalidate(pa);
|
||||
analysisPair.second->invalidate(pa);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
Loading…
Reference in New Issue