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