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 
16 char CGSCCAnalysisManagerModuleProxy::PassID;
17 
18 CGSCCAnalysisManagerModuleProxy::Result
19 CGSCCAnalysisManagerModuleProxy::run(Module &M) {
20   assert(CGAM->empty() && "CGSCC analyses ran prior to the module proxy!");
21   return Result(*CGAM);
22 }
23 
24 CGSCCAnalysisManagerModuleProxy::Result::~Result() {
25   // CGAM is cleared in a moved from state where there is nothing to do.
26   if (!CGAM)
27     return;
28 
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(
35     Module &M, const PreservedAnalyses &PA) {
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
52 FunctionAnalysisManagerCGSCCProxy::run(LazyCallGraph::SCC &C) {
53   return Result(*FAM);
54 }
55 
56 FunctionAnalysisManagerCGSCCProxy::Result::~Result() {
57   // FAM is cleared in a moved from state where there is nothing to do.
58   if (!FAM)
59     return;
60 
61   // Clear out the analysis manager if we're being destroyed -- it means we
62   // didn't even see an invalidate call when we got invalidated.
63   FAM->clear();
64 }
65 
66 bool FunctionAnalysisManagerCGSCCProxy::Result::invalidate(
67     LazyCallGraph::SCC &C, const PreservedAnalyses &PA) {
68   // If this proxy isn't marked as preserved, then we can't even invalidate
69   // individual function analyses, there may be an invalid set of Function
70   // objects in the cache making it impossible to incrementally preserve them.
71   // Just clear the entire manager.
72   if (!PA.preserved(ID()))
73     FAM->clear();
74 
75   // Return false to indicate that this result is still a valid proxy.
76   return false;
77 }
78 
79 char CGSCCAnalysisManagerFunctionProxy::PassID;
80