X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FIR%2FPassManager.cpp;h=2e2a7cb4956c05a6fc2cc9ab73fd709ce1983311;hb=29e82393abf3d8f578c6719af03b596858761a4f;hp=88464e0ef0e5a30d7ad20529d54a43c57549eabc;hpb=1b497a9fc4854a451481d4d92c6fd49f6ac1ce5d;p=oota-llvm.git diff --git a/lib/IR/PassManager.cpp b/lib/IR/PassManager.cpp index 88464e0ef0e..2e2a7cb4956 100644 --- a/lib/IR/PassManager.cpp +++ b/lib/IR/PassManager.cpp @@ -1,4 +1,4 @@ -//===- PassManager.h - Infrastructure for managing & running IR passes ----===// +//===- PassManager.cpp - Infrastructure for managing & running IR passes --===// // // The LLVM Compiler Infrastructure // @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/STLExtras.h" +#include "llvm/IR/LLVMContext.h" #include "llvm/IR/PassManager.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" @@ -32,6 +33,8 @@ PreservedAnalyses ModulePassManager::run(Module *M, ModuleAnalysisManager *AM) { if (AM) AM->invalidate(M, PassPA); PA.intersect(std::move(PassPA)); + + M->getContext().yield(); } if (DebugPM) @@ -50,7 +53,7 @@ ModuleAnalysisManager::getResultImpl(void *PassID, Module *M) { // If we don't have a cached result for this module, look up the pass and run // it to produce a result, which we then add to the cache. if (Inserted) - RI->second = std::move(lookupPass(PassID).run(M, this)); + RI->second = lookupPass(PassID).run(M, this); return *RI->second; } @@ -59,7 +62,7 @@ ModuleAnalysisManager::ResultConceptT * ModuleAnalysisManager::getCachedResultImpl(void *PassID, Module *M) const { ModuleAnalysisResultMapT::const_iterator RI = ModuleAnalysisResults.find(PassID); - return RI == ModuleAnalysisResults.end() ? 0 : &*RI->second; + return RI == ModuleAnalysisResults.end() ? nullptr : &*RI->second; } void ModuleAnalysisManager::invalidateImpl(void *PassID, Module *M) { @@ -92,6 +95,8 @@ PreservedAnalyses FunctionPassManager::run(Function *F, if (AM) AM->invalidate(F, PassPA); PA.intersect(std::move(PassPA)); + + F->getContext().yield(); } if (DebugPM) @@ -135,7 +140,7 @@ FunctionAnalysisManager::ResultConceptT * FunctionAnalysisManager::getCachedResultImpl(void *PassID, Function *F) const { FunctionAnalysisResultMapT::const_iterator RI = FunctionAnalysisResults.find(std::make_pair(PassID, F)); - return RI == FunctionAnalysisResults.end() ? 0 : &*RI->second->second; + return RI == FunctionAnalysisResults.end() ? nullptr : &*RI->second->second; } void FunctionAnalysisManager::invalidateImpl(void *PassID, Function *F) { @@ -165,20 +170,22 @@ void FunctionAnalysisManager::invalidateImpl(Function *F, while (!InvalidatedPassIDs.empty()) FunctionAnalysisResults.erase( std::make_pair(InvalidatedPassIDs.pop_back_val(), F)); + if (ResultsList.empty()) + FunctionAnalysisResultLists.erase(F); } char FunctionAnalysisManagerModuleProxy::PassID; FunctionAnalysisManagerModuleProxy::Result FunctionAnalysisManagerModuleProxy::run(Module *M) { - assert(FAM.empty() && "Function analyses ran prior to the module proxy!"); - return Result(FAM); + assert(FAM->empty() && "Function analyses ran prior to the module proxy!"); + return Result(*FAM); } FunctionAnalysisManagerModuleProxy::Result::~Result() { // Clear out the analysis manager if we're being destroyed -- it means we // didn't even see an invalidate call when we got invalidated. - FAM.clear(); + FAM->clear(); } bool FunctionAnalysisManagerModuleProxy::Result::invalidate( @@ -188,7 +195,7 @@ bool FunctionAnalysisManagerModuleProxy::Result::invalidate( // objects in the cache making it impossible to incrementally preserve them. // Just clear the entire manager. if (!PA.preserved(ID())) - FAM.clear(); + FAM->clear(); // Return false to indicate that this result is still a valid proxy. return false;