blob: 9cceed4ba875bbf85c7d0e9dbd231bf701b868d1 [file] [log] [blame]
Chandler Carruth572e3402014-04-21 11:12:00 +00001//===- 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
14using namespace llvm;
15
Chandler Carruth572e3402014-04-21 11:12:00 +000016char CGSCCAnalysisManagerModuleProxy::PassID;
17
18CGSCCAnalysisManagerModuleProxy::Result
Chandler Carruthd174ce42015-01-05 02:47:05 +000019CGSCCAnalysisManagerModuleProxy::run(Module &M) {
Chandler Carruth572e3402014-04-21 11:12:00 +000020 assert(CGAM->empty() && "CGSCC analyses ran prior to the module proxy!");
21 return Result(*CGAM);
22}
23
24CGSCCAnalysisManagerModuleProxy::Result::~Result() {
Chandler Carruth77b6e472016-02-23 00:05:00 +000025 // CGAM is cleared in a moved from state where there is nothing to do.
26 if (!CGAM)
27 return;
28
Chandler Carruth572e3402014-04-21 11:12:00 +000029 // 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
34bool CGSCCAnalysisManagerModuleProxy::Result::invalidate(
Chandler Carruthd174ce42015-01-05 02:47:05 +000035 Module &M, const PreservedAnalyses &PA) {
Chandler Carruth572e3402014-04-21 11:12:00 +000036 // 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
47char ModuleAnalysisManagerCGSCCProxy::PassID;
48
49char FunctionAnalysisManagerCGSCCProxy::PassID;
50
51FunctionAnalysisManagerCGSCCProxy::Result
Chandler Carruthd174ce42015-01-05 02:47:05 +000052FunctionAnalysisManagerCGSCCProxy::run(LazyCallGraph::SCC &C) {
Chandler Carruth572e3402014-04-21 11:12:00 +000053 assert(FAM->empty() && "Function analyses ran prior to the CGSCC proxy!");
54 return Result(*FAM);
55}
56
57FunctionAnalysisManagerCGSCCProxy::Result::~Result() {
Chandler Carruth77b6e472016-02-23 00:05:00 +000058 // FAM is cleared in a moved from state where there is nothing to do.
59 if (!FAM)
60 return;
61
Chandler Carruth572e3402014-04-21 11:12:00 +000062 // 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
67bool FunctionAnalysisManagerCGSCCProxy::Result::invalidate(
Chandler Carruthd174ce42015-01-05 02:47:05 +000068 LazyCallGraph::SCC &C, const PreservedAnalyses &PA) {
Chandler Carruth572e3402014-04-21 11:12:00 +000069 // 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
80char CGSCCAnalysisManagerFunctionProxy::PassID;