Chandler Carruth | 572e340 | 2014-04-21 11:12:00 +0000 | [diff] [blame] | 1 | //===- CGSCCPassManager.cpp - Managing & running CGSCC 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/Analysis/CGSCCPassManager.h" |
| 11 | #include "llvm/Support/CommandLine.h" |
| 12 | #include "llvm/Support/Debug.h" |
| 13 | |
| 14 | using namespace llvm; |
| 15 | |
Chandler Carruth | 572e340 | 2014-04-21 11:12:00 +0000 | [diff] [blame] | 16 | char CGSCCAnalysisManagerModuleProxy::PassID; |
| 17 | |
| 18 | CGSCCAnalysisManagerModuleProxy::Result |
Chandler Carruth | d174ce4 | 2015-01-05 02:47:05 +0000 | [diff] [blame] | 19 | CGSCCAnalysisManagerModuleProxy::run(Module &M) { |
Chandler Carruth | 572e340 | 2014-04-21 11:12:00 +0000 | [diff] [blame] | 20 | assert(CGAM->empty() && "CGSCC analyses ran prior to the module proxy!"); |
| 21 | return Result(*CGAM); |
| 22 | } |
| 23 | |
| 24 | CGSCCAnalysisManagerModuleProxy::Result::~Result() { |
Chandler Carruth | 77b6e47 | 2016-02-23 00:05:00 +0000 | [diff] [blame^] | 25 | // CGAM is cleared in a moved from state where there is nothing to do. |
| 26 | if (!CGAM) |
| 27 | return; |
| 28 | |
Chandler Carruth | 572e340 | 2014-04-21 11:12:00 +0000 | [diff] [blame] | 29 | // Clear out the analysis manager if we're being destroyed -- it means we |
| 30 | // didn't even see an invalidate call when we got invalidated. |
| 31 | CGAM->clear(); |
| 32 | } |
| 33 | |
| 34 | bool CGSCCAnalysisManagerModuleProxy::Result::invalidate( |
Chandler Carruth | d174ce4 | 2015-01-05 02:47:05 +0000 | [diff] [blame] | 35 | Module &M, const PreservedAnalyses &PA) { |
Chandler Carruth | 572e340 | 2014-04-21 11:12:00 +0000 | [diff] [blame] | 36 | // If this proxy isn't marked as preserved, then we can't even invalidate |
| 37 | // individual CGSCC analyses, there may be an invalid set of SCC objects in |
| 38 | // the cache making it impossible to incrementally preserve them. |
| 39 | // Just clear the entire manager. |
| 40 | if (!PA.preserved(ID())) |
| 41 | CGAM->clear(); |
| 42 | |
| 43 | // Return false to indicate that this result is still a valid proxy. |
| 44 | return false; |
| 45 | } |
| 46 | |
| 47 | char ModuleAnalysisManagerCGSCCProxy::PassID; |
| 48 | |
| 49 | char FunctionAnalysisManagerCGSCCProxy::PassID; |
| 50 | |
| 51 | FunctionAnalysisManagerCGSCCProxy::Result |
Chandler Carruth | d174ce4 | 2015-01-05 02:47:05 +0000 | [diff] [blame] | 52 | FunctionAnalysisManagerCGSCCProxy::run(LazyCallGraph::SCC &C) { |
Chandler Carruth | 572e340 | 2014-04-21 11:12:00 +0000 | [diff] [blame] | 53 | assert(FAM->empty() && "Function analyses ran prior to the CGSCC proxy!"); |
| 54 | return Result(*FAM); |
| 55 | } |
| 56 | |
| 57 | FunctionAnalysisManagerCGSCCProxy::Result::~Result() { |
Chandler Carruth | 77b6e47 | 2016-02-23 00:05:00 +0000 | [diff] [blame^] | 58 | // FAM is cleared in a moved from state where there is nothing to do. |
| 59 | if (!FAM) |
| 60 | return; |
| 61 | |
Chandler Carruth | 572e340 | 2014-04-21 11:12:00 +0000 | [diff] [blame] | 62 | // Clear out the analysis manager if we're being destroyed -- it means we |
| 63 | // didn't even see an invalidate call when we got invalidated. |
| 64 | FAM->clear(); |
| 65 | } |
| 66 | |
| 67 | bool FunctionAnalysisManagerCGSCCProxy::Result::invalidate( |
Chandler Carruth | d174ce4 | 2015-01-05 02:47:05 +0000 | [diff] [blame] | 68 | LazyCallGraph::SCC &C, const PreservedAnalyses &PA) { |
Chandler Carruth | 572e340 | 2014-04-21 11:12:00 +0000 | [diff] [blame] | 69 | // If this proxy isn't marked as preserved, then we can't even invalidate |
| 70 | // individual function analyses, there may be an invalid set of Function |
| 71 | // objects in the cache making it impossible to incrementally preserve them. |
| 72 | // Just clear the entire manager. |
| 73 | if (!PA.preserved(ID())) |
| 74 | FAM->clear(); |
| 75 | |
| 76 | // Return false to indicate that this result is still a valid proxy. |
| 77 | return false; |
| 78 | } |
| 79 | |
| 80 | char CGSCCAnalysisManagerFunctionProxy::PassID; |