blob: 69c37f57528c212adaed5219aa1b547974eb731a [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 +000016CGSCCAnalysisManagerModuleProxy::Result
Chandler Carruthd174ce42015-01-05 02:47:05 +000017CGSCCAnalysisManagerModuleProxy::run(Module &M) {
Chandler Carruth572e3402014-04-21 11:12:00 +000018 assert(CGAM->empty() && "CGSCC analyses ran prior to the module proxy!");
19 return Result(*CGAM);
20}
21
22CGSCCAnalysisManagerModuleProxy::Result::~Result() {
Chandler Carruth77b6e472016-02-23 00:05:00 +000023 // CGAM is cleared in a moved from state where there is nothing to do.
24 if (!CGAM)
25 return;
26
Chandler Carruth572e3402014-04-21 11:12:00 +000027 // 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
32bool CGSCCAnalysisManagerModuleProxy::Result::invalidate(
Chandler Carruthd174ce42015-01-05 02:47:05 +000033 Module &M, const PreservedAnalyses &PA) {
Chandler Carruth572e3402014-04-21 11:12:00 +000034 // 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 Carruth572e3402014-04-21 11:12:00 +000045FunctionAnalysisManagerCGSCCProxy::Result
Chandler Carruthd174ce42015-01-05 02:47:05 +000046FunctionAnalysisManagerCGSCCProxy::run(LazyCallGraph::SCC &C) {
Chandler Carruth572e3402014-04-21 11:12:00 +000047 return Result(*FAM);
48}
49
50FunctionAnalysisManagerCGSCCProxy::Result::~Result() {
Chandler Carruth77b6e472016-02-23 00:05:00 +000051 // FAM is cleared in a moved from state where there is nothing to do.
52 if (!FAM)
53 return;
54
Chandler Carruth572e3402014-04-21 11:12:00 +000055 // 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
60bool FunctionAnalysisManagerCGSCCProxy::Result::invalidate(
Chandler Carruthd174ce42015-01-05 02:47:05 +000061 LazyCallGraph::SCC &C, const PreservedAnalyses &PA) {
Chandler Carruth572e3402014-04-21 11:12:00 +000062 // 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}