LLVM 22.0.0git
PassManager.h
Go to the documentation of this file.
1//===- PassManager.h - Pass management infrastructure -----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9///
10/// This header defines various interfaces for pass management in LLVM. There
11/// is no "pass" interface in LLVM per se. Instead, an instance of any class
12/// which supports a method to 'run' it over a unit of IR can be used as
13/// a pass. A pass manager is generally a tool to collect a sequence of passes
14/// which run over a particular IR construct, and run each of them in sequence
15/// over each such construct in the containing IR construct. As there is no
16/// containing IR construct for a Module, a manager for passes over modules
17/// forms the base case which runs its managed passes in sequence over the
18/// single module provided.
19///
20/// The core IR library provides managers for running passes over
21/// modules and functions.
22///
23/// * FunctionPassManager can run over a Module, runs each pass over
24/// a Function.
25/// * ModulePassManager must be directly run, runs each pass over the Module.
26///
27/// Note that the implementations of the pass managers use concept-based
28/// polymorphism as outlined in the "Value Semantics and Concept-based
29/// Polymorphism" talk (or its abbreviated sibling "Inheritance Is The Base
30/// Class of Evil") by Sean Parent:
31/// * https://sean-parent.stlab.cc/papers-and-presentations
32/// * http://www.youtube.com/watch?v=_BpMYeUFXv8
33/// * https://learn.microsoft.com/en-us/shows/goingnative-2013/inheritance-base-class-of-evil
34///
35//===----------------------------------------------------------------------===//
36
37#ifndef LLVM_IR_PASSMANAGER_H
38#define LLVM_IR_PASSMANAGER_H
39
40#include "llvm/ADT/DenseMap.h"
41#include "llvm/ADT/STLExtras.h"
42#include "llvm/ADT/StringRef.h"
44#include "llvm/IR/Analysis.h"
48#include <cassert>
49#include <cstring>
50#include <iterator>
51#include <list>
52#include <memory>
53#include <tuple>
54#include <type_traits>
55#include <utility>
56#include <vector>
57
58namespace llvm {
59
60class Function;
61class Module;
62
63// Forward declare the analysis manager template.
64template <typename IRUnitT, typename... ExtraArgTs> class AnalysisManager;
65
66/// A CRTP mix-in to automatically provide informational APIs needed for
67/// passes.
68///
69/// This provides some boilerplate for types that are passes.
70template <typename DerivedT> struct PassInfoMixin {
71 /// Gets the name of the pass we are mixed into.
72 static StringRef name() {
73 static_assert(std::is_base_of<PassInfoMixin, DerivedT>::value,
74 "Must pass the derived type as the template argument!");
75 StringRef Name = getTypeName<DerivedT>();
76 Name.consume_front("llvm::");
77 return Name;
78 }
79
81 function_ref<StringRef(StringRef)> MapClassName2PassName) {
82 StringRef ClassName = DerivedT::name();
83 auto PassName = MapClassName2PassName(ClassName);
84 OS << PassName;
85 }
86};
87
88/// A CRTP mix-in that provides informational APIs needed for analysis passes.
89///
90/// This provides some boilerplate for types that are analysis passes. It
91/// automatically mixes in \c PassInfoMixin.
92template <typename DerivedT>
93struct AnalysisInfoMixin : PassInfoMixin<DerivedT> {
94 /// Returns an opaque, unique ID for this analysis type.
95 ///
96 /// This ID is a pointer type that is guaranteed to be 8-byte aligned and thus
97 /// suitable for use in sets, maps, and other data structures that use the low
98 /// bits of pointers.
99 ///
100 /// Note that this requires the derived type provide a static \c AnalysisKey
101 /// member called \c Key.
102 ///
103 /// FIXME: The only reason the mixin type itself can't declare the Key value
104 /// is that some compilers cannot correctly unique a templated static variable
105 /// so it has the same addresses in each instantiation. The only currently
106 /// known platform with this limitation is Windows DLL builds, specifically
107 /// building each part of LLVM as a DLL. If we ever remove that build
108 /// configuration, this mixin can provide the static key as well.
109 static AnalysisKey *ID() {
110 static_assert(std::is_base_of<AnalysisInfoMixin, DerivedT>::value,
111 "Must pass the derived type as the template argument!");
112 return &DerivedT::Key;
113 }
114};
115
116namespace detail {
117
118/// Actual unpacker of extra arguments in getAnalysisResult,
119/// passes only those tuple arguments that are mentioned in index_sequence.
120template <typename PassT, typename IRUnitT, typename AnalysisManagerT,
121 typename... ArgTs, size_t... Ns>
122typename PassT::Result
123getAnalysisResultUnpackTuple(AnalysisManagerT &AM, IRUnitT &IR,
124 std::tuple<ArgTs...> Args,
125 std::index_sequence<Ns...>) {
126 (void)Args;
127 return AM.template getResult<PassT>(IR, std::get<Ns>(Args)...);
128}
129
130/// Helper for *partial* unpacking of extra arguments in getAnalysisResult.
131///
132/// Arguments passed in tuple come from PassManager, so they might have extra
133/// arguments after those AnalysisManager's ExtraArgTs ones that we need to
134/// pass to getResult.
135template <typename PassT, typename IRUnitT, typename... AnalysisArgTs,
136 typename... MainArgTs>
137typename PassT::Result
139 std::tuple<MainArgTs...> Args) {
141 PassT, IRUnitT>)(AM, IR, Args,
142 std::index_sequence_for<AnalysisArgTs...>{});
143}
144
145} // namespace detail
146
147/// Manages a sequence of passes over a particular unit of IR.
148///
149/// A pass manager contains a sequence of passes to run over a particular unit
150/// of IR (e.g. Functions, Modules). It is itself a valid pass over that unit of
151/// IR, and when run over some given IR will run each of its contained passes in
152/// sequence. Pass managers are the primary and most basic building block of a
153/// pass pipeline.
154///
155/// When you run a pass manager, you provide an \c AnalysisManager<IRUnitT>
156/// argument. The pass manager will propagate that analysis manager to each
157/// pass it runs, and will call the analysis manager's invalidation routine with
158/// the PreservedAnalyses of each pass it runs.
159template <typename IRUnitT,
160 typename AnalysisManagerT = AnalysisManager<IRUnitT>,
161 typename... ExtraArgTs>
163 PassManager<IRUnitT, AnalysisManagerT, ExtraArgTs...>> {
164public:
165 /// Construct a pass manager.
166 explicit PassManager() = default;
167
168 // FIXME: These are equivalent to the default move constructor/move
169 // assignment. However, using = default triggers linker errors due to the
170 // explicit instantiations below. Find away to use the default and remove the
171 // duplicated code here.
173
175 Passes = std::move(RHS.Passes);
176 return *this;
177 }
178
180 function_ref<StringRef(StringRef)> MapClassName2PassName) {
181 for (unsigned Idx = 0, Size = Passes.size(); Idx != Size; ++Idx) {
182 auto *P = Passes[Idx].get();
183 P->printPipeline(OS, MapClassName2PassName);
184 if (Idx + 1 < Size)
185 OS << ',';
186 }
187 }
188
189 /// Run all of the passes in this manager over the given unit of IR.
190 /// ExtraArgs are passed to each pass.
191 PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT &AM,
192 ExtraArgTs... ExtraArgs);
193
194 template <typename PassT>
195 LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same_v<PassT, PassManager>>
196 addPass(PassT &&Pass) {
197 using PassModelT =
198 detail::PassModel<IRUnitT, PassT, AnalysisManagerT, ExtraArgTs...>;
199 // Do not use make_unique or emplace_back, they cause too many template
200 // instantiations, causing terrible compile times.
201 Passes.push_back(std::unique_ptr<PassConceptT>(
202 new PassModelT(std::forward<PassT>(Pass))));
203 }
204
205 /// When adding a pass manager pass that has the same type as this pass
206 /// manager, simply move the passes over. This is because we don't have
207 /// use cases rely on executing nested pass managers. Doing this could
208 /// reduce implementation complexity and avoid potential invalidation
209 /// issues that may happen with nested pass managers of the same type.
210 template <typename PassT>
211 LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<std::is_same_v<PassT, PassManager>>
212 addPass(PassT &&Pass) {
213 for (auto &P : Pass.Passes)
214 Passes.push_back(std::move(P));
215 }
216
217 /// Returns if the pass manager contains any passes.
218 bool isEmpty() const { return Passes.empty(); }
219
220 static bool isRequired() { return true; }
221
222protected:
224 detail::PassConcept<IRUnitT, AnalysisManagerT, ExtraArgTs...>;
225
226 std::vector<std::unique_ptr<PassConceptT>> Passes;
227};
228
229template <typename IRUnitT>
231
232template <>
234 const Module &IR);
235
236extern template class LLVM_TEMPLATE_ABI PassManager<Module>;
237
238/// Convenience typedef for a pass manager over modules.
240
241template <>
243 const Function &IR);
244
245extern template class LLVM_TEMPLATE_ABI PassManager<Function>;
246
247/// Convenience typedef for a pass manager over functions.
249
250/// A container for analyses that lazily runs them and caches their
251/// results.
252///
253/// This class can manage analyses for any IR unit where the address of the IR
254/// unit sufficies as its identity.
255template <typename IRUnitT, typename... ExtraArgTs> class AnalysisManager {
256public:
257 class Invalidator;
258
259private:
260 // Now that we've defined our invalidator, we can define the concept types.
262 using PassConceptT =
263 detail::AnalysisPassConcept<IRUnitT, Invalidator, ExtraArgTs...>;
264
265 /// List of analysis pass IDs and associated concept pointers.
266 ///
267 /// Requires iterators to be valid across appending new entries and arbitrary
268 /// erases. Provides the analysis ID to enable finding iterators to a given
269 /// entry in maps below, and provides the storage for the actual result
270 /// concept.
271 using AnalysisResultListT =
272 std::list<std::pair<AnalysisKey *, std::unique_ptr<ResultConceptT>>>;
273
274 /// Map type from IRUnitT pointer to our custom list type.
276
277 /// Map type from a pair of analysis ID and IRUnitT pointer to an
278 /// iterator into a particular result list (which is where the actual analysis
279 /// result is stored).
280 using AnalysisResultMapT =
282 typename AnalysisResultListT::iterator>;
283
284public:
285 /// API to communicate dependencies between analyses during invalidation.
286 ///
287 /// When an analysis result embeds handles to other analysis results, it
288 /// needs to be invalidated both when its own information isn't preserved and
289 /// when any of its embedded analysis results end up invalidated. We pass an
290 /// \c Invalidator object as an argument to \c invalidate() in order to let
291 /// the analysis results themselves define the dependency graph on the fly.
292 /// This lets us avoid building an explicit representation of the
293 /// dependencies between analysis results.
295 public:
296 /// Trigger the invalidation of some other analysis pass if not already
297 /// handled and return whether it was in fact invalidated.
298 ///
299 /// This is expected to be called from within a given analysis result's \c
300 /// invalidate method to trigger a depth-first walk of all inter-analysis
301 /// dependencies. The same \p IR unit and \p PA passed to that result's \c
302 /// invalidate method should in turn be provided to this routine.
303 ///
304 /// The first time this is called for a given analysis pass, it will call
305 /// the corresponding result's \c invalidate method. Subsequent calls will
306 /// use a cache of the results of that initial call. It is an error to form
307 /// cyclic dependencies between analysis results.
308 ///
309 /// This returns true if the given analysis's result is invalid. Any
310 /// dependecies on it will become invalid as a result.
311 template <typename PassT>
312 bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA) {
313 using ResultModelT =
314 detail::AnalysisResultModel<IRUnitT, PassT, typename PassT::Result,
316
317 return invalidateImpl<ResultModelT>(PassT::ID(), IR, PA);
318 }
319
320 /// A type-erased variant of the above invalidate method with the same core
321 /// API other than passing an analysis ID rather than an analysis type
322 /// parameter.
323 ///
324 /// This is sadly less efficient than the above routine, which leverages
325 /// the type parameter to avoid the type erasure overhead.
326 bool invalidate(AnalysisKey *ID, IRUnitT &IR, const PreservedAnalyses &PA) {
327 return invalidateImpl<>(ID, IR, PA);
328 }
329
330 private:
331 friend class AnalysisManager;
332
333 template <typename ResultT = ResultConceptT>
334 bool invalidateImpl(AnalysisKey *ID, IRUnitT &IR,
335 const PreservedAnalyses &PA) {
336 // If we've already visited this pass, return true if it was invalidated
337 // and false otherwise.
338 auto IMapI = IsResultInvalidated.find(ID);
339 if (IMapI != IsResultInvalidated.end())
340 return IMapI->second;
341
342 // Otherwise look up the result object.
343 auto RI = Results.find({ID, &IR});
344 assert(RI != Results.end() &&
345 "Trying to invalidate a dependent result that isn't in the "
346 "manager's cache is always an error, likely due to a stale result "
347 "handle!");
348
349 auto &Result = static_cast<ResultT &>(*RI->second->second);
350
351 // Insert into the map whether the result should be invalidated and return
352 // that. Note that we cannot reuse IMapI and must do a fresh insert here,
353 // as calling invalidate could (recursively) insert things into the map,
354 // making any iterator or reference invalid.
355 bool Inserted;
356 std::tie(IMapI, Inserted) =
357 IsResultInvalidated.insert({ID, Result.invalidate(IR, PA, *this)});
358 (void)Inserted;
359 assert(Inserted && "Should not have already inserted this ID, likely "
360 "indicates a dependency cycle!");
361 return IMapI->second;
362 }
363
364 Invalidator(SmallDenseMap<AnalysisKey *, bool, 8> &IsResultInvalidated,
365 const AnalysisResultMapT &Results)
366 : IsResultInvalidated(IsResultInvalidated), Results(Results) {}
367
368 SmallDenseMap<AnalysisKey *, bool, 8> &IsResultInvalidated;
369 const AnalysisResultMapT &Results;
370 };
371
372 /// Construct an empty analysis manager.
376
377 /// Returns true if the analysis manager has an empty results cache.
378 bool empty() const {
379 assert(AnalysisResults.empty() == AnalysisResultLists.empty() &&
380 "The storage and index of analysis results disagree on how many "
381 "there are!");
382 return AnalysisResults.empty();
383 }
384
385 /// Clear any cached analysis results for a single unit of IR.
386 ///
387 /// This doesn't invalidate, but instead simply deletes, the relevant results.
388 /// It is useful when the IR is being removed and we want to clear out all the
389 /// memory pinned for it.
390 void clear(IRUnitT &IR, llvm::StringRef Name);
391
392 /// Clear all analysis results cached by this AnalysisManager.
393 ///
394 /// Like \c clear(IRUnitT&), this doesn't invalidate the results; it simply
395 /// deletes them. This lets you clean up the AnalysisManager when the set of
396 /// IR units itself has potentially changed, and thus we can't even look up a
397 /// a result and invalidate/clear it directly.
398 void clear() {
399 AnalysisResults.clear();
400 AnalysisResultLists.clear();
401 }
402
403 /// Returns true if the specified analysis pass is registered.
404 template <typename PassT> bool isPassRegistered() const {
405 return AnalysisPasses.count(PassT::ID());
406 }
407
408 /// Get the result of an analysis pass for a given IR unit.
409 ///
410 /// Runs the analysis if a cached result is not available.
411 template <typename PassT>
412 typename PassT::Result &getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs) {
413 assert(AnalysisPasses.count(PassT::ID()) &&
414 "This analysis pass was not registered prior to being queried");
415 ResultConceptT &ResultConcept =
416 getResultImpl(PassT::ID(), IR, ExtraArgs...);
417
418 using ResultModelT =
419 detail::AnalysisResultModel<IRUnitT, PassT, typename PassT::Result,
421
422 return static_cast<ResultModelT &>(ResultConcept).Result;
423 }
424
425 /// Get the cached result of an analysis pass for a given IR unit.
426 ///
427 /// This method never runs the analysis.
428 ///
429 /// \returns null if there is no cached result.
430 template <typename PassT>
431 typename PassT::Result *getCachedResult(IRUnitT &IR) const {
432 assert(AnalysisPasses.count(PassT::ID()) &&
433 "This analysis pass was not registered prior to being queried");
434
435 ResultConceptT *ResultConcept = getCachedResultImpl(PassT::ID(), IR);
436 if (!ResultConcept)
437 return nullptr;
438
439 using ResultModelT =
440 detail::AnalysisResultModel<IRUnitT, PassT, typename PassT::Result,
442
443 return &static_cast<ResultModelT *>(ResultConcept)->Result;
444 }
445
446 /// Verify that the given Result cannot be invalidated, assert otherwise.
447 template <typename PassT>
448 void verifyNotInvalidated(IRUnitT &IR, typename PassT::Result *Result) const {
450 SmallDenseMap<AnalysisKey *, bool, 8> IsResultInvalidated;
451 Invalidator Inv(IsResultInvalidated, AnalysisResults);
452 assert(!Result->invalidate(IR, PA, Inv) &&
453 "Cached result cannot be invalidated");
454 }
455
456 /// Register an analysis pass with the manager.
457 ///
458 /// The parameter is a callable whose result is an analysis pass. This allows
459 /// passing in a lambda to construct the analysis.
460 ///
461 /// The analysis type to register is the type returned by calling the \c
462 /// PassBuilder argument. If that type has already been registered, then the
463 /// argument will not be called and this function will return false.
464 /// Otherwise, we register the analysis returned by calling \c PassBuilder(),
465 /// and this function returns true.
466 ///
467 /// (Note: Although the return value of this function indicates whether or not
468 /// an analysis was previously registered, you should just register all the
469 /// analyses you might want and let this class run them lazily. This idiom
470 /// lets us minimize the number of times we have to look up analyses in our
471 /// hashtable.)
472 template <typename PassBuilderT>
473 bool registerPass(PassBuilderT &&PassBuilder) {
474 using PassT = decltype(PassBuilder());
475 using PassModelT =
476 detail::AnalysisPassModel<IRUnitT, PassT, Invalidator, ExtraArgTs...>;
477
478 auto &PassPtr = AnalysisPasses[PassT::ID()];
479 if (PassPtr)
480 // Already registered this pass type!
481 return false;
482
483 // Construct a new model around the instance returned by the builder.
484 PassPtr.reset(new PassModelT(PassBuilder()));
485 return true;
486 }
487
488 /// Invalidate cached analyses for an IR unit.
489 ///
490 /// Walk through all of the analyses pertaining to this unit of IR and
491 /// invalidate them, unless they are preserved by the PreservedAnalyses set.
492 void invalidate(IRUnitT &IR, const PreservedAnalyses &PA);
493
494 /// Directly clear a cached analysis for an IR unit.
495 ///
496 /// Using invalidate() over this is preferred unless you are really
497 /// sure you want to *only* clear this analysis without asking if it is
498 /// invalid.
499 template <typename AnalysisT> void clearAnalysis(IRUnitT &IR) {
500 AnalysisResultListT &ResultsList = AnalysisResultLists[&IR];
501 AnalysisKey *ID = AnalysisT::ID();
502
503 auto I =
504 llvm::find_if(ResultsList, [&ID](auto &E) { return E.first == ID; });
505 assert(I != ResultsList.end() && "Analysis must be available");
506 ResultsList.erase(I);
507 AnalysisResults.erase({ID, &IR});
508 }
509
510private:
511 /// Look up a registered analysis pass.
512 PassConceptT &lookUpPass(AnalysisKey *ID) {
513 typename AnalysisPassMapT::iterator PI = AnalysisPasses.find(ID);
514 assert(PI != AnalysisPasses.end() &&
515 "Analysis passes must be registered prior to being queried!");
516 return *PI->second;
517 }
518
519 /// Look up a registered analysis pass.
520 const PassConceptT &lookUpPass(AnalysisKey *ID) const {
521 typename AnalysisPassMapT::const_iterator PI = AnalysisPasses.find(ID);
522 assert(PI != AnalysisPasses.end() &&
523 "Analysis passes must be registered prior to being queried!");
524 return *PI->second;
525 }
526
527 /// Get an analysis result, running the pass if necessary.
528 ResultConceptT &getResultImpl(AnalysisKey *ID, IRUnitT &IR,
529 ExtraArgTs... ExtraArgs);
530
531 /// Get a cached analysis result or return null.
532 ResultConceptT *getCachedResultImpl(AnalysisKey *ID, IRUnitT &IR) const {
534 AnalysisResults.find({ID, &IR});
535 return RI == AnalysisResults.end() ? nullptr : &*RI->second->second;
536 }
537
538 /// Map type from analysis pass ID to pass concept pointer.
539 using AnalysisPassMapT =
540 DenseMap<AnalysisKey *, std::unique_ptr<PassConceptT>>;
541
542 /// Collection of analysis passes, indexed by ID.
543 AnalysisPassMapT AnalysisPasses;
544
545 /// Map from IR unit to a list of analysis results.
546 ///
547 /// Provides linear time removal of all analysis results for a IR unit and
548 /// the ultimate storage for a particular cached analysis result.
549 AnalysisResultListMapT AnalysisResultLists;
550
551 /// Map from an analysis ID and IR unit to a particular cached
552 /// analysis result.
553 AnalysisResultMapT AnalysisResults;
554};
555
556extern template class LLVM_TEMPLATE_ABI AnalysisManager<Module>;
557
558/// Convenience typedef for the Module analysis manager.
560
561extern template class LLVM_TEMPLATE_ABI AnalysisManager<Function>;
562
563/// Convenience typedef for the Function analysis manager.
565
566/// An analysis over an "outer" IR unit that provides access to an
567/// analysis manager over an "inner" IR unit. The inner unit must be contained
568/// in the outer unit.
569///
570/// For example, InnerAnalysisManagerProxy<FunctionAnalysisManager, Module> is
571/// an analysis over Modules (the "outer" unit) that provides access to a
572/// Function analysis manager. The FunctionAnalysisManager is the "inner"
573/// manager being proxied, and Functions are the "inner" unit. The inner/outer
574/// relationship is valid because each Function is contained in one Module.
575///
576/// If you're (transitively) within a pass manager for an IR unit U that
577/// contains IR unit V, you should never use an analysis manager over V, except
578/// via one of these proxies.
579///
580/// Note that the proxy's result is a move-only RAII object. The validity of
581/// the analyses in the inner analysis manager is tied to its lifetime.
582template <typename AnalysisManagerT, typename IRUnitT, typename... ExtraArgTs>
584 : public AnalysisInfoMixin<
585 InnerAnalysisManagerProxy<AnalysisManagerT, IRUnitT>> {
586public:
587 class Result {
588 public:
589 explicit Result(AnalysisManagerT &InnerAM) : InnerAM(&InnerAM) {}
590
591 Result(Result &&Arg) : InnerAM(std::move(Arg.InnerAM)) {
592 // We have to null out the analysis manager in the moved-from state
593 // because we are taking ownership of the responsibilty to clear the
594 // analysis state.
595 Arg.InnerAM = nullptr;
596 }
597
599 // InnerAM is cleared in a moved from state where there is nothing to do.
600 if (!InnerAM)
601 return;
602
603 // Clear out the analysis manager if we're being destroyed -- it means we
604 // didn't even see an invalidate call when we got invalidated.
605 InnerAM->clear();
606 }
607
609 InnerAM = RHS.InnerAM;
610 // We have to null out the analysis manager in the moved-from state
611 // because we are taking ownership of the responsibilty to clear the
612 // analysis state.
613 RHS.InnerAM = nullptr;
614 return *this;
615 }
616
617 /// Accessor for the analysis manager.
618 AnalysisManagerT &getManager() { return *InnerAM; }
619
620 /// Handler for invalidation of the outer IR unit, \c IRUnitT.
621 ///
622 /// If the proxy analysis itself is not preserved, we assume that the set of
623 /// inner IR objects contained in IRUnit may have changed. In this case,
624 /// we have to call \c clear() on the inner analysis manager, as it may now
625 /// have stale pointers to its inner IR objects.
626 ///
627 /// Regardless of whether the proxy analysis is marked as preserved, all of
628 /// the analyses in the inner analysis manager are potentially invalidated
629 /// based on the set of preserved analyses.
631 IRUnitT &IR, const PreservedAnalyses &PA,
633
634 private:
635 AnalysisManagerT *InnerAM;
636 };
637
638 explicit InnerAnalysisManagerProxy(AnalysisManagerT &InnerAM)
639 : InnerAM(&InnerAM) {}
640
641 /// Run the analysis pass and create our proxy result object.
642 ///
643 /// This doesn't do any interesting work; it is primarily used to insert our
644 /// proxy result object into the outer analysis cache so that we can proxy
645 /// invalidation to the inner analysis manager.
647 ExtraArgTs...) {
648 return Result(*InnerAM);
649 }
650
651private:
652 friend AnalysisInfoMixin<
654
655 static AnalysisKey Key;
656
657 AnalysisManagerT *InnerAM;
658};
659
660// NOTE: The LLVM_ABI annotation cannot be used here because MSVC disallows
661// storage-class specifiers on class members outside of the class declaration
662// (C2720). LLVM_ATTRIBUTE_VISIBILITY_DEFAULT only applies to non-Windows
663// targets so it is used instead. Without this annotation, compiling LLVM as a
664// shared library with -fvisibility=hidden using GCC fails to export the symbol
665// even though InnerAnalysisManagerProxy is already annotated with LLVM_ABI.
666template <typename AnalysisManagerT, typename IRUnitT, typename... ExtraArgTs>
668 InnerAnalysisManagerProxy<AnalysisManagerT, IRUnitT, ExtraArgTs...>::Key;
669
670/// Provide the \c FunctionAnalysisManager to \c Module proxy.
673
674/// Specialization of the invalidate method for the \c
675/// FunctionAnalysisManagerModuleProxy's result.
676template <>
677LLVM_ABI bool FunctionAnalysisManagerModuleProxy::Result::invalidate(
678 Module &M, const PreservedAnalyses &PA,
680
681// Ensure the \c FunctionAnalysisManagerModuleProxy is provided as an extern
682// template.
684 Module>;
685
686/// An analysis over an "inner" IR unit that provides access to an
687/// analysis manager over a "outer" IR unit. The inner unit must be contained
688/// in the outer unit.
689///
690/// For example OuterAnalysisManagerProxy<ModuleAnalysisManager, Function> is an
691/// analysis over Functions (the "inner" unit) which provides access to a Module
692/// analysis manager. The ModuleAnalysisManager is the "outer" manager being
693/// proxied, and Modules are the "outer" IR unit. The inner/outer relationship
694/// is valid because each Function is contained in one Module.
695///
696/// This proxy only exposes the const interface of the outer analysis manager,
697/// to indicate that you cannot cause an outer analysis to run from within an
698/// inner pass. Instead, you must rely on the \c getCachedResult API. This is
699/// due to keeping potential future concurrency in mind. To give an example,
700/// running a module analysis before any function passes may give a different
701/// result than running it in a function pass. Both may be valid, but it would
702/// produce non-deterministic results. GlobalsAA is a good analysis example,
703/// because the cached information has the mod/ref info for all memory for each
704/// function at the time the analysis was computed. The information is still
705/// valid after a function transformation, but it may be *different* if
706/// recomputed after that transform. GlobalsAA is never invalidated.
707
708///
709/// This proxy doesn't manage invalidation in any way -- that is handled by the
710/// recursive return path of each layer of the pass manager. A consequence of
711/// this is the outer analyses may be stale. We invalidate the outer analyses
712/// only when we're done running passes over the inner IR units.
713template <typename AnalysisManagerT, typename IRUnitT, typename... ExtraArgTs>
715 : public AnalysisInfoMixin<
716 OuterAnalysisManagerProxy<AnalysisManagerT, IRUnitT, ExtraArgTs...>> {
717public:
718 /// Result proxy object for \c OuterAnalysisManagerProxy.
719 class Result {
720 public:
721 explicit Result(const AnalysisManagerT &OuterAM) : OuterAM(&OuterAM) {}
722
723 /// Get a cached analysis. If the analysis can be invalidated, this will
724 /// assert.
725 template <typename PassT, typename IRUnitTParam>
726 typename PassT::Result *getCachedResult(IRUnitTParam &IR) const {
727 typename PassT::Result *Res =
728 OuterAM->template getCachedResult<PassT>(IR);
729 if (Res)
730 OuterAM->template verifyNotInvalidated<PassT>(IR, Res);
731 return Res;
732 }
733
734 /// Method provided for unit testing, not intended for general use.
735 template <typename PassT, typename IRUnitTParam>
736 bool cachedResultExists(IRUnitTParam &IR) const {
737 typename PassT::Result *Res =
738 OuterAM->template getCachedResult<PassT>(IR);
739 return Res != nullptr;
740 }
741
742 /// When invalidation occurs, remove any registered invalidation events.
744 IRUnitT &IRUnit, const PreservedAnalyses &PA,
746 // Loop over the set of registered outer invalidation mappings and if any
747 // of them map to an analysis that is now invalid, clear it out.
749 for (auto &KeyValuePair : OuterAnalysisInvalidationMap) {
750 AnalysisKey *OuterID = KeyValuePair.first;
751 auto &InnerIDs = KeyValuePair.second;
752 llvm::erase_if(InnerIDs, [&](AnalysisKey *InnerID) {
753 return Inv.invalidate(InnerID, IRUnit, PA);
754 });
755 if (InnerIDs.empty())
756 DeadKeys.push_back(OuterID);
757 }
758
759 for (auto *OuterID : DeadKeys)
760 OuterAnalysisInvalidationMap.erase(OuterID);
761
762 // The proxy itself remains valid regardless of anything else.
763 return false;
764 }
765
766 /// Register a deferred invalidation event for when the outer analysis
767 /// manager processes its invalidations.
768 template <typename OuterAnalysisT, typename InvalidatedAnalysisT>
770 AnalysisKey *OuterID = OuterAnalysisT::ID();
771 AnalysisKey *InvalidatedID = InvalidatedAnalysisT::ID();
772
773 auto &InvalidatedIDList = OuterAnalysisInvalidationMap[OuterID];
774 // Note, this is a linear scan. If we end up with large numbers of
775 // analyses that all trigger invalidation on the same outer analysis,
776 // this entire system should be changed to some other deterministic
777 // data structure such as a `SetVector` of a pair of pointers.
778 if (!llvm::is_contained(InvalidatedIDList, InvalidatedID))
779 InvalidatedIDList.push_back(InvalidatedID);
780 }
781
782 /// Access the map from outer analyses to deferred invalidation requiring
783 /// analyses.
786 return OuterAnalysisInvalidationMap;
787 }
788
789 private:
790 const AnalysisManagerT *OuterAM;
791
792 /// A map from an outer analysis ID to the set of this IR-unit's analyses
793 /// which need to be invalidated.
795 OuterAnalysisInvalidationMap;
796 };
797
798 OuterAnalysisManagerProxy(const AnalysisManagerT &OuterAM)
799 : OuterAM(&OuterAM) {}
800
801 /// Run the analysis pass and create our proxy result object.
802 /// Nothing to see here, it just forwards the \c OuterAM reference into the
803 /// result.
805 ExtraArgTs...) {
806 return Result(*OuterAM);
807 }
808
809private:
810 friend AnalysisInfoMixin<
811 OuterAnalysisManagerProxy<AnalysisManagerT, IRUnitT, ExtraArgTs...>>;
812
813 static AnalysisKey Key;
814
815 const AnalysisManagerT *OuterAM;
816};
817
818template <typename AnalysisManagerT, typename IRUnitT, typename... ExtraArgTs>
819AnalysisKey
820 OuterAnalysisManagerProxy<AnalysisManagerT, IRUnitT, ExtraArgTs...>::Key;
821
822extern template class LLVM_TEMPLATE_ABI
824/// Provide the \c ModuleAnalysisManager to \c Function proxy.
827
828/// Trivial adaptor that maps from a module to its functions.
829///
830/// Designed to allow composition of a FunctionPass(Manager) and
831/// a ModulePassManager, by running the FunctionPass(Manager) over every
832/// function in the module.
833///
834/// Function passes run within this adaptor can rely on having exclusive access
835/// to the function they are run over. They should not read or modify any other
836/// functions! Other threads or systems may be manipulating other functions in
837/// the module, and so their state should never be relied on.
838/// FIXME: Make the above true for all of LLVM's actual passes, some still
839/// violate this principle.
840///
841/// Function passes can also read the module containing the function, but they
842/// should not modify that module outside of the use lists of various globals.
843/// For example, a function pass is not permitted to add functions to the
844/// module.
845/// FIXME: Make the above true for all of LLVM's actual passes, some still
846/// violate this principle.
847///
848/// Note that although function passes can access module analyses, module
849/// analyses are not invalidated while the function passes are running, so they
850/// may be stale. Function analyses will not be stale.
853public:
855
856 explicit ModuleToFunctionPassAdaptor(std::unique_ptr<PassConceptT> Pass,
857 bool EagerlyInvalidate)
858 : Pass(std::move(Pass)), EagerlyInvalidate(EagerlyInvalidate) {}
859
860 /// Runs the function pass across every function in the module.
862 LLVM_ABI void
863 printPipeline(raw_ostream &OS,
864 function_ref<StringRef(StringRef)> MapClassName2PassName);
865
866 static bool isRequired() { return true; }
867
868private:
869 std::unique_ptr<PassConceptT> Pass;
870 bool EagerlyInvalidate;
871};
872
873/// A function to deduce a function pass type and wrap it in the
874/// templated adaptor.
875template <typename FunctionPassT>
876ModuleToFunctionPassAdaptor
878 bool EagerlyInvalidate = false) {
879 using PassModelT =
881 // Do not use make_unique, it causes too many template instantiations,
882 // causing terrible compile times.
884 std::unique_ptr<ModuleToFunctionPassAdaptor::PassConceptT>(
885 new PassModelT(std::forward<FunctionPassT>(Pass))),
886 EagerlyInvalidate);
887}
888
889/// A utility pass template to force an analysis result to be available.
890///
891/// If there are extra arguments at the pass's run level there may also be
892/// extra arguments to the analysis manager's \c getResult routine. We can't
893/// guess how to effectively map the arguments from one to the other, and so
894/// this specialization just ignores them.
895///
896/// Specific patterns of run-method extra arguments and analysis manager extra
897/// arguments will have to be defined as appropriate specializations.
898template <typename AnalysisT, typename IRUnitT,
899 typename AnalysisManagerT = AnalysisManager<IRUnitT>,
900 typename... ExtraArgTs>
902 : PassInfoMixin<RequireAnalysisPass<AnalysisT, IRUnitT, AnalysisManagerT,
903 ExtraArgTs...>> {
904 /// Run this pass over some unit of IR.
905 ///
906 /// This pass can be run over any unit of IR and use any analysis manager
907 /// provided they satisfy the basic API requirements. When this pass is
908 /// created, these methods can be instantiated to satisfy whatever the
909 /// context requires.
910 PreservedAnalyses run(IRUnitT &Arg, AnalysisManagerT &AM,
911 ExtraArgTs &&... Args) {
912 (void)AM.template getResult<AnalysisT>(Arg,
913 std::forward<ExtraArgTs>(Args)...);
914
915 return PreservedAnalyses::all();
916 }
918 function_ref<StringRef(StringRef)> MapClassName2PassName) {
919 auto ClassName = AnalysisT::name();
920 auto PassName = MapClassName2PassName(ClassName);
921 OS << "require<" << PassName << '>';
922 }
923 static bool isRequired() { return true; }
924};
925
926/// A no-op pass template which simply forces a specific analysis result
927/// to be invalidated.
928template <typename AnalysisT>
930 : PassInfoMixin<InvalidateAnalysisPass<AnalysisT>> {
931 /// Run this pass over some unit of IR.
932 ///
933 /// This pass can be run over any unit of IR and use any analysis manager,
934 /// provided they satisfy the basic API requirements. When this pass is
935 /// created, these methods can be instantiated to satisfy whatever the
936 /// context requires.
937 template <typename IRUnitT, typename AnalysisManagerT, typename... ExtraArgTs>
938 PreservedAnalyses run(IRUnitT &Arg, AnalysisManagerT &AM, ExtraArgTs &&...) {
939 auto PA = PreservedAnalyses::all();
940 PA.abandon<AnalysisT>();
941 return PA;
942 }
944 function_ref<StringRef(StringRef)> MapClassName2PassName) {
945 auto ClassName = AnalysisT::name();
946 auto PassName = MapClassName2PassName(ClassName);
947 OS << "invalidate<" << PassName << '>';
948 }
949};
950
951/// A utility pass that does nothing, but preserves no analyses.
952///
953/// Because this preserves no analyses, any analysis passes queried after this
954/// pass runs will recompute fresh results.
955struct InvalidateAllAnalysesPass : PassInfoMixin<InvalidateAllAnalysesPass> {
956 /// Run this pass over some unit of IR.
957 template <typename IRUnitT, typename AnalysisManagerT, typename... ExtraArgTs>
958 PreservedAnalyses run(IRUnitT &, AnalysisManagerT &, ExtraArgTs &&...) {
960 }
961};
962
963} // end namespace llvm
964
965#endif // LLVM_IR_PASSMANAGER_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Function Alias Analysis Results
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition: Compiler.h:213
#define LLVM_TEMPLATE_ABI
Definition: Compiler.h:214
#define LLVM_ATTRIBUTE_MINSIZE
Definition: Compiler.h:328
#define LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
Definition: Compiler.h:126
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
std::string Name
uint64_t Size
Legalize the Machine IR a function s Machine IR
Definition: Legalizer.cpp:80
#define I(x, y, z)
Definition: MD5.cpp:58
Machine Check Debug Module
#define P(N)
This header provides internal APIs and implementation details used by the pass management interfaces ...
This file contains some templates that are useful if you are working with the STL at all.
raw_pwrite_stream & OS
static const char PassName[]
Value * RHS
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:294
bool invalidate(AnalysisKey *ID, IRUnitT &IR, const PreservedAnalyses &PA)
A type-erased variant of the above invalidate method with the same core API other than passing an ana...
Definition: PassManager.h:326
bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA)
Trigger the invalidation of some other analysis pass if not already handled and return whether it was...
Definition: PassManager.h:312
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:255
bool isPassRegistered() const
Returns true if the specified analysis pass is registered.
Definition: PassManager.h:404
AnalysisManager()
Construct an empty analysis manager.
void clear()
Clear all analysis results cached by this AnalysisManager.
Definition: PassManager.h:398
AnalysisManager(AnalysisManager &&)
void verifyNotInvalidated(IRUnitT &IR, typename PassT::Result *Result) const
Verify that the given Result cannot be invalidated, assert otherwise.
Definition: PassManager.h:448
AnalysisManager & operator=(AnalysisManager &&)
void invalidate(IRUnitT &IR, const PreservedAnalyses &PA)
Invalidate cached analyses for an IR unit.
void clearAnalysis(IRUnitT &IR)
Directly clear a cached analysis for an IR unit.
Definition: PassManager.h:499
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
Definition: PassManager.h:431
bool registerPass(PassBuilderT &&PassBuilder)
Register an analysis pass with the manager.
Definition: PassManager.h:473
bool empty() const
Returns true if the analysis manager has an empty results cache.
Definition: PassManager.h:378
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:412
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:177
bool erase(const KeyT &Val)
Definition: DenseMap.h:319
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
Definition: DenseMap.h:74
bool empty() const
Definition: DenseMap.h:119
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition: DenseMap.h:173
iterator end()
Definition: DenseMap.h:87
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT, true > const_iterator
Definition: DenseMap.h:76
bool invalidate(IRUnitT &IR, const PreservedAnalyses &PA, typename AnalysisManager< IRUnitT, ExtraArgTs... >::Invalidator &Inv)
Handler for invalidation of the outer IR unit, IRUnitT.
Result(AnalysisManagerT &InnerAM)
Definition: PassManager.h:589
AnalysisManagerT & getManager()
Accessor for the analysis manager.
Definition: PassManager.h:618
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
Definition: PassManager.h:585
Result run(IRUnitT &IR, AnalysisManager< IRUnitT, ExtraArgTs... > &AM, ExtraArgTs...)
Run the analysis pass and create our proxy result object.
Definition: PassManager.h:646
InnerAnalysisManagerProxy(AnalysisManagerT &InnerAM)
Definition: PassManager.h:638
Trivial adaptor that maps from a module to its functions.
Definition: PassManager.h:852
ModuleToFunctionPassAdaptor(std::unique_ptr< PassConceptT > Pass, bool EagerlyInvalidate)
Definition: PassManager.h:856
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
Result proxy object for OuterAnalysisManagerProxy.
Definition: PassManager.h:719
Result(const AnalysisManagerT &OuterAM)
Definition: PassManager.h:721
PassT::Result * getCachedResult(IRUnitTParam &IR) const
Get a cached analysis.
Definition: PassManager.h:726
bool invalidate(IRUnitT &IRUnit, const PreservedAnalyses &PA, typename AnalysisManager< IRUnitT, ExtraArgTs... >::Invalidator &Inv)
When invalidation occurs, remove any registered invalidation events.
Definition: PassManager.h:743
bool cachedResultExists(IRUnitTParam &IR) const
Method provided for unit testing, not intended for general use.
Definition: PassManager.h:736
const SmallDenseMap< AnalysisKey *, TinyPtrVector< AnalysisKey * >, 2 > & getOuterInvalidations() const
Access the map from outer analyses to deferred invalidation requiring analyses.
Definition: PassManager.h:785
void registerOuterAnalysisInvalidation()
Register a deferred invalidation event for when the outer analysis manager processes its invalidation...
Definition: PassManager.h:769
An analysis over an "inner" IR unit that provides access to an analysis manager over a "outer" IR uni...
Definition: PassManager.h:716
Result run(IRUnitT &, AnalysisManager< IRUnitT, ExtraArgTs... > &, ExtraArgTs...)
Run the analysis pass and create our proxy result object.
Definition: PassManager.h:804
OuterAnalysisManagerProxy(const AnalysisManagerT &OuterAM)
Definition: PassManager.h:798
This class provides access to building LLVM's passes.
Definition: PassBuilder.h:110
Manages a sequence of passes over a particular unit of IR.
Definition: PassManager.h:163
PassManager(PassManager &&Arg)
Definition: PassManager.h:172
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
Definition: PassManager.h:179
PassManager & operator=(PassManager &&RHS)
Definition: PassManager.h:174
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same_v< PassT, PassManager > > addPass(PassT &&Pass)
Definition: PassManager.h:196
std::vector< std::unique_ptr< PassConceptT > > Passes
Definition: PassManager.h:226
PassManager()=default
Construct a pass manager.
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t< std::is_same_v< PassT, PassManager > > addPass(PassT &&Pass)
When adding a pass manager pass that has the same type as this pass manager, simply move the passes o...
Definition: PassManager.h:212
static bool isRequired()
Definition: PassManager.h:220
PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT &AM, ExtraArgTs... ExtraArgs)
Run all of the passes in this manager over the given unit of IR.
bool isEmpty() const
Returns if the pass manager contains any passes.
Definition: PassManager.h:218
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:99
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:112
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition: Analysis.h:115
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: Analysis.h:118
PreservedAnalyses & abandon()
Mark an analysis as abandoned.
Definition: Analysis.h:171
void push_back(const T &Elt)
Definition: SmallVector.h:414
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
Pass manager infrastructure for declaring and invalidating analyses.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
PassT::Result getAnalysisResultUnpackTuple(AnalysisManagerT &AM, IRUnitT &IR, std::tuple< ArgTs... > Args, std::index_sequence< Ns... >)
Actual unpacker of extra arguments in getAnalysisResult, passes only those tuple arguments that are m...
Definition: PassManager.h:123
PassT::Result getAnalysisResult(AnalysisManager< IRUnitT, AnalysisArgTs... > &AM, IRUnitT &IR, std::tuple< MainArgTs... > Args)
Helper for partial unpacking of extra arguments in getAnalysisResult.
Definition: PassManager.h:138
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
ModuleToFunctionPassAdaptor createModuleToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
Definition: PassManager.h:877
template class LLVM_TEMPLATE_ABI OuterAnalysisManagerProxy< ModuleAnalysisManager, Function >
Definition: PassManager.cpp:28
template class LLVM_TEMPLATE_ABI AnalysisManager< Module >
Definition: PassManager.cpp:24
LLVM_ABI void printIRUnitNameForStackTrace< Function >(raw_ostream &OS, const Function &IR)
void printIRUnitNameForStackTrace(raw_ostream &OS, const IRUnitT &IR)
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
Definition: PassManager.h:564
LLVM_ABI void printIRUnitNameForStackTrace< Module >(raw_ostream &OS, const Module &IR)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1886
template class LLVM_TEMPLATE_ABI AnalysisManager< Function >
Definition: PassManager.cpp:25
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1777
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
Definition: STLExtras.h:2139
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition: STLExtras.h:1916
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition: MIRParser.h:39
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:856
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:93
static AnalysisKey * ID()
Returns an opaque, unique ID for this analysis type.
Definition: PassManager.h:109
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: Analysis.h:29
A utility pass that does nothing, but preserves no analyses.
Definition: PassManager.h:955
PreservedAnalyses run(IRUnitT &, AnalysisManagerT &, ExtraArgTs &&...)
Run this pass over some unit of IR.
Definition: PassManager.h:958
A no-op pass template which simply forces a specific analysis result to be invalidated.
Definition: PassManager.h:930
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
Definition: PassManager.h:943
PreservedAnalyses run(IRUnitT &Arg, AnalysisManagerT &AM, ExtraArgTs &&...)
Run this pass over some unit of IR.
Definition: PassManager.h:938
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:70
static StringRef name()
Gets the name of the pass we are mixed into.
Definition: PassManager.h:72
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
Definition: PassManager.h:80
A utility pass template to force an analysis result to be available.
Definition: PassManager.h:903
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
Definition: PassManager.h:917
static bool isRequired()
Definition: PassManager.h:923
PreservedAnalyses run(IRUnitT &Arg, AnalysisManagerT &AM, ExtraArgTs &&... Args)
Run this pass over some unit of IR.
Definition: PassManager.h:910
Abstract concept of an analysis pass.
Wrapper to model the analysis pass concept.
Abstract concept of an analysis result.
Wrapper to model the analysis result concept.
A template wrapper used to implement the polymorphic API.