llvm.org GIT mirror llvm / 6b1894a
[PM] Fold all three analysis managers into a single AnalysisManager template. This consolidates three copies of nearly the same core logic. It adds "complexity" to the ModuleAnalysisManager in that it makes it possible to share a ModuleAnalysisManager across multiple modules... But it does so by deleting *all of the code*, so I'm OK with that. This will naturally make fixing bugs in this code much simpler, etc. The only down side here is that we have to use 'typename' and 'this->' in various places, and the implementation is lifted into the header. I'll take that for the code size reduction. The convenient names are still typedef-ed and used throughout so that users can largely ignore this aspect of the implementation. The follow-up change to this will do the exact same refactoring for the PassManagers. =D It turns out that the interesting different code is almost entirely in the adaptors. At the end, that should be essentially all that is left. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225757 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 4 years ago
8 changed file(s) with 232 addition(s) and 528 deletion(s). Raw diff Collapse all Expand all
2525
2626 namespace llvm {
2727
28 class CGSCCAnalysisManager;
28 /// \brief The CGSCC analysis manager.
29 ///
30 /// See the documentation for the AnalysisManager template for detail
31 /// documentation. This typedef serves as a convenient way to refer to this
32 /// construct in the adaptors and proxies used to integrate this into the larger
33 /// pass manager infrastructure.
34 typedef AnalysisManager CGSCCAnalysisManager;
2935
3036 class CGSCCPassManager {
3137 public:
6470 CGSCCPassManager &operator=(const CGSCCPassManager &) LLVM_DELETED_FUNCTION;
6571
6672 std::vector> Passes;
67 };
68
69 /// \brief A function analysis manager to coordinate and cache analyses run over
70 /// a module.
71 class CGSCCAnalysisManager
72 : public detail::AnalysisManagerBase
73 LazyCallGraph::SCC> {
74 friend class detail::AnalysisManagerBase
75 LazyCallGraph::SCC>;
76 typedef detail::AnalysisManagerBase
77 BaseT;
78 typedef BaseT::ResultConceptT ResultConceptT;
79 typedef BaseT::PassConceptT PassConceptT;
80
81 public:
82 // Most public APIs are inherited from the CRTP base class.
83
84 // We have to explicitly define all the special member functions because MSVC
85 // refuses to generate them.
86 CGSCCAnalysisManager() {}
87 CGSCCAnalysisManager(CGSCCAnalysisManager &&Arg)
88 : BaseT(std::move(static_cast(Arg))),
89 CGSCCAnalysisResults(std::move(Arg.CGSCCAnalysisResults)) {}
90 CGSCCAnalysisManager &operator=(CGSCCAnalysisManager &&RHS) {
91 BaseT::operator=(std::move(static_cast(RHS)));
92 CGSCCAnalysisResults = std::move(RHS.CGSCCAnalysisResults);
93 return *this;
94 }
95
96 /// \brief Returns true if the analysis manager has an empty results cache.
97 bool empty() const;
98
99 /// \brief Clear the function analysis result cache.
100 ///
101 /// This routine allows cleaning up when the set of functions itself has
102 /// potentially changed, and thus we can't even look up a a result and
103 /// invalidate it directly. Notably, this does *not* call invalidate
104 /// functions as there is nothing to be done for them.
105 void clear();
106
107 private:
108 CGSCCAnalysisManager(const CGSCCAnalysisManager &) LLVM_DELETED_FUNCTION;
109 CGSCCAnalysisManager &
110 operator=(const CGSCCAnalysisManager &) LLVM_DELETED_FUNCTION;
111
112 /// \brief Get a function pass result, running the pass if necessary.
113 ResultConceptT &getResultImpl(void *PassID, LazyCallGraph::SCC &C);
114
115 /// \brief Get a cached function pass result or return null.
116 ResultConceptT *getCachedResultImpl(void *PassID,
117 LazyCallGraph::SCC &C) const;
118
119 /// \brief Invalidate a function pass result.
120 void invalidateImpl(void *PassID, LazyCallGraph::SCC &C);
121
122 /// \brief Invalidate the results for a function..
123 PreservedAnalyses invalidateImpl(LazyCallGraph::SCC &C, PreservedAnalyses PA);
124
125 /// \brief List of function analysis pass IDs and associated concept pointers.
126 ///
127 /// Requires iterators to be valid across appending new entries and arbitrary
128 /// erases. Provides both the pass ID and concept pointer such that it is
129 /// half of a bijection and provides storage for the actual result concept.
130 typedef std::list
131 void *,
132 std::unique_ptr>>>
133 CGSCCAnalysisResultListT;
134
135 /// \brief Map type from function pointer to our custom list type.
136 typedef DenseMap
137 CGSCCAnalysisResultListMapT;
138
139 /// \brief Map from function to a list of function analysis results.
140 ///
141 /// Provides linear time removal of all analysis results for a function and
142 /// the ultimate storage for a particular cached analysis result.
143 CGSCCAnalysisResultListMapT CGSCCAnalysisResultLists;
144
145 /// \brief Map type from a pair of analysis ID and function pointer to an
146 /// iterator into a particular result list.
147 typedef DenseMap,
148 CGSCCAnalysisResultListT::iterator> CGSCCAnalysisResultMapT;
149
150 /// \brief Map from an analysis ID and function to a particular cached
151 /// analysis result.
152 CGSCCAnalysisResultMapT CGSCCAnalysisResults;
15373 };
15474
15575 /// \brief A module analysis which acts as a proxy for a CGSCC analysis
4545 #include "llvm/IR/BasicBlock.h"
4646 #include "llvm/IR/Function.h"
4747 #include "llvm/IR/Module.h"
48 #include "llvm/IR/PassManager.h"
4849 #include "llvm/Support/Allocator.h"
4950 #include
5051
5152 namespace llvm {
52 class ModuleAnalysisManager;
5353 class PreservedAnalyses;
5454 class raw_ostream;
5555
247247 /// @returns the module identifier as a string
248248 const std::string &getModuleIdentifier() const { return ModuleID; }
249249
250 /// \brief Get a short "name" for the module.
251 ///
252 /// This is useful for debugging or logging. It is essentially a convenience
253 /// wrapper around getModuleIdentifier().
254 StringRef getName() const { return ModuleID; }
255
250256 /// Get the data layout string for the module's target platform. This is
251257 /// equivalent to getDataLayout()->getStringRepresentation().
252258 const std::string &getDataLayoutStr() const { return DataLayoutStr; }
4343 #include "llvm/IR/Function.h"
4444 #include "llvm/IR/Module.h"
4545 #include "llvm/IR/PassManagerInternal.h"
46 #include "llvm/Support/CommandLine.h"
47 #include "llvm/Support/Debug.h"
4648 #include "llvm/Support/type_traits.h"
4749 #include
4850 #include
5254
5355 class Module;
5456 class Function;
57
58 namespace detail {
59
60 // Declare our debug option here so we can refer to it from templates.
61 extern cl::opt DebugPM;
62
63 } // End detail namespace
5564
5665 /// \brief An abstract set of preserved analyses following a transformation pass
5766 /// run.
159168 SmallPtrSet PreservedPassIDs;
160169 };
161170
162 // We define the pass managers prior to the analysis managers that they use.
163 class ModuleAnalysisManager;
171 // Forward declare the analysis manager template and two typedefs used in the
172 // pass managers.
173 template class AnalysisManager;
174 typedef AnalysisManager ModuleAnalysisManager;
175 typedef AnalysisManager FunctionAnalysisManager;
164176
165177 /// \brief Manages a sequence of passes over Modules of IR.
166178 ///
216228
217229 std::vector> Passes;
218230 };
219
220 // We define the pass managers prior to the analysis managers that they use.
221 class FunctionAnalysisManager;
222231
223232 /// \brief Manages a sequence of passes over a Function of IR.
224233 ///
296305 /// - invalidateImpl
297306 ///
298307 /// The details of the call pattern are within.
308 ///
309 /// Note that there is also a generic analysis manager template which implements
310 /// the above required functions along with common datastructures used for
311 /// managing analyses. This base class is factored so that if you need to
312 /// customize the handling of a specific IR unit, you can do so without
313 /// replicating *all* of the boilerplate.
299314 template class AnalysisManagerBase {
300315 DerivedT *derived_this() { return static_cast(this); }
301316 const DerivedT *derived_this() const {
418433
419434 } // End namespace detail
420435
421 /// \brief A module analysis pass manager with lazy running and caching of
436 /// \brief A generic analysis pass manager with lazy running and caching of
422437 /// results.
423 class ModuleAnalysisManager
424 : public detail::AnalysisManagerBase {
425 friend class detail::AnalysisManagerBase;
426 typedef detail::AnalysisManagerBase BaseT;
427 typedef BaseT::ResultConceptT ResultConceptT;
428 typedef BaseT::PassConceptT PassConceptT;
438 ///
439 /// This analysis manager can be used for any IR unit where the address of the
440 /// IR unit sufficies as its identity. It manages the cache for a unit of IR via
441 /// the address of each unit of IR cached.
442 template
443 class AnalysisManager
444 : public detail::AnalysisManagerBase, IRUnitT> {
445 friend class detail::AnalysisManagerBase, IRUnitT>;
446 typedef detail::AnalysisManagerBase, IRUnitT> BaseT;
447 typedef typename BaseT::ResultConceptT ResultConceptT;
448 typedef typename BaseT::PassConceptT PassConceptT;
429449
430450 public:
451 // Most public APIs are inherited from the CRTP base class.
452
431453 // We have to explicitly define all the special member functions because MSVC
432454 // refuses to generate them.
433 ModuleAnalysisManager() {}
434 ModuleAnalysisManager(ModuleAnalysisManager &&Arg)
455 AnalysisManager() {}
456 AnalysisManager(AnalysisManager &&Arg)
435457 : BaseT(std::move(static_cast(Arg))),
436 ModuleAnalysisResults(std::move(Arg.ModuleAnalysisResults)) {}
437 ModuleAnalysisManager &operator=(ModuleAnalysisManager &&RHS) {
458 AnalysisResults(std::move(Arg.AnalysisResults)) {}
459 AnalysisManager &operator=(AnalysisManager &&RHS) {
438460 BaseT::operator=(std::move(static_cast(RHS)));
439 ModuleAnalysisResults = std::move(RHS.ModuleAnalysisResults);
461 AnalysisResults = std::move(RHS.AnalysisResults);
440462 return *this;
441463 }
442464
465 /// \brief Returns true if the analysis manager has an empty results cache.
466 bool empty() const {
467 assert(AnalysisResults.empty() == AnalysisResultLists.empty() &&
468 "The storage and index of analysis results disagree on how many "
469 "there are!");
470 return AnalysisResults.empty();
471 }
472
473 /// \brief Clear the analysis result cache.
474 ///
475 /// This routine allows cleaning up when the set of IR units itself has
476 /// potentially changed, and thus we can't even look up a a result and
477 /// invalidate it directly. Notably, this does *not* call invalidate functions
478 /// as there is nothing to be done for them.
479 void clear() {
480 AnalysisResults.clear();
481 AnalysisResultLists.clear();
482 }
483
443484 private:
444 ModuleAnalysisManager(const ModuleAnalysisManager &) LLVM_DELETED_FUNCTION;
445 ModuleAnalysisManager &
446 operator=(const ModuleAnalysisManager &) LLVM_DELETED_FUNCTION;
447
448 /// \brief Get a module pass result, running the pass if necessary.
449 ResultConceptT &getResultImpl(void *PassID, Module &M);
450
451 /// \brief Get a cached module pass result or return null.
452 ResultConceptT *getCachedResultImpl(void *PassID, Module &M) const;
453
454 /// \brief Invalidate a module pass result.
455 void invalidateImpl(void *PassID, Module &M);
456
457 /// \brief Invalidate results across a module.
458 PreservedAnalyses invalidateImpl(Module &M, PreservedAnalyses PA);
459
460 /// \brief Map type from module analysis pass ID to pass result concept
461 /// pointer.
462 typedef DenseMap
463 std::unique_ptr>>
464 ModuleAnalysisResultMapT;
465
466 /// \brief Cache of computed module analysis results for this module.
467 ModuleAnalysisResultMapT ModuleAnalysisResults;
468 };
469
470 /// \brief A function analysis manager to coordinate and cache analyses run over
471 /// a module.
472 class FunctionAnalysisManager
473 : public detail::AnalysisManagerBase {
474 friend class detail::AnalysisManagerBase;
475 typedef detail::AnalysisManagerBase BaseT;
476 typedef BaseT::ResultConceptT ResultConceptT;
477 typedef BaseT::PassConceptT PassConceptT;
478
479 public:
480 // Most public APIs are inherited from the CRTP base class.
481
482 // We have to explicitly define all the special member functions because MSVC
483 // refuses to generate them.
484 FunctionAnalysisManager() {}
485 FunctionAnalysisManager(FunctionAnalysisManager &&Arg)
486 : BaseT(std::move(static_cast(Arg))),
487 FunctionAnalysisResults(std::move(Arg.FunctionAnalysisResults)) {}
488 FunctionAnalysisManager &operator=(FunctionAnalysisManager &&RHS) {
489 BaseT::operator=(std::move(static_cast(RHS)));
490 FunctionAnalysisResults = std::move(RHS.FunctionAnalysisResults);
491 return *this;
492 }
493
494 /// \brief Returns true if the analysis manager has an empty results cache.
495 bool empty() const;
496
497 /// \brief Clear the function analysis result cache.
498 ///
499 /// This routine allows cleaning up when the set of functions itself has
500 /// potentially changed, and thus we can't even look up a a result and
501 /// invalidate it directly. Notably, this does *not* call invalidate
502 /// functions as there is nothing to be done for them.
503 void clear();
504
505 private:
506 FunctionAnalysisManager(const FunctionAnalysisManager &)
507 LLVM_DELETED_FUNCTION;
508 FunctionAnalysisManager &
509 operator=(const FunctionAnalysisManager &) LLVM_DELETED_FUNCTION;
510
511 /// \brief Get a function pass result, running the pass if necessary.
512 ResultConceptT &getResultImpl(void *PassID, Function &F);
513
514 /// \brief Get a cached function pass result or return null.
515 ResultConceptT *getCachedResultImpl(void *PassID, Function &F) const;
485 AnalysisManager(const AnalysisManager &) LLVM_DELETED_FUNCTION;
486 AnalysisManager &operator=(const AnalysisManager &) LLVM_DELETED_FUNCTION;
487
488 /// \brief Get an analysis result, running the pass if necessary.
489 ResultConceptT &getResultImpl(void *PassID, IRUnitT &IR) {
490 typename AnalysisResultMapT::iterator RI;
491 bool Inserted;
492 std::tie(RI, Inserted) = AnalysisResults.insert(std::make_pair(
493 std::make_pair(PassID, &IR), typename AnalysisResultListT::iterator()));
494
495 // If we don't have a cached result for this function, look up the pass and
496 // run it to produce a result, which we then add to the cache.
497 if (Inserted) {
498 auto &P = this->lookupPass(PassID);
499 if (detail::DebugPM)
500 dbgs() << "Running analysis: " << P.name() << "\n";
501 AnalysisResultListT &ResultList = AnalysisResultLists[&IR];
502 ResultList.emplace_back(PassID, P.run(IR, this));
503 RI->second = std::prev(ResultList.end());
504 }
505
506 return *RI->second->second;
507 }
508
509 /// \brief Get a cached analysis result or return null.
510 ResultConceptT *getCachedResultImpl(void *PassID, IRUnitT &IR) const {
511 typename AnalysisResultMapT::const_iterator RI =
512 AnalysisResults.find(std::make_pair(PassID, &IR));
513 return RI == AnalysisResults.end() ? nullptr : &*RI->second->second;
514 }
516515
517516 /// \brief Invalidate a function pass result.
518 void invalidateImpl(void *PassID, Function &F);
517 void invalidateImpl(void *PassID, IRUnitT &IR) {
518 typename AnalysisResultMapT::iterator RI =
519 AnalysisResults.find(std::make_pair(PassID, &IR));
520 if (RI == AnalysisResults.end())
521 return;
522
523 if (detail::DebugPM)
524 dbgs() << "Invalidating analysis: " << this->lookupPass(PassID).name()
525 << "\n";
526 AnalysisResultLists[&IR].erase(RI->second);
527 AnalysisResults.erase(RI);
528 }
519529
520530 /// \brief Invalidate the results for a function..
521 PreservedAnalyses invalidateImpl(Function &F, PreservedAnalyses PA);
531 PreservedAnalyses invalidateImpl(IRUnitT &IR, PreservedAnalyses PA) {
532 // Short circuit for a common case of all analyses being preserved.
533 if (PA.areAllPreserved())
534 return std::move(PA);
535
536 if (detail::DebugPM)
537 dbgs() << "Invalidating all non-preserved analyses for: "
538 << IR.getName() << "\n";
539
540 // Clear all the invalidated results associated specifically with this
541 // function.
542 SmallVector InvalidatedPassIDs;
543 AnalysisResultListT &ResultsList = AnalysisResultLists[&IR];
544 for (typename AnalysisResultListT::iterator I = ResultsList.begin(),
545 E = ResultsList.end();
546 I != E;) {
547 void *PassID = I->first;
548
549 // Pass the invalidation down to the pass itself to see if it thinks it is
550 // necessary. The analysis pass can return false if no action on the part
551 // of the analysis manager is required for this invalidation event.
552 if (I->second->invalidate(IR, PA)) {
553 if (detail::DebugPM)
554 dbgs() << "Invalidating analysis: " << this->lookupPass(PassID).name()
555 << "\n";
556
557 InvalidatedPassIDs.push_back(I->first);
558 I = ResultsList.erase(I);
559 } else {
560 ++I;
561 }
562
563 // After handling each pass, we mark it as preserved. Once we've
564 // invalidated any stale results, the rest of the system is allowed to
565 // start preserving this analysis again.
566 PA.preserve(PassID);
567 }
568 while (!InvalidatedPassIDs.empty())
569 AnalysisResults.erase(
570 std::make_pair(InvalidatedPassIDs.pop_back_val(), &IR));
571 if (ResultsList.empty())
572 AnalysisResultLists.erase(&IR);
573
574 return std::move(PA);
575 }
522576
523577 /// \brief List of function analysis pass IDs and associated concept pointers.
524578 ///
526580 /// erases. Provides both the pass ID and concept pointer such that it is
527581 /// half of a bijection and provides storage for the actual result concept.
528582 typedef std::list
529 void *, std::unique_ptr>>>
530 FunctionAnalysisResultListT;
583 void *, std::unique_ptr>>>
584 AnalysisResultListT;
531585
532586 /// \brief Map type from function pointer to our custom list type.
533 typedef DenseMap
534 FunctionAnalysisResultListMapT;
587 typedef DenseMap AnalysisResultListMapT;
535588
536589 /// \brief Map from function to a list of function analysis results.
537590 ///
538591 /// Provides linear time removal of all analysis results for a function and
539592 /// the ultimate storage for a particular cached analysis result.
540 FunctionAnalysisResultListMapT FunctionAnalysisResultLists;
593 AnalysisResultListMapT AnalysisResultLists;
541594
542595 /// \brief Map type from a pair of analysis ID and function pointer to an
543596 /// iterator into a particular result list.
544 typedef DenseMap,
545 FunctionAnalysisResultListT::iterator>
546 FunctionAnalysisResultMapT;
597 typedef DenseMap,
598 typename AnalysisResultListT::iterator> AnalysisResultMapT;
547599
548600 /// \brief Map from an analysis ID and function to a particular cached
549601 /// analysis result.
550 FunctionAnalysisResultMapT FunctionAnalysisResults;
602 AnalysisResultMapT AnalysisResults;
551603 };
552604
553605 /// \brief A module analysis which acts as a proxy for a function analysis
4646 dbgs() << "Finished CGSCC pass manager run.\n";
4747
4848 return PA;
49 }
50
51 bool CGSCCAnalysisManager::empty() const {
52 assert(CGSCCAnalysisResults.empty() == CGSCCAnalysisResultLists.empty() &&
53 "The storage and index of analysis results disagree on how many there "
54 "are!");
55 return CGSCCAnalysisResults.empty();
56 }
57
58 void CGSCCAnalysisManager::clear() {
59 CGSCCAnalysisResults.clear();
60 CGSCCAnalysisResultLists.clear();
61 }
62
63 CGSCCAnalysisManager::ResultConceptT &
64 CGSCCAnalysisManager::getResultImpl(void *PassID, LazyCallGraph::SCC &C) {
65 CGSCCAnalysisResultMapT::iterator RI;
66 bool Inserted;
67 std::tie(RI, Inserted) = CGSCCAnalysisResults.insert(std::make_pair(
68 std::make_pair(PassID, &C), CGSCCAnalysisResultListT::iterator()));
69
70 // If we don't have a cached result for this function, look up the pass and
71 // run it to produce a result, which we then add to the cache.
72 if (Inserted) {
73 auto &P = lookupPass(PassID);
74 if (DebugPM)
75 dbgs() << "Running CGSCC analysis: " << P.name() << "\n";
76 CGSCCAnalysisResultListT &ResultList = CGSCCAnalysisResultLists[&C];
77 ResultList.emplace_back(PassID, P.run(C, this));
78 RI->second = std::prev(ResultList.end());
79 }
80
81 return *RI->second->second;
82 }
83
84 CGSCCAnalysisManager::ResultConceptT *
85 CGSCCAnalysisManager::getCachedResultImpl(void *PassID,
86 LazyCallGraph::SCC &C) const {
87 CGSCCAnalysisResultMapT::const_iterator RI =
88 CGSCCAnalysisResults.find(std::make_pair(PassID, &C));
89 return RI == CGSCCAnalysisResults.end() ? nullptr : &*RI->second->second;
90 }
91
92 void CGSCCAnalysisManager::invalidateImpl(void *PassID, LazyCallGraph::SCC &C) {
93 CGSCCAnalysisResultMapT::iterator RI =
94 CGSCCAnalysisResults.find(std::make_pair(PassID, &C));
95 if (RI == CGSCCAnalysisResults.end())
96 return;
97
98 if (DebugPM)
99 dbgs() << "Invalidating CGSCC analysis: " << lookupPass(PassID).name()
100 << "\n";
101 CGSCCAnalysisResultLists[&C].erase(RI->second);
102 CGSCCAnalysisResults.erase(RI);
103 }
104
105 PreservedAnalyses CGSCCAnalysisManager::invalidateImpl(LazyCallGraph::SCC &C,
106 PreservedAnalyses PA) {
107 // Short circuit for a common case of all analyses being preserved.
108 if (PA.areAllPreserved())
109 return std::move(PA);
110
111 if (DebugPM)
112 dbgs() << "Invalidating all non-preserved analyses for SCC: " << C.getName()
113 << "\n";
114
115 // Clear all the invalidated results associated specifically with this
116 // function.
117 SmallVector InvalidatedPassIDs;
118 CGSCCAnalysisResultListT &ResultsList = CGSCCAnalysisResultLists[&C];
119 for (CGSCCAnalysisResultListT::iterator I = ResultsList.begin(),
120 E = ResultsList.end();
121 I != E;) {
122 void *PassID = I->first;
123
124 // Pass the invalidation down to the pass itself to see if it thinks it is
125 // necessary. The analysis pass can return false if no action on the part
126 // of the analysis manager is required for this invalidation event.
127 if (I->second->invalidate(C, PA)) {
128 if (DebugPM)
129 dbgs() << "Invalidating CGSCC analysis: " << lookupPass(PassID).name()
130 << "\n";
131
132 InvalidatedPassIDs.push_back(I->first);
133 I = ResultsList.erase(I);
134 } else {
135 ++I;
136 }
137
138 // After handling each pass, we mark it as preserved. Once we've
139 // invalidated any stale results, the rest of the system is allowed to
140 // start preserving this analysis again.
141 PA.preserve(PassID);
142 }
143 while (!InvalidatedPassIDs.empty())
144 CGSCCAnalysisResults.erase(
145 std::make_pair(InvalidatedPassIDs.pop_back_val(), &C));
146 CGSCCAnalysisResultLists.erase(&C);
147
148 return std::move(PA);
14949 }
15050
15151 char CGSCCAnalysisManagerModuleProxy::PassID;
99 #include "llvm/ADT/STLExtras.h"
1010 #include "llvm/IR/LLVMContext.h"
1111 #include "llvm/IR/PassManager.h"
12 #include "llvm/Support/CommandLine.h"
13 #include "llvm/Support/Debug.h"
1412
1513 using namespace llvm;
14 using llvm::detail::DebugPM;
1615
17 static cl::opt
18 DebugPM("debug-pass-manager", cl::Hidden,
19 cl::desc("Print pass management debugging information"));
16 cl::opt llvm::detail::DebugPM(
17 "debug-pass-manager", cl::Hidden,
18 cl::desc("Print pass management debugging information"));
2019
2120 PreservedAnalyses ModulePassManager::run(Module &M, ModuleAnalysisManager *AM) {
2221 PreservedAnalyses PA = PreservedAnalyses::all();
4948 dbgs() << "Finished module pass manager run.\n";
5049
5150 return PA;
52 }
53
54 ModuleAnalysisManager::ResultConceptT &
55 ModuleAnalysisManager::getResultImpl(void *PassID, Module &M) {
56 ModuleAnalysisResultMapT::iterator RI;
57 bool Inserted;
58 std::tie(RI, Inserted) = ModuleAnalysisResults.insert(std::make_pair(
59 PassID, std::unique_ptr>()));
60
61 // If we don't have a cached result for this module, look up the pass and run
62 // it to produce a result, which we then add to the cache.
63 if (Inserted) {
64 auto &P = lookupPass(PassID);
65 if (DebugPM)
66 dbgs() << "Running module analysis: " << P.name() << "\n";
67 RI->second = P.run(M, this);
68 }
69
70 return *RI->second;
71 }
72
73 ModuleAnalysisManager::ResultConceptT *
74 ModuleAnalysisManager::getCachedResultImpl(void *PassID, Module &M) const {
75 ModuleAnalysisResultMapT::const_iterator RI =
76 ModuleAnalysisResults.find(PassID);
77 return RI == ModuleAnalysisResults.end() ? nullptr : &*RI->second;
78 }
79
80 void ModuleAnalysisManager::invalidateImpl(void *PassID, Module &M) {
81 if (DebugPM)
82 dbgs() << "Invalidating module analysis: " << lookupPass(PassID).name()
83 << "\n";
84 ModuleAnalysisResults.erase(PassID);
85 }
86
87 PreservedAnalyses ModuleAnalysisManager::invalidateImpl(Module &M,
88 PreservedAnalyses PA) {
89 // Short circuit for a common case of all analyses being preserved.
90 if (PA.areAllPreserved())
91 return std::move(PA);
92
93 if (DebugPM)
94 dbgs() << "Invalidating all non-preserved analyses for module: "
95 << M.getModuleIdentifier() << "\n";
96
97 // FIXME: This is a total hack based on the fact that erasure doesn't
98 // invalidate iteration for DenseMap.
99 for (ModuleAnalysisResultMapT::iterator I = ModuleAnalysisResults.begin(),
100 E = ModuleAnalysisResults.end();
101 I != E; ++I) {
102 void *PassID = I->first;
103
104 // Pass the invalidation down to the pass itself to see if it thinks it is
105 // necessary. The analysis pass can return false if no action on the part
106 // of the analysis manager is required for this invalidation event.
107 if (I->second->invalidate(M, PA)) {
108 if (DebugPM)
109 dbgs() << "Invalidating module analysis: " << lookupPass(PassID).name()
110 << "\n";
111
112 ModuleAnalysisResults.erase(I);
113 }
114
115 // After handling each pass, we mark it as preserved. Once we've
116 // invalidated any stale results, the rest of the system is allowed to
117 // start preserving this analysis again.
118 PA.preserve(PassID);
119 }
120
121 return std::move(PA);
12251 }
12352
12453 PreservedAnalyses FunctionPassManager::run(Function &F,
15584 return PA;
15685 }
15786
158 bool FunctionAnalysisManager::empty() const {
159 assert(FunctionAnalysisResults.empty() ==
160 FunctionAnalysisResultLists.empty() &&
161 "The storage and index of analysis results disagree on how many there "
162 "are!");
163 return FunctionAnalysisResults.empty();
164 }
165
166 void FunctionAnalysisManager::clear() {
167 FunctionAnalysisResults.clear();
168 FunctionAnalysisResultLists.clear();
169 }
170
171 FunctionAnalysisManager::ResultConceptT &
172 FunctionAnalysisManager::getResultImpl(void *PassID, Function &F) {
173 FunctionAnalysisResultMapT::iterator RI;
174 bool Inserted;
175 std::tie(RI, Inserted) = FunctionAnalysisResults.insert(std::make_pair(
176 std::make_pair(PassID, &F), FunctionAnalysisResultListT::iterator()));
177
178 // If we don't have a cached result for this function, look up the pass and
179 // run it to produce a result, which we then add to the cache.
180 if (Inserted) {
181 auto &P = lookupPass(PassID);
182 if (DebugPM)
183 dbgs() << "Running function analysis: " << P.name() << "\n";
184 FunctionAnalysisResultListT &ResultList = FunctionAnalysisResultLists[&F];
185 ResultList.emplace_back(PassID, P.run(F, this));
186 RI->second = std::prev(ResultList.end());
187 }
188
189 return *RI->second->second;
190 }
191
192 FunctionAnalysisManager::ResultConceptT *
193 FunctionAnalysisManager::getCachedResultImpl(void *PassID, Function &F) const {
194 FunctionAnalysisResultMapT::const_iterator RI =
195 FunctionAnalysisResults.find(std::make_pair(PassID, &F));
196 return RI == FunctionAnalysisResults.end() ? nullptr : &*RI->second->second;
197 }
198
199 void FunctionAnalysisManager::invalidateImpl(void *PassID, Function &F) {
200 FunctionAnalysisResultMapT::iterator RI =
201 FunctionAnalysisResults.find(std::make_pair(PassID, &F));
202 if (RI == FunctionAnalysisResults.end())
203 return;
204
205 if (DebugPM)
206 dbgs() << "Invalidating function analysis: " << lookupPass(PassID).name()
207 << "\n";
208 FunctionAnalysisResultLists[&F].erase(RI->second);
209 FunctionAnalysisResults.erase(RI);
210 }
211
212 PreservedAnalyses
213 FunctionAnalysisManager::invalidateImpl(Function &F, PreservedAnalyses PA) {
214 // Short circuit for a common case of all analyses being preserved.
215 if (PA.areAllPreserved())
216 return std::move(PA);
217
218 if (DebugPM)
219 dbgs() << "Invalidating all non-preserved analyses for function: "
220 << F.getName() << "\n";
221
222 // Clear all the invalidated results associated specifically with this
223 // function.
224 SmallVector InvalidatedPassIDs;
225 FunctionAnalysisResultListT &ResultsList = FunctionAnalysisResultLists[&F];
226 for (FunctionAnalysisResultListT::iterator I = ResultsList.begin(),
227 E = ResultsList.end();
228 I != E;) {
229 void *PassID = I->first;
230
231 // Pass the invalidation down to the pass itself to see if it thinks it is
232 // necessary. The analysis pass can return false if no action on the part
233 // of the analysis manager is required for this invalidation event.
234 if (I->second->invalidate(F, PA)) {
235 if (DebugPM)
236 dbgs() << "Invalidating function analysis: "
237 << lookupPass(PassID).name() << "\n";
238
239 InvalidatedPassIDs.push_back(I->first);
240 I = ResultsList.erase(I);
241 } else {
242 ++I;
243 }
244
245 // After handling each pass, we mark it as preserved. Once we've
246 // invalidated any stale results, the rest of the system is allowed to
247 // start preserving this analysis again.
248 PA.preserve(PassID);
249 }
250 while (!InvalidatedPassIDs.empty())
251 FunctionAnalysisResults.erase(
252 std::make_pair(InvalidatedPassIDs.pop_back_val(), &F));
253 if (ResultsList.empty())
254 FunctionAnalysisResultLists.erase(&F);
255
256 return std::move(PA);
257 }
258
25987 char FunctionAnalysisManagerModuleProxy::PassID;
26088
26189 FunctionAnalysisManagerModuleProxy::Result
1919 ; RUN: | FileCheck %s --check-prefix=CHECK-CGSCC-PASS
2020 ; CHECK-CGSCC-PASS: Starting module pass manager
2121 ; CHECK-CGSCC-PASS-NEXT: Running module pass: ModuleToPostOrderCGSCCPassAdaptor
22 ; CHECK-CGSCC-PASS-NEXT: Running module analysis: CGSCCAnalysisManagerModuleProxy
23 ; CHECK-CGSCC-PASS-NEXT: Running module analysis: Lazy CallGraph Analysis
22 ; CHECK-CGSCC-PASS-NEXT: Running analysis: CGSCCAnalysisManagerModuleProxy
23 ; CHECK-CGSCC-PASS-NEXT: Running analysis: Lazy CallGraph Analysis
2424 ; CHECK-CGSCC-PASS-NEXT: Starting CGSCC pass manager run.
2525 ; CHECK-CGSCC-PASS-NEXT: Running CGSCC pass: NoOpCGSCCPass
2626 ; CHECK-CGSCC-PASS-NEXT: Finished CGSCC pass manager run.
3434 ; RUN: | FileCheck %s --check-prefix=CHECK-FUNCTION-PASS
3535 ; CHECK-FUNCTION-PASS: Starting module pass manager
3636 ; CHECK-FUNCTION-PASS-NEXT: Running module pass: ModuleToFunctionPassAdaptor
37 ; CHECK-FUNCTION-PASS-NEXT: Running module analysis: FunctionAnalysisManagerModuleProxy
37 ; CHECK-FUNCTION-PASS-NEXT: Running analysis: FunctionAnalysisManagerModuleProxy
3838 ; CHECK-FUNCTION-PASS-NEXT: Starting function pass manager run.
3939 ; CHECK-FUNCTION-PASS-NEXT: Running function pass: NoOpFunctionPass
4040 ; CHECK-FUNCTION-PASS-NEXT: Finished function pass manager run.
6464 ; CHECK-FUNCTION-PRINT: Starting module pass manager
6565 ; CHECK-FUNCTION-PRINT: Running module pass: VerifierPass
6666 ; CHECK-FUNCTION-PRINT: Running module pass: ModuleToFunctionPassAdaptor
67 ; CHECK-FUNCTION-PRINT: Running module analysis: FunctionAnalysisManagerModuleProxy
67 ; CHECK-FUNCTION-PRINT: Running analysis: FunctionAnalysisManagerModuleProxy
6868 ; CHECK-FUNCTION-PRINT: Starting function pass manager
6969 ; CHECK-FUNCTION-PRINT: Running function pass: PrintFunctionPass
7070 ; CHECK-FUNCTION-PRINT-NOT: ModuleID
126126 ; RUN: | FileCheck %s --check-prefix=CHECK-ANALYSES
127127 ; CHECK-ANALYSES: Starting module pass manager
128128 ; CHECK-ANALYSES: Running module pass: RequireAnalysisPass
129 ; CHECK-ANALYSES: Running module analysis: NoOpModuleAnalysis
129 ; CHECK-ANALYSES: Running analysis: NoOpModuleAnalysis
130130 ; CHECK-ANALYSES: Starting CGSCC pass manager
131131 ; CHECK-ANALYSES: Running CGSCC pass: RequireAnalysisPass
132 ; CHECK-ANALYSES: Running CGSCC analysis: NoOpCGSCCAnalysis
132 ; CHECK-ANALYSES: Running analysis: NoOpCGSCCAnalysis
133133 ; CHECK-ANALYSES: Starting function pass manager
134134 ; CHECK-ANALYSES: Running function pass: RequireAnalysisPass
135 ; CHECK-ANALYSES: Running function analysis: NoOpFunctionAnalysis
135 ; CHECK-ANALYSES: Running analysis: NoOpFunctionAnalysis
136136
137137 ; Make sure no-op passes that preserve all analyses don't even try to do any
138138 ; analysis invalidation.
147147 ; RUN: | FileCheck %s --check-prefix=CHECK-DO-CACHE-MODULE-ANALYSIS-RESULTS
148148 ; CHECK-DO-CACHE-MODULE-ANALYSIS-RESULTS: Starting module pass manager
149149 ; CHECK-DO-CACHE-MODULE-ANALYSIS-RESULTS: Running module pass: RequireAnalysisPass
150 ; CHECK-DO-CACHE-MODULE-ANALYSIS-RESULTS: Running module analysis: NoOpModuleAnalysis
151 ; CHECK-DO-CACHE-MODULE-ANALYSIS-RESULTS-NOT: Running module analysis: NoOpModuleAnalysis
150 ; CHECK-DO-CACHE-MODULE-ANALYSIS-RESULTS: Running analysis: NoOpModuleAnalysis
151 ; CHECK-DO-CACHE-MODULE-ANALYSIS-RESULTS-NOT: Running analysis: NoOpModuleAnalysis
152152
153153 ; RUN: opt -disable-output -debug-pass-manager -debug-cgscc-pass-manager \
154154 ; RUN: -passes='require,invalidate,require' %s 2>&1 \
155155 ; RUN: | FileCheck %s --check-prefix=CHECK-DO-INVALIDATE-MODULE-ANALYSIS-RESULTS
156156 ; CHECK-DO-INVALIDATE-MODULE-ANALYSIS-RESULTS: Starting module pass manager
157157 ; CHECK-DO-INVALIDATE-MODULE-ANALYSIS-RESULTS: Running module pass: RequireAnalysisPass
158 ; CHECK-DO-INVALIDATE-MODULE-ANALYSIS-RESULTS: Running module analysis: NoOpModuleAnalysis
159 ; CHECK-DO-INVALIDATE-MODULE-ANALYSIS-RESULTS: Invalidating module analysis: NoOpModuleAnalysis
160 ; CHECK-DO-INVALIDATE-MODULE-ANALYSIS-RESULTS: Running module analysis: NoOpModuleAnalysis
158 ; CHECK-DO-INVALIDATE-MODULE-ANALYSIS-RESULTS: Running analysis: NoOpModuleAnalysis
159 ; CHECK-DO-INVALIDATE-MODULE-ANALYSIS-RESULTS: Invalidating analysis: NoOpModuleAnalysis
160 ; CHECK-DO-INVALIDATE-MODULE-ANALYSIS-RESULTS: Running analysis: NoOpModuleAnalysis
161161
162162 ; RUN: opt -disable-output -debug-pass-manager -debug-cgscc-pass-manager \
163163 ; RUN: -passes='cgscc(require,require,require)' %s 2>&1 \
164164 ; RUN: | FileCheck %s --check-prefix=CHECK-DO-CACHE-CGSCC-ANALYSIS-RESULTS
165165 ; CHECK-DO-CACHE-CGSCC-ANALYSIS-RESULTS: Starting CGSCC pass manager
166166 ; CHECK-DO-CACHE-CGSCC-ANALYSIS-RESULTS: Running CGSCC pass: RequireAnalysisPass
167 ; CHECK-DO-CACHE-CGSCC-ANALYSIS-RESULTS: Running CGSCC analysis: NoOpCGSCCAnalysis
168 ; CHECK-DO-CACHE-CGSCC-ANALYSIS-RESULTS-NOT: Running CGSCC analysis: NoOpCGSCCAnalysis
167 ; CHECK-DO-CACHE-CGSCC-ANALYSIS-RESULTS: Running analysis: NoOpCGSCCAnalysis
168 ; CHECK-DO-CACHE-CGSCC-ANALYSIS-RESULTS-NOT: Running analysis: NoOpCGSCCAnalysis
169169
170170 ; RUN: opt -disable-output -debug-pass-manager -debug-cgscc-pass-manager \
171171 ; RUN: -passes='cgscc(require,invalidate,require)' %s 2>&1 \
172172 ; RUN: | FileCheck %s --check-prefix=CHECK-DO-INVALIDATE-CGSCC-ANALYSIS-RESULTS
173173 ; CHECK-DO-INVALIDATE-CGSCC-ANALYSIS-RESULTS: Starting CGSCC pass manager
174174 ; CHECK-DO-INVALIDATE-CGSCC-ANALYSIS-RESULTS: Running CGSCC pass: RequireAnalysisPass
175 ; CHECK-DO-INVALIDATE-CGSCC-ANALYSIS-RESULTS: Running CGSCC analysis: NoOpCGSCCAnalysis
176 ; CHECK-DO-INVALIDATE-CGSCC-ANALYSIS-RESULTS: Invalidating CGSCC analysis: NoOpCGSCCAnalysis
177 ; CHECK-DO-INVALIDATE-CGSCC-ANALYSIS-RESULTS: Running CGSCC analysis: NoOpCGSCCAnalysis
175 ; CHECK-DO-INVALIDATE-CGSCC-ANALYSIS-RESULTS: Running analysis: NoOpCGSCCAnalysis
176 ; CHECK-DO-INVALIDATE-CGSCC-ANALYSIS-RESULTS: Invalidating analysis: NoOpCGSCCAnalysis
177 ; CHECK-DO-INVALIDATE-CGSCC-ANALYSIS-RESULTS: Running analysis: NoOpCGSCCAnalysis
178178
179179 ; RUN: opt -disable-output -debug-pass-manager -debug-cgscc-pass-manager \
180180 ; RUN: -passes='function(require,require,require)' %s 2>&1 \
181181 ; RUN: | FileCheck %s --check-prefix=CHECK-DO-CACHE-FUNCTION-ANALYSIS-RESULTS
182182 ; CHECK-DO-CACHE-FUNCTION-ANALYSIS-RESULTS: Starting function pass manager
183183 ; CHECK-DO-CACHE-FUNCTION-ANALYSIS-RESULTS: Running function pass: RequireAnalysisPass
184 ; CHECK-DO-CACHE-FUNCTION-ANALYSIS-RESULTS: Running function analysis: NoOpFunctionAnalysis
185 ; CHECK-DO-CACHE-FUNCTION-ANALYSIS-RESULTS-NOT: Running function analysis: NoOpFunctionAnalysis
184 ; CHECK-DO-CACHE-FUNCTION-ANALYSIS-RESULTS: Running analysis: NoOpFunctionAnalysis
185 ; CHECK-DO-CACHE-FUNCTION-ANALYSIS-RESULTS-NOT: Running analysis: NoOpFunctionAnalysis
186186
187187 ; RUN: opt -disable-output -debug-pass-manager -debug-cgscc-pass-manager \
188188 ; RUN: -passes='function(require,invalidate,require)' %s 2>&1 \
189189 ; RUN: | FileCheck %s --check-prefix=CHECK-DO-INVALIDATE-FUNCTION-ANALYSIS-RESULTS
190190 ; CHECK-DO-INVALIDATE-FUNCTION-ANALYSIS-RESULTS: Starting function pass manager
191191 ; CHECK-DO-INVALIDATE-FUNCTION-ANALYSIS-RESULTS: Running function pass: RequireAnalysisPass
192 ; CHECK-DO-INVALIDATE-FUNCTION-ANALYSIS-RESULTS: Running function analysis: NoOpFunctionAnalysis
193 ; CHECK-DO-INVALIDATE-FUNCTION-ANALYSIS-RESULTS: Invalidating function analysis: NoOpFunctionAnalysis
194 ; CHECK-DO-INVALIDATE-FUNCTION-ANALYSIS-RESULTS: Running function analysis: NoOpFunctionAnalysis
192 ; CHECK-DO-INVALIDATE-FUNCTION-ANALYSIS-RESULTS: Running analysis: NoOpFunctionAnalysis
193 ; CHECK-DO-INVALIDATE-FUNCTION-ANALYSIS-RESULTS: Invalidating analysis: NoOpFunctionAnalysis
194 ; CHECK-DO-INVALIDATE-FUNCTION-ANALYSIS-RESULTS: Running analysis: NoOpFunctionAnalysis
195195
196196 ; RUN: opt -disable-output -disable-verify -debug-pass-manager -debug-cgscc-pass-manager \
197197 ; RUN: -passes='require,module(require,function(require,invalidate,require),require),require' %s 2>&1 \
198198 ; RUN: | FileCheck %s --check-prefix=CHECK-INVALIDATE-ALL
199199 ; CHECK-INVALIDATE-ALL: Starting module pass manager run.
200200 ; CHECK-INVALIDATE-ALL: Running module pass: RequireAnalysisPass
201 ; CHECK-INVALIDATE-ALL: Running module analysis: NoOpModuleAnalysis
201 ; CHECK-INVALIDATE-ALL: Running analysis: NoOpModuleAnalysis
202202 ; CHECK-INVALIDATE-ALL: Starting module pass manager run.
203203 ; CHECK-INVALIDATE-ALL: Running module pass: RequireAnalysisPass
204 ; CHECK-INVALIDATE-ALL-NOT: Running module analysis: NoOpModuleAnalysis
204 ; CHECK-INVALIDATE-ALL-NOT: Running analysis: NoOpModuleAnalysis
205205 ; CHECK-INVALIDATE-ALL: Starting function pass manager run.
206206 ; CHECK-INVALIDATE-ALL: Running function pass: RequireAnalysisPass
207 ; CHECK-INVALIDATE-ALL: Running function analysis: NoOpFunctionAnalysis
207 ; CHECK-INVALIDATE-ALL: Running analysis: NoOpFunctionAnalysis
208208 ; CHECK-INVALIDATE-ALL: Running function pass: InvalidateAllAnalysesPass
209 ; CHECK-INVALIDATE-ALL: Invalidating all non-preserved analyses for function
210 ; CHECK-INVALIDATE-ALL: Invalidating function analysis: NoOpFunctionAnalysis
209 ; CHECK-INVALIDATE-ALL: Invalidating all non-preserved analyses
210 ; CHECK-INVALIDATE-ALL: Invalidating analysis: NoOpFunctionAnalysis
211211 ; CHECK-INVALIDATE-ALL: Running function pass: RequireAnalysisPass
212 ; CHECK-INVALIDATE-ALL: Running function analysis: NoOpFunctionAnalysis
212 ; CHECK-INVALIDATE-ALL: Running analysis: NoOpFunctionAnalysis
213213 ; CHECK-INVALIDATE-ALL: Finished function pass manager run.
214 ; CHECK-INVALIDATE-ALL: Invalidating all non-preserved analyses for function
215 ; CHECK-INVALIDATE-ALL-NOT: Running function analysis: NoOpFunctionAnalysis
216 ; CHECK-INVALIDATE-ALL: Invalidating all non-preserved analyses for module
217 ; CHECK-INVALIDATE-ALL: Invalidating module analysis: NoOpModuleAnalysis
218 ; CHECK-INVALIDATE-ALL: Running module pass: RequireAnalysisPass
219 ; CHECK-INVALIDATE-ALL: Running module analysis: NoOpModuleAnalysis
214 ; CHECK-INVALIDATE-ALL: Invalidating all non-preserved analyses
215 ; CHECK-INVALIDATE-ALL-NOT: Running analysis: NoOpFunctionAnalysis
216 ; CHECK-INVALIDATE-ALL: Invalidating all non-preserved analyses
217 ; CHECK-INVALIDATE-ALL: Invalidating analysis: NoOpModuleAnalysis
218 ; CHECK-INVALIDATE-ALL: Running module pass: RequireAnalysisPass
219 ; CHECK-INVALIDATE-ALL: Running analysis: NoOpModuleAnalysis
220220 ; CHECK-INVALIDATE-ALL: Finished module pass manager run.
221 ; CHECK-INVALIDATE-ALL: Invalidating all non-preserved analyses for module
222 ; CHECK-INVALIDATE-ALL-NOT: Invalidating module analysis: NoOpModuleAnalysis
223 ; CHECK-INVALIDATE-ALL: Running module pass: RequireAnalysisPass
224 ; CHECK-INVALIDATE-ALL-NOT: Running module analysis: NoOpModuleAnalysis
221 ; CHECK-INVALIDATE-ALL: Invalidating all non-preserved analyses
222 ; CHECK-INVALIDATE-ALL-NOT: Invalidating analysis: NoOpModuleAnalysis
223 ; CHECK-INVALIDATE-ALL: Running module pass: RequireAnalysisPass
224 ; CHECK-INVALIDATE-ALL-NOT: Running analysis: NoOpModuleAnalysis
225225 ; CHECK-INVALIDATE-ALL: Finished module pass manager run.
226226
227227 ; RUN: opt -disable-output -disable-verify -debug-pass-manager -debug-cgscc-pass-manager \
229229 ; RUN: | FileCheck %s --check-prefix=CHECK-INVALIDATE-ALL-CG
230230 ; CHECK-INVALIDATE-ALL-CG: Starting module pass manager run.
231231 ; CHECK-INVALIDATE-ALL-CG: Running module pass: RequireAnalysisPass
232 ; CHECK-INVALIDATE-ALL-CG: Running module analysis: NoOpModuleAnalysis
232 ; CHECK-INVALIDATE-ALL-CG: Running analysis: NoOpModuleAnalysis
233233 ; CHECK-INVALIDATE-ALL-CG: Starting module pass manager run.
234234 ; CHECK-INVALIDATE-ALL-CG: Running module pass: RequireAnalysisPass
235 ; CHECK-INVALIDATE-ALL-CG-NOT: Running module analysis: NoOpModuleAnalysis
235 ; CHECK-INVALIDATE-ALL-CG-NOT: Running analysis: NoOpModuleAnalysis
236236 ; CHECK-INVALIDATE-ALL-CG: Starting CGSCC pass manager run.
237237 ; CHECK-INVALIDATE-ALL-CG: Running CGSCC pass: RequireAnalysisPass
238 ; CHECK-INVALIDATE-ALL-CG: Running CGSCC analysis: NoOpCGSCCAnalysis
238 ; CHECK-INVALIDATE-ALL-CG: Running analysis: NoOpCGSCCAnalysis
239239 ; CHECK-INVALIDATE-ALL-CG: Starting function pass manager run.
240240 ; CHECK-INVALIDATE-ALL-CG: Running function pass: RequireAnalysisPass
241 ; CHECK-INVALIDATE-ALL-CG: Running function analysis: NoOpFunctionAnalysis
241 ; CHECK-INVALIDATE-ALL-CG: Running analysis: NoOpFunctionAnalysis
242242 ; CHECK-INVALIDATE-ALL-CG: Running function pass: InvalidateAllAnalysesPass
243 ; CHECK-INVALIDATE-ALL-CG: Invalidating all non-preserved analyses for function
244 ; CHECK-INVALIDATE-ALL-CG: Invalidating function analysis: NoOpFunctionAnalysis
243 ; CHECK-INVALIDATE-ALL-CG: Invalidating all non-preserved analyses
244 ; CHECK-INVALIDATE-ALL-CG: Invalidating analysis: NoOpFunctionAnalysis
245245 ; CHECK-INVALIDATE-ALL-CG: Running function pass: RequireAnalysisPass
246 ; CHECK-INVALIDATE-ALL-CG: Running function analysis: NoOpFunctionAnalysis
246 ; CHECK-INVALIDATE-ALL-CG: Running analysis: NoOpFunctionAnalysis
247247 ; CHECK-INVALIDATE-ALL-CG: Finished function pass manager run.
248 ; CHECK-INVALIDATE-ALL-CG: Invalidating all non-preserved analyses for function
249 ; CHECK-INVALIDATE-ALL-CG-NOT: Running function analysis: NoOpFunctionAnalysis
250 ; CHECK-INVALIDATE-ALL-CG: Invalidating all non-preserved analyses for SCC
251 ; CHECK-INVALIDATE-ALL-CG: Invalidating CGSCC analysis: NoOpCGSCCAnalysis
248 ; CHECK-INVALIDATE-ALL-CG: Invalidating all non-preserved analyses
249 ; CHECK-INVALIDATE-ALL-CG-NOT: Running analysis: NoOpFunctionAnalysis
250 ; CHECK-INVALIDATE-ALL-CG: Invalidating all non-preserved analyses
251 ; CHECK-INVALIDATE-ALL-CG: Invalidating analysis: NoOpCGSCCAnalysis
252252 ; CHECK-INVALIDATE-ALL-CG: Running CGSCC pass: RequireAnalysisPass
253 ; CHECK-INVALIDATE-ALL-CG: Running CGSCC analysis: NoOpCGSCCAnalysis
253 ; CHECK-INVALIDATE-ALL-CG: Running analysis: NoOpCGSCCAnalysis
254254 ; CHECK-INVALIDATE-ALL-CG: Finished CGSCC pass manager run.
255 ; CHECK-INVALIDATE-ALL-CG: Invalidating all non-preserved analyses for SCC
256 ; CHECK-INVALIDATE-ALL-CG-NOT: Invalidating CGSCC analysis: NoOpCGSCCAnalysis
257 ; CHECK-INVALIDATE-ALL-CG: Invalidating all non-preserved analyses for module
258 ; CHECK-INVALIDATE-ALL-CG: Invalidating module analysis: NoOpModuleAnalysis
259 ; CHECK-INVALIDATE-ALL-CG: Running module pass: RequireAnalysisPass
260 ; CHECK-INVALIDATE-ALL-CG: Running module analysis: NoOpModuleAnalysis
255 ; CHECK-INVALIDATE-ALL-CG: Invalidating all non-preserved analyses
256 ; CHECK-INVALIDATE-ALL-CG-NOT: Invalidating analysis: NoOpCGSCCAnalysis
257 ; CHECK-INVALIDATE-ALL-CG: Invalidating all non-preserved analyses
258 ; CHECK-INVALIDATE-ALL-CG: Invalidating analysis: NoOpModuleAnalysis
259 ; CHECK-INVALIDATE-ALL-CG: Running module pass: RequireAnalysisPass
260 ; CHECK-INVALIDATE-ALL-CG: Running analysis: NoOpModuleAnalysis
261261 ; CHECK-INVALIDATE-ALL-CG: Finished module pass manager run.
262 ; CHECK-INVALIDATE-ALL-CG: Invalidating all non-preserved analyses for module
263 ; CHECK-INVALIDATE-ALL-CG-NOT: Invalidating module analysis: NoOpModuleAnalysis
264 ; CHECK-INVALIDATE-ALL-CG: Running module pass: RequireAnalysisPass
265 ; CHECK-INVALIDATE-ALL-CG-NOT: Running module analysis: NoOpModuleAnalysis
262 ; CHECK-INVALIDATE-ALL-CG: Invalidating all non-preserved analyses
263 ; CHECK-INVALIDATE-ALL-CG-NOT: Invalidating analysis: NoOpModuleAnalysis
264 ; CHECK-INVALIDATE-ALL-CG: Running module pass: RequireAnalysisPass
265 ; CHECK-INVALIDATE-ALL-CG-NOT: Running analysis: NoOpModuleAnalysis
266266 ; CHECK-INVALIDATE-ALL-CG: Finished module pass manager run.
267267
268268 define void @foo() {
1616 #define LLVM_TOOLS_OPT_PASSES_H
1717
1818 #include "llvm/ADT/StringRef.h"
19 #include "llvm/IR/PassManager.h"
20 #include "llvm/Analysis/CGSCCPassManager.h"
1921
2022 namespace llvm {
21 class CGSCCAnalysisManager;
22 class FunctionAnalysisManager;
23 class ModuleAnalysisManager;
24 class ModulePassManager;
2523
2624 /// \brief Registers all available module analysis passes.
2725 ///