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