LLVM API Documentation

PassManager.cpp
Go to the documentation of this file.
00001 //===- PassManager.cpp - Infrastructure for managing & running IR passes --===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #include "llvm/ADT/STLExtras.h"
00011 #include "llvm/IR/LLVMContext.h"
00012 #include "llvm/IR/PassManager.h"
00013 
00014 using namespace llvm;
00015 
00016 char FunctionAnalysisManagerModuleProxy::PassID;
00017 
00018 FunctionAnalysisManagerModuleProxy::Result
00019 FunctionAnalysisManagerModuleProxy::run(Module &M) {
00020   assert(FAM->empty() && "Function analyses ran prior to the module proxy!");
00021   return Result(*FAM);
00022 }
00023 
00024 FunctionAnalysisManagerModuleProxy::Result::~Result() {
00025   // Clear out the analysis manager if we're being destroyed -- it means we
00026   // didn't even see an invalidate call when we got invalidated.
00027   FAM->clear();
00028 }
00029 
00030 bool FunctionAnalysisManagerModuleProxy::Result::invalidate(
00031     Module &M, const PreservedAnalyses &PA) {
00032   // If this proxy isn't marked as preserved, then we can't even invalidate
00033   // individual function analyses, there may be an invalid set of Function
00034   // objects in the cache making it impossible to incrementally preserve them.
00035   // Just clear the entire manager.
00036   if (!PA.preserved(ID()))
00037     FAM->clear();
00038 
00039   // Return false to indicate that this result is still a valid proxy.
00040   return false;
00041 }
00042 
00043 char ModuleAnalysisManagerFunctionProxy::PassID;