LLVM 24.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"
26#include "llvm/IR/IRUnitRef.h"
27#include "llvm/IR/OptBisect.h"
29#include "llvm/IR/ValueHandle.h"
34
35#include <string>
36#include <utility>
37
38namespace llvm {
39
40class Module;
41class Function;
42class MachineFunction;
44
45/// Instrumentation to print IR before/after passes.
46///
47/// Needs state to be able to print module after pass that invalidates IR unit
48/// (typically Loop or SCC).
50public:
52
54
55private:
56 struct PassRunDescriptor {
57 const Module *M;
58 const unsigned PassNumber;
59 const std::string IRFileDisplayName;
60 const std::string IRName;
61 const StringRef PassID;
62
63 PassRunDescriptor(const Module *M, unsigned PassNumber,
64 std::string &&IRFileDisplayName, std::string &&IRName,
65 const StringRef PassID)
66 : M{M}, PassNumber{PassNumber}, IRFileDisplayName(IRFileDisplayName),
67 IRName{IRName}, PassID(PassID) {}
68 };
69
70 void printBeforePass(StringRef PassID, IRUnitRef IR);
71 void printAfterPass(StringRef PassID, IRUnitRef IR);
72 void printAfterPassInvalidated(StringRef PassID);
73
74 bool shouldPrintBeforePass(StringRef PassID);
75 bool shouldPrintAfterPass(StringRef PassID);
76 bool shouldPrintBeforeCurrentPassNumber();
77 bool shouldPrintAfterCurrentPassNumber();
78 bool shouldPrintPassNumbers();
79 bool shouldPrintBeforeSomePassNumber();
80 bool shouldPrintAfterSomePassNumber();
81
82 void pushPassRunDescriptor(StringRef PassID, IRUnitRef IR,
83 unsigned PassNumber);
84 PassRunDescriptor popPassRunDescriptor(StringRef PassID);
85
86 enum class IRDumpFileSuffixType {
87 Before,
88 After,
89 Invalidated,
90 };
91
92 static StringRef
93 getFileSuffix(PrintIRInstrumentation::IRDumpFileSuffixType Type);
94 std::string fetchDumpFilename(StringRef PassId, StringRef IRFileDisplayName,
95 unsigned PassNumber,
96 IRDumpFileSuffixType SuffixType);
97
99 /// Stack of Pass Run descriptions, enough to print the IR unit after a given
100 /// pass.
101 SmallVector<PassRunDescriptor, 2> PassRunDescriptorStack;
102
103 /// Used for print-at-pass-number
104 unsigned CurrentPassNumber = 0;
105};
106
108public:
109 OptNoneInstrumentation(bool DebugLogging) : DebugLogging(DebugLogging) {}
111
112private:
113 bool DebugLogging;
114 bool shouldRun(StringRef PassID, IRUnitRef IR);
115};
116
118 LLVMContext &Context;
119 bool HasWrittenIR = false;
120public:
121 OptPassGateInstrumentation(LLVMContext &Context) : Context(Context) {}
124};
125
127 /// Print adaptors and pass managers.
128 bool Verbose = false;
129 /// Don't print information for analyses.
130 bool SkipAnalyses = false;
131 /// Indent based on hierarchy.
132 bool Indent = false;
133};
134
135// Debug logging for transformation and analysis passes.
137 raw_ostream &print();
138
139public:
141 : Enabled(Enabled), Opts(Opts) {}
143
144private:
145 bool Enabled;
146 PrintPassOptions Opts;
147 int Indent = 0;
148};
149
151public:
152 // Keeps sticky poisoned flag for the given basic block once it has been
153 // deleted or RAUWed.
154 struct BBGuard final : public CallbackVH {
155 BBGuard(const BasicBlock *BB) : CallbackVH(BB) {}
156 void deleted() override { CallbackVH::deleted(); }
158 bool isPoisoned() const { return !getValPtr(); }
159 };
160
161 // CFG is a map BB -> {(Succ, Multiplicity)}, where BB is a non-leaf basic
162 // block, {(Succ, Multiplicity)} set of all pairs of the block's successors
163 // and the multiplicity of the edge (BB->Succ). As the mapped sets are
164 // unordered the order of successors is not tracked by the CFG. In other words
165 // this allows basic block successors to be swapped by a pass without
166 // reporting a CFG change. CFG can be guarded by basic block tracking pointers
167 // in the Graph (BBGuard). That is if any of the block is deleted or RAUWed
168 // then the CFG is treated poisoned and no block pointer of the Graph is used.
169 struct CFG {
170 std::optional<DenseMap<intptr_t, BBGuard>> BBGuards;
172
173 LLVM_ABI CFG(const Function *F, bool TrackBBLifetime);
174
175 bool operator==(const CFG &G) const {
176 return !isPoisoned() && !G.isPoisoned() && Graph == G.Graph;
177 }
178
179 bool isPoisoned() const {
180 return BBGuards && llvm::any_of(*BBGuards, [](const auto &BB) {
181 return BB.second.isPoisoned();
182 });
183 }
184
185 LLVM_ABI static void printDiff(raw_ostream &out, const CFG &Before,
186 const CFG &After);
188 FunctionAnalysisManager::Invalidator &);
189 };
190
191#if LLVM_ENABLE_ABI_BREAKING_CHECKS
193#endif
194
197};
198
199// Base class for classes that report changes to the IR.
200// It presents an interface for such classes and provides calls
201// on various events as the new pass manager transforms the IR.
202// It also provides filtering of information based on hidden options
203// specifying which functions are interesting.
204// Calls are made for the following events/queries:
205// 1. The initial IR processed.
206// 2. To get the representation of the IR (of type \p T).
207// 3. When a pass does not change the IR.
208// 4. When a pass changes the IR (given both before and after representations
209// of type \p T).
210// 5. When an IR is invalidated.
211// 6. When a pass is run on an IR that is not interesting (based on options).
212// 7. When a pass is ignored (pass manager or adapter pass).
213// 8. To compare two IR representations (of type \p T).
214template <typename IRUnitT> class LLVM_ABI ChangeReporter {
215protected:
216 ChangeReporter(bool RunInVerboseMode) : VerboseMode(RunInVerboseMode) {}
217
218public:
219 virtual ~ChangeReporter();
220
221 // Determine if this pass/IR is interesting and if so, save the IR
222 // otherwise it is left on the stack without data.
223 void saveIRBeforePass(IRUnitRef IR, StringRef PassID, StringRef PassName);
224 // Compare the IR from before the pass after the pass.
225 void handleIRAfterPass(IRUnitRef IR, StringRef PassID, StringRef PassName);
226 // Handle the situation where a pass is invalidated.
227 void handleInvalidatedPass(StringRef PassID);
228
229protected:
230 // Register required callbacks.
231 void registerRequiredCallbacks(PassInstrumentationCallbacks &PIC);
232
233 // Called on the first IR processed.
234 virtual void handleInitialIR(IRUnitRef IR) = 0;
235 // Called before and after a pass to get the representation of the IR.
237 IRUnitT &Output) = 0;
238 // Called when the pass is not iteresting.
239 virtual void omitAfter(StringRef PassID, std::string &Name) = 0;
240 // Called when an interesting IR has changed.
241 virtual void handleAfter(StringRef PassID, std::string &Name,
242 const IRUnitT &Before, const IRUnitT &After,
243 IRUnitRef) = 0;
244 // Called when an interesting pass is invalidated.
245 virtual void handleInvalidated(StringRef PassID) = 0;
246 // Called when the IR or pass is not interesting.
247 virtual void handleFiltered(StringRef PassID, std::string &Name) = 0;
248 // Called when an ignored pass is encountered.
249 virtual void handleIgnored(StringRef PassID, std::string &Name) = 0;
250
251 struct BeforeIR {
252 IRUnitT Data;
253 bool IsInteresting = false;
254 };
255
256 // Stack of IRs before passes and whether they matched the filters.
257 std::vector<BeforeIR> BeforeStack;
258 // Is this the first IR seen?
259 bool InitialIR = true;
260
261 // Run in verbose mode, printing everything?
262 const bool VerboseMode;
263};
264
265// An abstract template base class that handles printing banners and
266// reporting when things have not changed or are filtered out.
267template <typename IRUnitT>
269protected:
271
272 // Print a module dump of the first IR that is changed.
273 void handleInitialIR(IRUnitRef IR) override;
274 // Report that the IR was omitted because it did not change.
275 void omitAfter(StringRef PassID, std::string &Name) override;
276 // Report that the pass was invalidated.
277 void handleInvalidated(StringRef PassID) override;
278 // Report that the IR was filtered out.
279 void handleFiltered(StringRef PassID, std::string &Name) override;
280 // Report that the pass was ignored.
281 void handleIgnored(StringRef PassID, std::string &Name) override;
282 // Make substitutions in \p S suitable for reporting changes
283 // after the pass and then print it.
284
286};
287
288// A change printer based on the string representation of the IR as created
289// by unwrapAndPrint. The string representation is stored in a std::string
290// to preserve it as the IR changes in each pass. Note that the banner is
291// included in this representation but it is massaged before reporting.
292class LLVM_ABI IRChangedPrinter : public TextChangeReporter<std::string> {
293public:
298
299protected:
300 // Called before and after a pass to get the representation of the IR.
302 std::string &Output) override;
303 // Called when an interesting IR has changed.
304 void handleAfter(StringRef PassID, std::string &Name,
305 const std::string &Before, const std::string &After,
306 IRUnitRef) override;
307};
308
310public:
314
315protected:
316 void handleIR(const std::string &IR, StringRef PassID);
317
318 // Check initial IR
319 void handleInitialIR(IRUnitRef IR) override;
320 // Do nothing.
321 void omitAfter(StringRef PassID, std::string &Name) override;
322 // Do nothing.
323 void handleInvalidated(StringRef PassID) override;
324 // Do nothing.
325 void handleFiltered(StringRef PassID, std::string &Name) override;
326 // Do nothing.
327 void handleIgnored(StringRef PassID, std::string &Name) override;
328
329 // Call test as interesting IR has changed.
330 void handleAfter(StringRef PassID, std::string &Name,
331 const std::string &Before, const std::string &After,
332 IRUnitRef) override;
333};
334
335// Information that needs to be saved for a basic block in order to compare
336// before and after the pass to determine if it was changed by a pass.
337template <typename T> class BlockDataT {
338public:
339 BlockDataT(const BasicBlock &B) : Label(B.getName().str()), Data(B) {
341 B.print(SS, nullptr, true, true);
342 }
343
346 B.print(SS);
347 }
348
349 bool operator==(const BlockDataT &That) const { return Body == That.Body; }
350 bool operator!=(const BlockDataT &That) const { return Body != That.Body; }
351
352 // Return the label of the represented basic block.
353 StringRef getLabel() const { return Label; }
354 // Return the string representation of the basic block.
355 StringRef getBody() const { return Body; }
356
357 // Return the associated data
358 const T &getData() const { return Data; }
359
360protected:
361 std::string Label;
362 std::string Body;
363
364 // Extra data associated with a basic block
366};
367
368template <typename T> class OrderedChangedData {
369public:
370 // Return the names in the order they were saved
371 std::vector<std::string> &getOrder() { return Order; }
372 const std::vector<std::string> &getOrder() const { return Order; }
373
374 // Return a map of names to saved representations
375 StringMap<T> &getData() { return Data; }
376 const StringMap<T> &getData() const { return Data; }
377
378 bool operator==(const OrderedChangedData<T> &That) const {
379 return Data == That.getData();
380 }
381
382 // Call the lambda \p HandlePair on each corresponding pair of data from
383 // \p Before and \p After. The order is based on the order in \p After
384 // with ones that are only in \p Before interspersed based on where they
385 // occur in \p Before. This is used to present the output in an order
386 // based on how the data is ordered in LLVM.
387 static void report(const OrderedChangedData &Before,
388 const OrderedChangedData &After,
389 function_ref<void(const T *, const T *)> HandlePair);
390
391protected:
392 std::vector<std::string> Order;
394};
395
396// Do not need extra information for patch-style change reporter.
398public:
401};
402
403// The data saved for comparing functions.
404template <typename T>
405class FuncDataT : public OrderedChangedData<BlockDataT<T>> {
406public:
407 FuncDataT(std::string S) : EntryBlockName(S) {}
408
409 // Return the name of the entry block
410 std::string getEntryBlockName() const { return EntryBlockName; }
411
412protected:
413 std::string EntryBlockName;
414};
415
416// The data saved for comparing IRs.
417template <typename T>
418class IRDataT : public OrderedChangedData<FuncDataT<T>> {};
419
420// Abstract template base class for a class that compares two IRs. The
421// class is created with the 2 IRs to compare and then compare is called.
422// The static function analyzeIR is used to build up the IR representation.
423template <typename T> class IRComparer {
424public:
427
428 // Compare the 2 IRs. \p handleFunctionCompare is called to handle the
429 // compare of a function. When \p InModule is set,
430 // this function is being handled as part of comparing a module.
431 void compare(
432 bool CompareModule,
433 std::function<void(bool InModule, unsigned Minor,
434 const FuncDataT<T> &Before, const FuncDataT<T> &After)>
435 CompareFunc);
436
437 // Analyze \p IR and build the IR representation in \p Data.
438 static void analyzeIR(IRUnitRef IR, IRDataT<T> &Data);
439
440protected:
441 // Generate the data for \p F into \p Data.
442 template <typename FunctionT>
443 static bool generateFunctionData(IRDataT<T> &Data, const FunctionT &F);
444
447};
448
449// A change printer that prints out in-line differences in the basic
450// blocks. It uses an InlineComparer to do the comparison so it shows
451// the differences prefixed with '-' and '+' for code that is removed
452// and added, respectively. Changes to the IR that do not affect basic
453// blocks are not reported as having changed the IR. The option
454// -print-module-scope does not affect this change reporter.
456 : public TextChangeReporter<IRDataT<EmptyData>> {
457public:
458 InLineChangePrinter(bool VerboseMode, bool ColourMode)
460 UseColour(ColourMode) {}
463
464protected:
465 // Create a representation of the IR.
467 IRDataT<EmptyData> &Output) override;
468
469 // Called when an interesting IR has changed.
470 void handleAfter(StringRef PassID, std::string &Name,
471 const IRDataT<EmptyData> &Before,
472 const IRDataT<EmptyData> &After, IRUnitRef) override;
473
474 void handleFunctionCompare(StringRef Name, StringRef Prefix, StringRef PassID,
475 StringRef Divider, bool InModule, unsigned Minor,
476 const FuncDataT<EmptyData> &Before,
477 const FuncDataT<EmptyData> &After);
478
480};
481
483 bool DebugLogging;
484
485public:
486 VerifyInstrumentation(bool DebugLogging) : DebugLogging(DebugLogging) {}
489};
490
491/// This class implements --time-trace functionality for new pass manager.
492/// It provides the pass-instrumentation callbacks that measure the pass
493/// execution time. They collect time tracing info by TimeProfiler.
495public:
497 // We intend this to be unique per-compilation, thus no copies.
499 void operator=(const TimeProfilingPassesHandler &) = delete;
500
502
503private:
504 // Implementation of pass instrumentation callbacks.
505 void runBeforePass(StringRef PassID, IRUnitRef IR);
506 void runAfterPass();
507};
508
509// Class that holds transitions between basic blocks. The transitions
510// are contained in a map of values to names of basic blocks.
511class DCData {
512public:
513 // Fill the map with the transitions from basic block \p B.
514 LLVM_ABI DCData(const BasicBlock &B);
516
517 // Return an iterator to the names of the successor blocks.
519 return Successors.begin();
520 }
522 return Successors.end();
523 }
524
525 // Return the label of the basic block reached on a transition on \p S.
527 assert(Successors.count(S) == 1 && "Expected to find successor.");
528 return Successors.find(S)->getValue();
529 }
530
531protected:
532 // Add a transition to \p Succ on \p Label
534 std::pair<std::string, std::string> SS{Succ.str(), Label.str()};
535 Successors.insert(SS);
536 }
537
539};
540
541// A change reporter that builds a website with links to pdf files showing
542// dot control flow graphs with changed instructions shown in colour.
543class LLVM_ABI DotCfgChangeReporter : public ChangeReporter<IRDataT<DCData>> {
544public:
546 ~DotCfgChangeReporter() override;
548
549protected:
550 // Initialize the HTML file and output the header.
551 bool initializeHTML();
552
553 // Called on the first IR processed.
554 void handleInitialIR(IRUnitRef IR) override;
555 // Called before and after a pass to get the representation of the IR.
557 IRDataT<DCData> &Output) override;
558 // Called when the pass is not iteresting.
559 void omitAfter(StringRef PassID, std::string &Name) override;
560 // Called when an interesting IR has changed.
561 void handleAfter(StringRef PassID, std::string &Name,
562 const IRDataT<DCData> &Before, const IRDataT<DCData> &After,
563 IRUnitRef) override;
564 // Called when an interesting pass is invalidated.
565 void handleInvalidated(StringRef PassID) override;
566 // Called when the IR or pass is not interesting.
567 void handleFiltered(StringRef PassID, std::string &Name) override;
568 // Called when an ignored pass is encountered.
569 void handleIgnored(StringRef PassID, std::string &Name) override;
570
571 // Generate the pdf file into \p Dir / \p PDFFileName using \p DotFile as
572 // input and return the html <a> tag with \Text as the content.
573 static std::string genHTML(StringRef Text, StringRef DotFile,
574 StringRef PDFFileName);
575
576 void handleFunctionCompare(StringRef Name, StringRef Prefix, StringRef PassID,
577 StringRef Divider, bool InModule, unsigned Minor,
578 const FuncDataT<DCData> &Before,
579 const FuncDataT<DCData> &After);
580
581 unsigned N = 0;
582 std::unique_ptr<raw_fd_ostream> HTML;
583};
584
585// Print IR on crash.
587public:
589 : SavedIR("*** Dump of IR Before Last Pass Unknown ***") {}
592 LLVM_ABI void reportCrashIR();
593
594protected:
595 std::string SavedIR;
596
597private:
598 // The crash reporter that will report on a crash.
599 static PrintCrashIRInstrumentation *CrashReporter;
600 // Crash handler registered when print-on-crash is specified.
601 static void SignalHandler(void *);
602};
603
604/// This class provides an interface to register all the standard pass
605/// instrumentations and manages their state (if any).
608 PrintPassInstrumentation PrintPass;
609 TimePassesHandler TimePasses;
610 TimeProfilingPassesHandler TimeProfilingPasses;
612 OptPassGateInstrumentation OptPassGate;
613 PreservedCFGCheckerInstrumentation PreservedCFGChecker;
614 IRChangedPrinter PrintChangedIR;
615 PseudoProbeVerifier PseudoProbeVerification;
616 InLineChangePrinter PrintChangedDiff;
617 DotCfgChangeReporter WebsiteChangeReporter;
618 PrintCrashIRInstrumentation PrintCrashIR;
619 IRChangedTester ChangeTester;
621 DroppedVariableStatsIR DroppedStatsIR;
622
623 bool VerifyEach;
624
625public:
627 StandardInstrumentations(LLVMContext &Context, bool DebugLogging,
628 bool VerifyEach = false,
629 PrintPassOptions PrintPassOpts = PrintPassOptions());
630
631 // Register all the standard instrumentation callbacks. If \p FAM is nullptr
632 // then PreservedCFGChecker is not enabled.
634 ModuleAnalysisManager *MAM = nullptr);
635
636 TimePassesHandler &getTimePasses() { return TimePasses; }
637};
638
639extern template class BlockDataT<EmptyData>;
640extern template class FuncDataT<EmptyData>;
641extern template class IRDataT<EmptyData>;
642extern template class IRComparer<EmptyData>;
643
644} // namespace llvm
645
646#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:215
===- DroppedVariableStatsIR.h - Opt Diagnostics -*- C++ -*-----------—===//
Flatten the CFG
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 F(x, y, z)
Definition MD5.cpp:54
#define G(x, y, z)
Definition MD5.cpp:55
#define T
This file declares the interface for bisecting optimizations.
ModuleAnalysisManager MAM
SI registerCallbacks(PIC, &MAM)
PassInstrumentationCallbacks PIC
This header defines classes/functions to handle pass execution timing information with interfaces for...
static StringRef getName(Value *V)
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[]
LLVM Basic Block Representation.
Definition BasicBlock.h:62
bool operator!=(const BlockDataT &That) const
bool operator==(const BlockDataT &That) const
BlockDataT(const MachineBasicBlock &B)
BlockDataT(const BasicBlock &B)
CallbackVH(const CallbackVH &)=default
virtual void deleted()
Callback for Value destruction.
virtual void handleFiltered(StringRef PassID, std::string &Name)=0
virtual void handleInitialIR(IRUnitRef IR)=0
virtual void generateIRRepresentation(IRUnitRef IR, StringRef PassID, IRUnitT &Output)=0
virtual void handleIgnored(StringRef PassID, std::string &Name)=0
virtual void handleAfter(StringRef PassID, std::string &Name, const IRUnitT &Before, const IRUnitT &After, IRUnitRef)=0
virtual void handleInvalidated(StringRef PassID)=0
virtual void omitAfter(StringRef PassID, std::string &Name)=0
std::vector< BeforeIR > BeforeStack
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
LLVM_ABI DCData(const BasicBlock &B)
StringMap< std::string >::const_iterator begin() const
void generateIRRepresentation(IRUnitRef IR, StringRef PassID, IRDataT< DCData > &Output) override
std::unique_ptr< raw_fd_ostream > HTML
void handleInvalidated(StringRef PassID) override
static std::string genHTML(StringRef Text, StringRef DotFile, StringRef PDFFileName)
void handleAfter(StringRef PassID, std::string &Name, const IRDataT< DCData > &Before, const IRDataT< DCData > &After, IRUnitRef) override
void handleFunctionCompare(StringRef Name, StringRef Prefix, StringRef PassID, StringRef Divider, bool InModule, unsigned Minor, const FuncDataT< DCData > &Before, const FuncDataT< DCData > &After)
void handleIgnored(StringRef PassID, std::string &Name) override
void handleInitialIR(IRUnitRef IR) 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, IRUnitRef) override
void generateIRRepresentation(IRUnitRef 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, IRUnitRef) override
void omitAfter(StringRef PassID, std::string &Name) override
void handleInvalidated(StringRef PassID) override
void handleIR(const std::string &IR, StringRef PassID)
void handleFiltered(StringRef PassID, std::string &Name) override
~IRChangedTester() override
void handleInitialIR(IRUnitRef IR) override
const IRDataT< T > & Before
static bool generateFunctionData(IRDataT< T > &Data, const FunctionT &F)
static void analyzeIR(IRUnitRef IR, IRDataT< T > &Data)
const IRDataT< T > & After
IRComparer(const IRDataT< T > &Before, const IRDataT< T > &After)
void compare(bool CompareModule, std::function< void(bool InModule, unsigned Minor, const FuncDataT< T > &Before, const FuncDataT< T > &After)> CompareFunc)
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
void generateIRRepresentation(IRUnitRef IR, StringRef PassID, IRDataT< EmptyData > &Output) override
InLineChangePrinter(bool VerboseMode, bool ColourMode)
void handleAfter(StringRef PassID, std::string &Name, const IRDataT< EmptyData > &Before, const IRDataT< EmptyData > &After, IRUnitRef) 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:68
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
LLVM_ABI bool shouldRun(StringRef PassName, IRUnitRef IR)
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()
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC, ModuleAnalysisManager &MAM)
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
Instrumentation to print IR before/after passes.
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
LLVM_ABI 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.
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC, ModuleAnalysisManager *MAM=nullptr)
LLVM_ABI StandardInstrumentations(LLVMContext &Context, bool DebugLogging, bool VerifyEach=false, PrintPassOptions PrintPassOpts=PrintPassOptions())
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:129
StringMapIterBase< ValueTy, true > const_iterator
Definition StringMap.h:208
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
std::string str() const
Get the contents as an std::string.
Definition StringRef.h:222
void handleInvalidated(StringRef PassID) override
void handleInitialIR(IRUnitRef IR) 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.
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
void operator=(const TimeProfilingPassesHandler &)=delete
TimeProfilingPassesHandler(const TimeProfilingPassesHandler &)=delete
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
Value * getValPtr() const
LLVM_ABI 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:53
A raw_ostream that writes to an std::string.
This is an optimization pass for GlobalISel generic memory operations.
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
@ Enabled
Convert any .debug_str_offsets tables to DWARF64 if needed.
Definition DWP.h:31
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:878
void deleted() override
Callback for Value destruction.
void allUsesReplacedWith(Value *) override
Callback for Value RAUW.
std::optional< DenseMap< intptr_t, BBGuard > > BBGuards
static LLVM_ABI void printDiff(raw_ostream &out, const CFG &Before, const CFG &After)
LLVM_ABI CFG(const Function *F, bool TrackBBLifetime)
LLVM_ABI 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.