LLVM 20.0.0git
StandardInstrumentations.h
Go to the documentation of this file.
1//===- StandardInstrumentations.h ------------------------------*- 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 a class that provides bookkeeping for all standard
11/// (i.e in-tree) pass instrumentations.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_PASSES_STANDARDINSTRUMENTATIONS_H
16#define LLVM_PASSES_STANDARDINSTRUMENTATIONS_H
17
18#include "llvm/ADT/STLExtras.h"
20#include "llvm/ADT/StringRef.h"
21#include "llvm/ADT/StringSet.h"
23#include "llvm/IR/BasicBlock.h"
25#include "llvm/IR/OptBisect.h"
27#include "llvm/IR/ValueHandle.h"
32
33#include <string>
34#include <utility>
35
36namespace llvm {
37
38class Module;
39class Function;
40class MachineFunction;
41class PassInstrumentationCallbacks;
42
43/// Instrumentation to print IR before/after passes.
44///
45/// Needs state to be able to print module after pass that invalidates IR unit
46/// (typically Loop or SCC).
48public:
50
52
53private:
54 struct PassRunDescriptor {
55 const Module *M;
56 const std::string DumpIRFilename;
57 const std::string IRName;
58 const StringRef PassID;
59
60 PassRunDescriptor(const Module *M, std::string DumpIRFilename,
61 std::string IRName, const StringRef PassID)
62 : M{M}, DumpIRFilename{DumpIRFilename}, IRName{IRName}, PassID(PassID) {
63 }
64 };
65
66 void printBeforePass(StringRef PassID, Any IR);
67 void printAfterPass(StringRef PassID, Any IR);
68 void printAfterPassInvalidated(StringRef PassID);
69
70 bool shouldPrintBeforePass(StringRef PassID);
71 bool shouldPrintAfterPass(StringRef PassID);
72 bool shouldPrintBeforeCurrentPassNumber();
73 bool shouldPrintAfterCurrentPassNumber();
74 bool shouldPrintPassNumbers();
75 bool shouldPrintBeforeSomePassNumber();
76 bool shouldPrintAfterSomePassNumber();
77
78 void pushPassRunDescriptor(StringRef PassID, Any IR,
79 std::string &DumpIRFilename);
80 PassRunDescriptor popPassRunDescriptor(StringRef PassID);
81 std::string fetchDumpFilename(StringRef PassId, Any IR);
82
84 /// Stack of Pass Run descriptions, enough to print the IR unit after a given
85 /// pass.
86 SmallVector<PassRunDescriptor, 2> PassRunDescriptorStack;
87
88 /// Used for print-at-pass-number
89 unsigned CurrentPassNumber = 0;
90};
91
93public:
94 OptNoneInstrumentation(bool DebugLogging) : DebugLogging(DebugLogging) {}
96
97private:
98 bool DebugLogging;
99 bool shouldRun(StringRef PassID, Any IR);
100};
101
103 LLVMContext &Context;
104 bool HasWrittenIR = false;
105public:
106 OptPassGateInstrumentation(LLVMContext &Context) : Context(Context) {}
109};
110
112 /// Print adaptors and pass managers.
113 bool Verbose = false;
114 /// Don't print information for analyses.
115 bool SkipAnalyses = false;
116 /// Indent based on hierarchy.
117 bool Indent = false;
118};
119
120// Debug logging for transformation and analysis passes.
122 raw_ostream &print();
123
124public:
126 : Enabled(Enabled), Opts(Opts) {}
128
129private:
130 bool Enabled;
131 PrintPassOptions Opts;
132 int Indent = 0;
133};
134
136public:
137 // Keeps sticky poisoned flag for the given basic block once it has been
138 // deleted or RAUWed.
139 struct BBGuard final : public CallbackVH {
140 BBGuard(const BasicBlock *BB) : CallbackVH(BB) {}
141 void deleted() override { CallbackVH::deleted(); }
143 bool isPoisoned() const { return !getValPtr(); }
144 };
145
146 // CFG is a map BB -> {(Succ, Multiplicity)}, where BB is a non-leaf basic
147 // block, {(Succ, Multiplicity)} set of all pairs of the block's successors
148 // and the multiplicity of the edge (BB->Succ). As the mapped sets are
149 // unordered the order of successors is not tracked by the CFG. In other words
150 // this allows basic block successors to be swapped by a pass without
151 // reporting a CFG change. CFG can be guarded by basic block tracking pointers
152 // in the Graph (BBGuard). That is if any of the block is deleted or RAUWed
153 // then the CFG is treated poisoned and no block pointer of the Graph is used.
154 struct CFG {
155 std::optional<DenseMap<intptr_t, BBGuard>> BBGuards;
157
158 CFG(const Function *F, bool TrackBBLifetime);
159
160 bool operator==(const CFG &G) const {
161 return !isPoisoned() && !G.isPoisoned() && Graph == G.Graph;
162 }
163
164 bool isPoisoned() const {
165 return BBGuards && llvm::any_of(*BBGuards, [](const auto &BB) {
166 return BB.second.isPoisoned();
167 });
168 }
169
170 static void printDiff(raw_ostream &out, const CFG &Before,
171 const CFG &After);
172 bool invalidate(Function &F, const PreservedAnalyses &PA,
174 };
175
176#if LLVM_ENABLE_ABI_BREAKING_CHECKS
178#endif
179
182};
183
184// Base class for classes that report changes to the IR.
185// It presents an interface for such classes and provides calls
186// on various events as the new pass manager transforms the IR.
187// It also provides filtering of information based on hidden options
188// specifying which functions are interesting.
189// Calls are made for the following events/queries:
190// 1. The initial IR processed.
191// 2. To get the representation of the IR (of type \p T).
192// 3. When a pass does not change the IR.
193// 4. When a pass changes the IR (given both before and after representations
194// of type \p T).
195// 5. When an IR is invalidated.
196// 6. When a pass is run on an IR that is not interesting (based on options).
197// 7. When a pass is ignored (pass manager or adapter pass).
198// 8. To compare two IR representations (of type \p T).
199template <typename IRUnitT> class ChangeReporter {
200protected:
201 ChangeReporter(bool RunInVerboseMode) : VerboseMode(RunInVerboseMode) {}
202
203public:
204 virtual ~ChangeReporter();
205
206 // Determine if this pass/IR is interesting and if so, save the IR
207 // otherwise it is left on the stack without data.
209 // Compare the IR from before the pass after the pass.
211 // Handle the situation where a pass is invalidated.
212 void handleInvalidatedPass(StringRef PassID);
213
214protected:
215 // Register required callbacks.
217
218 // Called on the first IR processed.
219 virtual void handleInitialIR(Any IR) = 0;
220 // Called before and after a pass to get the representation of the IR.
222 IRUnitT &Output) = 0;
223 // Called when the pass is not iteresting.
224 virtual void omitAfter(StringRef PassID, std::string &Name) = 0;
225 // Called when an interesting IR has changed.
226 virtual void handleAfter(StringRef PassID, std::string &Name,
227 const IRUnitT &Before, const IRUnitT &After,
228 Any) = 0;
229 // Called when an interesting pass is invalidated.
230 virtual void handleInvalidated(StringRef PassID) = 0;
231 // Called when the IR or pass is not interesting.
232 virtual void handleFiltered(StringRef PassID, std::string &Name) = 0;
233 // Called when an ignored pass is encountered.
234 virtual void handleIgnored(StringRef PassID, std::string &Name) = 0;
235
236 // Stack of IRs before passes.
237 std::vector<IRUnitT> BeforeStack;
238 // Is this the first IR seen?
239 bool InitialIR = true;
240
241 // Run in verbose mode, printing everything?
242 const bool VerboseMode;
243};
244
245// An abstract template base class that handles printing banners and
246// reporting when things have not changed or are filtered out.
247template <typename IRUnitT>
248class TextChangeReporter : public ChangeReporter<IRUnitT> {
249protected:
251
252 // Print a module dump of the first IR that is changed.
253 void handleInitialIR(Any IR) override;
254 // Report that the IR was omitted because it did not change.
255 void omitAfter(StringRef PassID, std::string &Name) override;
256 // Report that the pass was invalidated.
257 void handleInvalidated(StringRef PassID) override;
258 // Report that the IR was filtered out.
259 void handleFiltered(StringRef PassID, std::string &Name) override;
260 // Report that the pass was ignored.
261 void handleIgnored(StringRef PassID, std::string &Name) override;
262 // Make substitutions in \p S suitable for reporting changes
263 // after the pass and then print it.
264
266};
267
268// A change printer based on the string representation of the IR as created
269// by unwrapAndPrint. The string representation is stored in a std::string
270// to preserve it as the IR changes in each pass. Note that the banner is
271// included in this representation but it is massaged before reporting.
272class IRChangedPrinter : public TextChangeReporter<std::string> {
273public:
278
279protected:
280 // Called before and after a pass to get the representation of the IR.
282 std::string &Output) override;
283 // Called when an interesting IR has changed.
284 void handleAfter(StringRef PassID, std::string &Name,
285 const std::string &Before, const std::string &After,
286 Any) override;
287};
288
290public:
292 ~IRChangedTester() override;
294
295protected:
296 void handleIR(const std::string &IR, StringRef PassID);
297
298 // Check initial IR
299 void handleInitialIR(Any IR) override;
300 // Do nothing.
301 void omitAfter(StringRef PassID, std::string &Name) override;
302 // Do nothing.
303 void handleInvalidated(StringRef PassID) override;
304 // Do nothing.
305 void handleFiltered(StringRef PassID, std::string &Name) override;
306 // Do nothing.
307 void handleIgnored(StringRef PassID, std::string &Name) override;
308
309 // Call test as interesting IR has changed.
310 void handleAfter(StringRef PassID, std::string &Name,
311 const std::string &Before, const std::string &After,
312 Any) override;
313};
314
315// Information that needs to be saved for a basic block in order to compare
316// before and after the pass to determine if it was changed by a pass.
317template <typename T> class BlockDataT {
318public:
319 BlockDataT(const BasicBlock &B) : Label(B.getName().str()), Data(B) {
321 B.print(SS, nullptr, true, true);
322 }
323
326 B.print(SS);
327 }
328
329 bool operator==(const BlockDataT &That) const { return Body == That.Body; }
330 bool operator!=(const BlockDataT &That) const { return Body != That.Body; }
331
332 // Return the label of the represented basic block.
333 StringRef getLabel() const { return Label; }
334 // Return the string representation of the basic block.
335 StringRef getBody() const { return Body; }
336
337 // Return the associated data
338 const T &getData() const { return Data; }
339
340protected:
341 std::string Label;
342 std::string Body;
343
344 // Extra data associated with a basic block
346};
347
348template <typename T> class OrderedChangedData {
349public:
350 // Return the names in the order they were saved
351 std::vector<std::string> &getOrder() { return Order; }
352 const std::vector<std::string> &getOrder() const { return Order; }
353
354 // Return a map of names to saved representations
355 StringMap<T> &getData() { return Data; }
356 const StringMap<T> &getData() const { return Data; }
357
358 bool operator==(const OrderedChangedData<T> &That) const {
359 return Data == That.getData();
360 }
361
362 // Call the lambda \p HandlePair on each corresponding pair of data from
363 // \p Before and \p After. The order is based on the order in \p After
364 // with ones that are only in \p Before interspersed based on where they
365 // occur in \p Before. This is used to present the output in an order
366 // based on how the data is ordered in LLVM.
367 static void report(const OrderedChangedData &Before,
369 function_ref<void(const T *, const T *)> HandlePair);
370
371protected:
372 std::vector<std::string> Order;
374};
375
376// Do not need extra information for patch-style change reporter.
378public:
381};
382
383// The data saved for comparing functions.
384template <typename T>
385class FuncDataT : public OrderedChangedData<BlockDataT<T>> {
386public:
387 FuncDataT(std::string S) : EntryBlockName(S) {}
388
389 // Return the name of the entry block
390 std::string getEntryBlockName() const { return EntryBlockName; }
391
392protected:
393 std::string EntryBlockName;
394};
395
396// The data saved for comparing IRs.
397template <typename T>
398class IRDataT : public OrderedChangedData<FuncDataT<T>> {};
399
400// Abstract template base class for a class that compares two IRs. The
401// class is created with the 2 IRs to compare and then compare is called.
402// The static function analyzeIR is used to build up the IR representation.
403template <typename T> class IRComparer {
404public:
406 : Before(Before), After(After) {}
407
408 // Compare the 2 IRs. \p handleFunctionCompare is called to handle the
409 // compare of a function. When \p InModule is set,
410 // this function is being handled as part of comparing a module.
411 void compare(
412 bool CompareModule,
413 std::function<void(bool InModule, unsigned Minor,
414 const FuncDataT<T> &Before, const FuncDataT<T> &After)>
415 CompareFunc);
416
417 // Analyze \p IR and build the IR representation in \p Data.
418 static void analyzeIR(Any IR, IRDataT<T> &Data);
419
420protected:
421 // Generate the data for \p F into \p Data.
422 template <typename FunctionT>
423 static bool generateFunctionData(IRDataT<T> &Data, const FunctionT &F);
424
427};
428
429// A change printer that prints out in-line differences in the basic
430// blocks. It uses an InlineComparer to do the comparison so it shows
431// the differences prefixed with '-' and '+' for code that is removed
432// and added, respectively. Changes to the IR that do not affect basic
433// blocks are not reported as having changed the IR. The option
434// -print-module-scope does not affect this change reporter.
435class InLineChangePrinter : public TextChangeReporter<IRDataT<EmptyData>> {
436public:
437 InLineChangePrinter(bool VerboseMode, bool ColourMode)
439 UseColour(ColourMode) {}
442
443protected:
444 // Create a representation of the IR.
446 IRDataT<EmptyData> &Output) override;
447
448 // Called when an interesting IR has changed.
449 void handleAfter(StringRef PassID, std::string &Name,
451 const IRDataT<EmptyData> &After, Any) override;
452
454 StringRef Divider, bool InModule, unsigned Minor,
457
459};
460
462 bool DebugLogging;
463
464public:
465 VerifyInstrumentation(bool DebugLogging) : DebugLogging(DebugLogging) {}
468};
469
470/// This class implements --time-trace functionality for new pass manager.
471/// It provides the pass-instrumentation callbacks that measure the pass
472/// execution time. They collect time tracing info by TimeProfiler.
474public:
476 // We intend this to be unique per-compilation, thus no copies.
478 void operator=(const TimeProfilingPassesHandler &) = delete;
479
481
482private:
483 // Implementation of pass instrumentation callbacks.
484 void runBeforePass(StringRef PassID, Any IR);
485 void runAfterPass();
486};
487
488// Class that holds transitions between basic blocks. The transitions
489// are contained in a map of values to names of basic blocks.
490class DCData {
491public:
492 // Fill the map with the transitions from basic block \p B.
493 DCData(const BasicBlock &B);
494 DCData(const MachineBasicBlock &B);
495
496 // Return an iterator to the names of the successor blocks.
498 return Successors.begin();
499 }
501 return Successors.end();
502 }
503
504 // Return the label of the basic block reached on a transition on \p S.
506 assert(Successors.count(S) == 1 && "Expected to find successor.");
507 return Successors.find(S)->getValue();
508 }
509
510protected:
511 // Add a transition to \p Succ on \p Label
513 std::pair<std::string, std::string> SS{Succ.str(), Label.str()};
514 Successors.insert(SS);
515 }
516
518};
519
520// A change reporter that builds a website with links to pdf files showing
521// dot control flow graphs with changed instructions shown in colour.
522class DotCfgChangeReporter : public ChangeReporter<IRDataT<DCData>> {
523public:
525 ~DotCfgChangeReporter() override;
527
528protected:
529 // Initialize the HTML file and output the header.
530 bool initializeHTML();
531
532 // Called on the first IR processed.
533 void handleInitialIR(Any IR) override;
534 // Called before and after a pass to get the representation of the IR.
536 IRDataT<DCData> &Output) override;
537 // Called when the pass is not iteresting.
538 void omitAfter(StringRef PassID, std::string &Name) override;
539 // Called when an interesting IR has changed.
540 void handleAfter(StringRef PassID, std::string &Name,
542 Any) override;
543 // Called when an interesting pass is invalidated.
544 void handleInvalidated(StringRef PassID) override;
545 // Called when the IR or pass is not interesting.
546 void handleFiltered(StringRef PassID, std::string &Name) override;
547 // Called when an ignored pass is encountered.
548 void handleIgnored(StringRef PassID, std::string &Name) override;
549
550 // Generate the pdf file into \p Dir / \p PDFFileName using \p DotFile as
551 // input and return the html <a> tag with \Text as the content.
552 static std::string genHTML(StringRef Text, StringRef DotFile,
553 StringRef PDFFileName);
554
556 StringRef Divider, bool InModule, unsigned Minor,
558 const FuncDataT<DCData> &After);
559
560 unsigned N = 0;
561 std::unique_ptr<raw_fd_ostream> HTML;
562};
563
564// Print IR on crash.
566public:
568 : SavedIR("*** Dump of IR Before Last Pass Unknown ***") {}
571 void reportCrashIR();
572
573protected:
574 std::string SavedIR;
575
576private:
577 // The crash reporter that will report on a crash.
578 static PrintCrashIRInstrumentation *CrashReporter;
579 // Crash handler registered when print-on-crash is specified.
580 static void SignalHandler(void *);
581};
582
583/// This class provides an interface to register all the standard pass
584/// instrumentations and manages their state (if any).
587 PrintPassInstrumentation PrintPass;
588 TimePassesHandler TimePasses;
589 TimeProfilingPassesHandler TimeProfilingPasses;
592 PreservedCFGCheckerInstrumentation PreservedCFGChecker;
593 IRChangedPrinter PrintChangedIR;
594 PseudoProbeVerifier PseudoProbeVerification;
595 InLineChangePrinter PrintChangedDiff;
596 DotCfgChangeReporter WebsiteChangeReporter;
597 PrintCrashIRInstrumentation PrintCrashIR;
598 IRChangedTester ChangeTester;
600 DroppedVariableStatsIR DroppedStatsIR;
601
602 bool VerifyEach;
603
604public:
605 StandardInstrumentations(LLVMContext &Context, bool DebugLogging,
606 bool VerifyEach = false,
607 PrintPassOptions PrintPassOpts = PrintPassOptions());
608
609 // Register all the standard instrumentation callbacks. If \p FAM is nullptr
610 // then PreservedCFGChecker is not enabled.
612 ModuleAnalysisManager *MAM = nullptr);
613
614 TimePassesHandler &getTimePasses() { return TimePasses; }
615};
616
617extern template class ChangeReporter<std::string>;
618extern template class TextChangeReporter<std::string>;
619
620extern template class BlockDataT<EmptyData>;
621extern template class FuncDataT<EmptyData>;
622extern template class IRDataT<EmptyData>;
623extern template class ChangeReporter<IRDataT<EmptyData>>;
624extern template class TextChangeReporter<IRDataT<EmptyData>>;
625extern template class IRComparer<EmptyData>;
626
627} // namespace llvm
628
629#endif
basic Basic Alias true
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
===- DroppedVariableStatsIR.h - Opt Diagnostics -*- C++ -*-----------—===//
std::string Name
Legalize the Machine IR a function s Machine IR
Definition: Legalizer.cpp:80
#define F(x, y, z)
Definition: MD5.cpp:55
#define G(x, y, z)
Definition: MD5.cpp:56
Machine Check Debug Module
This file declares the interface for bisecting optimizations.
ModuleAnalysisManager MAM
bool VerifyEach
PassInstrumentationCallbacks PIC
This header defines classes/functions to handle pass execution timing information with interfaces for...
static StringRef getName(Value *V)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some templates that are useful if you are working with the STL at all.
This file provides the interface for the pseudo probe implementation for AutoFDO.
This file defines the SmallVector class.
StringSet - A set-like wrapper for the StringMap.
static const char PassName[]
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:292
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
Definition: Any.h:28
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
bool operator!=(const BlockDataT &That) const
bool operator==(const BlockDataT &That) const
StringRef getLabel() const
BlockDataT(const MachineBasicBlock &B)
BlockDataT(const BasicBlock &B)
const T & getData() const
StringRef getBody() const
Value handle with callbacks on RAUW and destruction.
Definition: ValueHandle.h:383
virtual void deleted()
Callback for Value destruction.
Definition: ValueHandle.h:414
void saveIRBeforePass(Any IR, StringRef PassID, StringRef PassName)
virtual void handleFiltered(StringRef PassID, std::string &Name)=0
virtual void handleAfter(StringRef PassID, std::string &Name, const IRUnitT &Before, const IRUnitT &After, Any)=0
virtual void handleIgnored(StringRef PassID, std::string &Name)=0
virtual void generateIRRepresentation(Any IR, StringRef PassID, IRUnitT &Output)=0
virtual void handleInitialIR(Any IR)=0
void handleIRAfterPass(Any IR, StringRef PassID, StringRef PassName)
virtual void handleInvalidated(StringRef PassID)=0
void registerRequiredCallbacks(PassInstrumentationCallbacks &PIC)
std::vector< IRUnitT > BeforeStack
virtual void omitAfter(StringRef PassID, std::string &Name)=0
void handleInvalidatedPass(StringRef PassID)
ChangeReporter(bool RunInVerboseMode)
void addSuccessorLabel(StringRef Succ, StringRef Label)
StringRef getSuccessorLabel(StringRef S) const
StringMap< std::string > Successors
StringMap< std::string >::const_iterator end() const
StringMap< std::string >::const_iterator begin() const
std::unique_ptr< raw_fd_ostream > HTML
void handleInvalidated(StringRef PassID) override
void generateIRRepresentation(Any IR, StringRef PassID, IRDataT< DCData > &Output) override
static std::string genHTML(StringRef Text, StringRef DotFile, StringRef PDFFileName)
void handleFunctionCompare(StringRef Name, StringRef Prefix, StringRef PassID, StringRef Divider, bool InModule, unsigned Minor, const FuncDataT< DCData > &Before, const FuncDataT< DCData > &After)
void registerCallbacks(PassInstrumentationCallbacks &PIC)
void handleIgnored(StringRef PassID, std::string &Name) override
void handleAfter(StringRef PassID, std::string &Name, const IRDataT< DCData > &Before, const IRDataT< DCData > &After, Any) override
void handleFiltered(StringRef PassID, std::string &Name) override
void omitAfter(StringRef PassID, std::string &Name) override
A class to collect and print dropped debug information due to LLVM IR optimization passes.
EmptyData(const MachineBasicBlock &)
EmptyData(const BasicBlock &)
std::string getEntryBlockName() const
~IRChangedPrinter() override
void handleAfter(StringRef PassID, std::string &Name, const std::string &Before, const std::string &After, Any) override
void registerCallbacks(PassInstrumentationCallbacks &PIC)
void generateIRRepresentation(Any IR, StringRef PassID, std::string &Output) override
void handleIgnored(StringRef PassID, std::string &Name) override
void handleAfter(StringRef PassID, std::string &Name, const std::string &Before, const std::string &After, Any) override
void omitAfter(StringRef PassID, std::string &Name) override
void handleInvalidated(StringRef PassID) override
void handleIR(const std::string &IR, StringRef PassID)
void handleInitialIR(Any IR) override
void registerCallbacks(PassInstrumentationCallbacks &PIC)
void handleFiltered(StringRef PassID, std::string &Name) override
const IRDataT< T > & Before
static bool generateFunctionData(IRDataT< T > &Data, const FunctionT &F)
const IRDataT< T > & After
IRComparer(const IRDataT< T > &Before, const IRDataT< T > &After)
static void analyzeIR(Any IR, IRDataT< T > &Data)
void compare(bool CompareModule, std::function< void(bool InModule, unsigned Minor, const FuncDataT< T > &Before, const FuncDataT< T > &After)> CompareFunc)
void registerCallbacks(PassInstrumentationCallbacks &PIC)
InLineChangePrinter(bool VerboseMode, bool ColourMode)
void handleAfter(StringRef PassID, std::string &Name, const IRDataT< EmptyData > &Before, const IRDataT< EmptyData > &After, Any) override
void generateIRRepresentation(Any IR, StringRef PassID, IRDataT< EmptyData > &Output) override
void handleFunctionCompare(StringRef Name, StringRef Prefix, StringRef PassID, StringRef Divider, bool InModule, unsigned Minor, const FuncDataT< EmptyData > &Before, const FuncDataT< EmptyData > &After)
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
void registerCallbacks(PassInstrumentationCallbacks &PIC)
OptPassGateInstrumentation(LLVMContext &Context)
void registerCallbacks(PassInstrumentationCallbacks &PIC)
bool shouldRun(StringRef PassName, Any IR)
Extensions to this class implement mechanisms to disable passes and individual optimizations at compi...
Definition: OptBisect.h:24
bool operator==(const OrderedChangedData< T > &That) const
static void report(const OrderedChangedData &Before, const OrderedChangedData &After, function_ref< void(const T *, const T *)> HandlePair)
const std::vector< std::string > & getOrder() const
std::vector< std::string > Order
const StringMap< T > & getData() const
std::vector< std::string > & getOrder()
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
void registerCallbacks(PassInstrumentationCallbacks &PIC, ModuleAnalysisManager &MAM)
void registerCallbacks(PassInstrumentationCallbacks &PIC)
Instrumentation to print IR before/after passes.
void registerCallbacks(PassInstrumentationCallbacks &PIC)
void registerCallbacks(PassInstrumentationCallbacks &PIC)
PrintPassInstrumentation(bool Enabled, PrintPassOptions Opts)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
This class provides an interface to register all the standard pass instrumentations and manages their...
void registerCallbacks(PassInstrumentationCallbacks &PIC, ModuleAnalysisManager *MAM=nullptr)
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:128
iterator end()
Definition: StringMap.h:220
iterator begin()
Definition: StringMap.h:219
iterator find(StringRef Key)
Definition: StringMap.h:233
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Definition: StringMap.h:276
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:308
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:229
void handleInitialIR(Any IR) override
void handleInvalidated(StringRef PassID) override
void omitAfter(StringRef PassID, std::string &Name) override
void handleIgnored(StringRef PassID, std::string &Name) override
void handleFiltered(StringRef PassID, std::string &Name) override
This class implements -time-passes functionality for new pass manager.
This class implements –time-trace functionality for new pass manager.
void registerCallbacks(PassInstrumentationCallbacks &PIC)
void operator=(const TimeProfilingPassesHandler &)=delete
TimeProfilingPassesHandler(const TimeProfilingPassesHandler &)=delete
Value * getValPtr() const
Definition: ValueHandle.h:99
LLVM Value Representation.
Definition: Value.h:74
void registerCallbacks(PassInstrumentationCallbacks &PIC, ModuleAnalysisManager *MAM)
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:52
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:661
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1746
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
void deleted() override
Callback for Value destruction.
void allUsesReplacedWith(Value *) override
Callback for Value RAUW.
std::optional< DenseMap< intptr_t, BBGuard > > BBGuards
static void printDiff(raw_ostream &out, const CFG &Before, const CFG &After)
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
DenseMap< const BasicBlock *, DenseMap< const BasicBlock *, unsigned > > Graph
bool SkipAnalyses
Don't print information for analyses.
bool Verbose
Print adaptors and pass managers.
bool Indent
Indent based on hierarchy.