PassManager.cpp revision ebe69fe11e48d322045d5949c83283927a0d790b
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/ADT/STLExtras.h" 11#include "llvm/IR/LLVMContext.h" 12#include "llvm/IR/PassManager.h" 13 14using namespace llvm; 15 16char FunctionAnalysisManagerModuleProxy::PassID; 17 18FunctionAnalysisManagerModuleProxy::Result 19FunctionAnalysisManagerModuleProxy::run(Module &M) { 20 assert(FAM->empty() && "Function analyses ran prior to the module proxy!"); 21 return Result(*FAM); 22} 23 24FunctionAnalysisManagerModuleProxy::Result::~Result() { 25 // Clear out the analysis manager if we're being destroyed -- it means we 26 // didn't even see an invalidate call when we got invalidated. 27 FAM->clear(); 28} 29 30bool FunctionAnalysisManagerModuleProxy::Result::invalidate( 31 Module &M, const PreservedAnalyses &PA) { 32 // If this proxy isn't marked as preserved, then we can't even invalidate 33 // individual function analyses, there may be an invalid set of Function 34 // objects in the cache making it impossible to incrementally preserve them. 35 // Just clear the entire manager. 36 if (!PA.preserved(ID())) 37 FAM->clear(); 38 39 // Return false to indicate that this result is still a valid proxy. 40 return false; 41} 42 43char ModuleAnalysisManagerFunctionProxy::PassID; 44