blob: 4a03002e510b38bdbe19e0d5d3130767bc563794 [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() {
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.
27 CGAM->clear();
28}
29
30bool CGSCCAnalysisManagerModuleProxy::Result::invalidate(
Chandler Carruthd174ce42015-01-05 02:47:05 +000031 Module &M, const PreservedAnalyses &PA) {
Chandler Carruth572e3402014-04-21 11:12:00 +000032 // If this proxy isn't marked as preserved, then we can't even invalidate
33 // individual CGSCC analyses, there may be an invalid set of SCC objects in
34 // the cache making it impossible to incrementally preserve them.
35 // Just clear the entire manager.
36 if (!PA.preserved(ID()))
37 CGAM->clear();
38
39 // Return false to indicate that this result is still a valid proxy.
40 return false;
41}
42
43char ModuleAnalysisManagerCGSCCProxy::PassID;
44
45char FunctionAnalysisManagerCGSCCProxy::PassID;
46
47FunctionAnalysisManagerCGSCCProxy::Result
Chandler Carruthd174ce42015-01-05 02:47:05 +000048FunctionAnalysisManagerCGSCCProxy::run(LazyCallGraph::SCC &C) {
Chandler Carruth572e3402014-04-21 11:12:00 +000049 assert(FAM->empty() && "Function analyses ran prior to the CGSCC proxy!");
50 return Result(*FAM);
51}
52
53FunctionAnalysisManagerCGSCCProxy::Result::~Result() {
54 // Clear out the analysis manager if we're being destroyed -- it means we
55 // didn't even see an invalidate call when we got invalidated.
56 FAM->clear();
57}
58
59bool FunctionAnalysisManagerCGSCCProxy::Result::invalidate(
Chandler Carruthd174ce42015-01-05 02:47:05 +000060 LazyCallGraph::SCC &C, const PreservedAnalyses &PA) {
Chandler Carruth572e3402014-04-21 11:12:00 +000061 // If this proxy isn't marked as preserved, then we can't even invalidate
62 // individual function analyses, there may be an invalid set of Function
63 // objects in the cache making it impossible to incrementally preserve them.
64 // Just clear the entire manager.
65 if (!PA.preserved(ID()))
66 FAM->clear();
67
68 // Return false to indicate that this result is still a valid proxy.
69 return false;
70}
71
72char CGSCCAnalysisManagerFunctionProxy::PassID;