Hans Wennborg | f88287f | 2014-03-19 18:41:38 +0000 | [diff] [blame] | 1 | //===- PassManager.cpp - Infrastructure for managing & running IR passes --===// |
Chandler Carruth | 74015a7 | 2013-11-13 01:12:08 +0000 | [diff] [blame] | 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 | |
Chandler Carruth | 74015a7 | 2013-11-13 01:12:08 +0000 | [diff] [blame] | 10 | #include "llvm/ADT/STLExtras.h" |
Juergen Ributzka | 34390c7 | 2014-05-16 02:33:15 +0000 | [diff] [blame] | 11 | #include "llvm/IR/LLVMContext.h" |
Chandler Carruth | a13f27c | 2014-01-11 11:52:05 +0000 | [diff] [blame] | 12 | #include "llvm/IR/PassManager.h" |
Chandler Carruth | 74015a7 | 2013-11-13 01:12:08 +0000 | [diff] [blame] | 13 | |
| 14 | using namespace llvm; |
Chandler Carruth | a13f27c | 2014-01-11 11:52:05 +0000 | [diff] [blame] | 15 | |
Chandler Carruth | b3e7219 | 2013-11-22 00:43:29 +0000 | [diff] [blame] | 16 | char FunctionAnalysisManagerModuleProxy::PassID; |
Chandler Carruth | 851a2aa | 2013-11-21 02:11:31 +0000 | [diff] [blame] | 17 | |
Chandler Carruth | b3e7219 | 2013-11-22 00:43:29 +0000 | [diff] [blame] | 18 | FunctionAnalysisManagerModuleProxy::Result |
Chandler Carruth | d174ce4 | 2015-01-05 02:47:05 +0000 | [diff] [blame] | 19 | FunctionAnalysisManagerModuleProxy::run(Module &M) { |
Chandler Carruth | b07f378 | 2014-03-13 09:50:31 +0000 | [diff] [blame] | 20 | assert(FAM->empty() && "Function analyses ran prior to the module proxy!"); |
| 21 | return Result(*FAM); |
Chandler Carruth | 851a2aa | 2013-11-21 02:11:31 +0000 | [diff] [blame] | 22 | } |
| 23 | |
Chandler Carruth | b3e7219 | 2013-11-22 00:43:29 +0000 | [diff] [blame] | 24 | FunctionAnalysisManagerModuleProxy::Result::~Result() { |
Chandler Carruth | 851a2aa | 2013-11-21 02:11:31 +0000 | [diff] [blame] | 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. |
Chandler Carruth | b07f378 | 2014-03-13 09:50:31 +0000 | [diff] [blame] | 27 | FAM->clear(); |
Chandler Carruth | 851a2aa | 2013-11-21 02:11:31 +0000 | [diff] [blame] | 28 | } |
| 29 | |
Chandler Carruth | b3e7219 | 2013-11-22 00:43:29 +0000 | [diff] [blame] | 30 | bool FunctionAnalysisManagerModuleProxy::Result::invalidate( |
Chandler Carruth | d174ce4 | 2015-01-05 02:47:05 +0000 | [diff] [blame] | 31 | Module &M, const PreservedAnalyses &PA) { |
Chandler Carruth | bceeb22 | 2013-11-22 23:38:07 +0000 | [diff] [blame] | 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())) |
Chandler Carruth | b07f378 | 2014-03-13 09:50:31 +0000 | [diff] [blame] | 37 | FAM->clear(); |
Chandler Carruth | 851a2aa | 2013-11-21 02:11:31 +0000 | [diff] [blame] | 38 | |
| 39 | // Return false to indicate that this result is still a valid proxy. |
| 40 | return false; |
| 41 | } |
Chandler Carruth | c1ff9ed | 2013-11-23 01:25:07 +0000 | [diff] [blame] | 42 | |
| 43 | char ModuleAnalysisManagerFunctionProxy::PassID; |