1 //===- PassManager.cpp - Infrastructure for managing & running IR passes --===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "llvm/IR/PassManager.h" 11 #include "llvm/ADT/STLExtras.h" 12 #include "llvm/IR/LLVMContext.h" 13 14 using namespace llvm; 15 16 // Explicit template instantiations and specialization defininitions for core 17 // template typedefs. 18 namespace llvm { 19 template class AllAnalysesOn<Module>; 20 template class AllAnalysesOn<Function>; 21 template class PassManager<Module>; 22 template class PassManager<Function>; 23 template class AnalysisManager<Module>; 24 template class AnalysisManager<Function>; 25 template class InnerAnalysisManagerProxy<FunctionAnalysisManager, Module>; 26 template class OuterAnalysisManagerProxy<ModuleAnalysisManager, Function>; 27 28 template <> 29 bool FunctionAnalysisManagerModuleProxy::Result::invalidate( 30 Module &M, const PreservedAnalyses &PA, 31 ModuleAnalysisManager::Invalidator &Inv) { 32 // If this proxy isn't marked as preserved, then even if the result remains 33 // valid, the key itself may no longer be valid, so we clear everything. 34 // 35 // Note that in order to preserve this proxy, a module pass must ensure that 36 // the FAM has been completely updated to handle the deletion of functions. 37 // Specifically, any FAM-cached results for those functions need to have been 38 // forcibly cleared. When preserved, this proxy will only invalidate results 39 // cached on functions *still in the module* at the end of the module pass. 40 if (!PA.preserved(FunctionAnalysisManagerModuleProxy::ID())) { 41 InnerAM->clear(); 42 return true; 43 } 44 45 // Otherwise propagate the invalidation event to all the remaining IR units. 46 for (Function &F : M) 47 InnerAM->invalidate(F, PA); 48 49 // Return false to indicate that this result is still a valid proxy. 50 return false; 51 } 52 } 53 54 AnalysisKey PreservedAnalyses::AllAnalysesKey; 55