1 //===- CGSCCPassManager.cpp - Managing & running CGSCC passes -------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Analysis/CGSCCPassManager.h"
11 #include "llvm/Support/CommandLine.h"
12 #include "llvm/Support/Debug.h"
17 DebugPM("debug-cgscc-pass-manager", cl::Hidden,
18 cl::desc("Print CGSCC pass management debugging information"));
20 PreservedAnalyses CGSCCPassManager::run(LazyCallGraph::SCC &C,
21 CGSCCAnalysisManager *AM) {
22 PreservedAnalyses PA = PreservedAnalyses::all();
25 dbgs() << "Starting CGSCC pass manager run.\n";
27 for (unsigned Idx = 0, Size = Passes.size(); Idx != Size; ++Idx) {
29 dbgs() << "Running CGSCC pass: " << Passes[Idx]->name() << "\n";
31 PreservedAnalyses PassPA = Passes[Idx]->run(C, AM);
33 // If we have an active analysis manager at this level we want to ensure we
34 // update it as each pass runs and potentially invalidates analyses. We
35 // also update the preserved set of analyses based on what analyses we have
36 // already handled the invalidation for here and don't need to invalidate
39 PassPA = AM->invalidate(C, std::move(PassPA));
41 // Finally, we intersect the final preserved analyses to compute the
42 // aggregate preserved set for this pass manager.
43 PA.intersect(std::move(PassPA));
47 dbgs() << "Finished CGSCC pass manager run.\n";
52 char CGSCCAnalysisManagerModuleProxy::PassID;
54 CGSCCAnalysisManagerModuleProxy::Result
55 CGSCCAnalysisManagerModuleProxy::run(Module &M) {
56 assert(CGAM->empty() && "CGSCC analyses ran prior to the module proxy!");
60 CGSCCAnalysisManagerModuleProxy::Result::~Result() {
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.
66 bool CGSCCAnalysisManagerModuleProxy::Result::invalidate(
67 Module &M, const PreservedAnalyses &PA) {
68 // If this proxy isn't marked as preserved, then we can't even invalidate
69 // individual CGSCC analyses, there may be an invalid set of SCC objects in
70 // the cache making it impossible to incrementally preserve them.
71 // Just clear the entire manager.
72 if (!PA.preserved(ID()))
75 // Return false to indicate that this result is still a valid proxy.
79 char ModuleAnalysisManagerCGSCCProxy::PassID;
81 char FunctionAnalysisManagerCGSCCProxy::PassID;
83 FunctionAnalysisManagerCGSCCProxy::Result
84 FunctionAnalysisManagerCGSCCProxy::run(LazyCallGraph::SCC &C) {
85 assert(FAM->empty() && "Function analyses ran prior to the CGSCC proxy!");
89 FunctionAnalysisManagerCGSCCProxy::Result::~Result() {
90 // Clear out the analysis manager if we're being destroyed -- it means we
91 // didn't even see an invalidate call when we got invalidated.
95 bool FunctionAnalysisManagerCGSCCProxy::Result::invalidate(
96 LazyCallGraph::SCC &C, const PreservedAnalyses &PA) {
97 // If this proxy isn't marked as preserved, then we can't even invalidate
98 // individual function analyses, there may be an invalid set of Function
99 // objects in the cache making it impossible to incrementally preserve them.
100 // Just clear the entire manager.
101 if (!PA.preserved(ID()))
104 // Return false to indicate that this result is still a valid proxy.
108 char CGSCCAnalysisManagerFunctionProxy::PassID;