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 <cstdint>
36#include <string>
37#include <utility>
38
39namespace llvm {
40
41class Module;
42class Function;
43class MachineFunction;
46struct PassesOptions;
47
48/// Instrumentation to print IR before/after passes.
49///
50/// Needs state to be able to print module after pass that invalidates IR unit
51/// (typically Loop or SCC).
53public:
54 explicit PrintIRInstrumentation(const PassesOptions &Opts) : Opts(Opts) {}
56
58 ExtendedIRContext *IRContext = nullptr);
59
60private:
61 struct PassRunDescriptor {
62 const Module *M;
63 const unsigned PassNumber;
64 const std::string IRFileDisplayName;
65 const std::string IRName;
66 const StringRef PassID;
67
68 PassRunDescriptor(const Module *M, unsigned PassNumber,
69 std::string &&IRFileDisplayName, std::string &&IRName,
70 const StringRef PassID)
71 : M{M}, PassNumber{PassNumber}, IRFileDisplayName(IRFileDisplayName),
72 IRName{IRName}, PassID(PassID) {}
73 };
74
75 void printBeforePass(StringRef PassID, IRUnitRef IR);
76 void printAfterPass(StringRef PassID, IRUnitRef IR);
77 void printAfterPassInvalidated(StringRef PassID);
78
79 bool shouldPrintBeforePass(StringRef PassID);
80 bool shouldPrintAfterPass(StringRef PassID);
81 bool shouldPrintBeforeCurrentPassNumber();
82 bool shouldPrintAfterCurrentPassNumber();
83 bool shouldPrintPassNumbers();
84 bool shouldPrintBeforeSomePassNumber();
85 bool shouldPrintAfterSomePassNumber();
86
87 void pushPassRunDescriptor(StringRef PassID, IRUnitRef IR,
88 unsigned PassNumber);
89 PassRunDescriptor popPassRunDescriptor(StringRef PassID);
90
91 enum class IRDumpFileSuffixType {
92 Before,
93 After,
94 Invalidated,
95 };
96
97 static StringRef
98 getFileSuffix(PrintIRInstrumentation::IRDumpFileSuffixType Type);
99 std::string fetchDumpFilename(StringRef PassId, StringRef IRFileDisplayName,
100 unsigned PassNumber,
101 IRDumpFileSuffixType SuffixType);
102
103 const PassesOptions &Opts;
104 PassInstrumentationCallbacks *PIC;
105 /// Stack of Pass Run descriptions, enough to print the IR unit after a given
106 /// pass.
107 SmallVector<PassRunDescriptor, 2> PassRunDescriptorStack;
108
109 /// Used for print-at-pass-number
110 unsigned CurrentPassNumber = 0;
111 ExtendedIRContext *IRContext = nullptr;
112};
113
115public:
116 OptNoneInstrumentation(bool DebugLogging) : DebugLogging(DebugLogging) {}
118 ExtendedIRContext *IRContext = nullptr);
119
120private:
121 bool DebugLogging;
122 ExtendedIRContext *IRContext = nullptr;
123 bool shouldRun(StringRef PassID, IRUnitRef IR);
124};
125
127 const PassesOptions &Opts;
128 LLVMContext &Context;
129 bool HasWrittenIR = false;
130public:
131 OptPassGateInstrumentation(const PassesOptions &Opts, LLVMContext &Context)
132 : Opts(Opts), Context(Context) {}
135 ExtendedIRContext *IRContext = nullptr);
136
137private:
138 ExtendedIRContext *IRContext = nullptr;
139};
140
142 /// Print adaptors and pass managers.
143 bool Verbose = false;
144 /// Don't print information for analyses.
145 bool SkipAnalyses = false;
146 /// Indent based on hierarchy.
147 bool Indent = false;
148};
149
150// Debug logging for transformation and analysis passes.
152 raw_ostream &print();
153
154public:
156 : Enabled(Enabled), Opts(Opts) {}
158 ExtendedIRContext *IRContext = nullptr);
159
160private:
161 bool Enabled;
162 ExtendedIRContext *IRContext = nullptr;
163 PrintPassOptions Opts;
164 int Indent = 0;
165};
166
168public:
169 explicit PreservedCFGCheckerInstrumentation(const PassesOptions &Opts)
170 : Opts(Opts) {}
171
172 // Keeps sticky poisoned flag for the given basic block once it has been
173 // deleted or RAUWed.
174 struct BBGuard final : public CallbackVH {
175 BBGuard(const BasicBlock *BB) : CallbackVH(BB) {}
176 void deleted() override { CallbackVH::deleted(); }
178 bool isPoisoned() const { return !getValPtr(); }
179 };
180
181 // CFG is a map BB -> {(Succ, Multiplicity)}, where BB is a non-leaf basic
182 // block, {(Succ, Multiplicity)} set of all pairs of the block's successors
183 // and the multiplicity of the edge (BB->Succ). As the mapped sets are
184 // unordered the order of successors is not tracked by the CFG. In other words
185 // this allows basic block successors to be swapped by a pass without
186 // reporting a CFG change. CFG can be guarded by basic block tracking pointers
187 // in the Graph (BBGuard). That is if any of the block is deleted or RAUWed
188 // then the CFG is treated poisoned and no block pointer of the Graph is used.
189 struct CFG {
190 std::optional<DenseMap<intptr_t, BBGuard>> BBGuards;
192
193 LLVM_ABI CFG(const Function *F, bool TrackBBLifetime);
194
195 bool operator==(const CFG &G) const {
196 return !isPoisoned() && !G.isPoisoned() && Graph == G.Graph;
197 }
198
199 bool isPoisoned() const {
200 return BBGuards && llvm::any_of(*BBGuards, [](const auto &BB) {
201 return BB.second.isPoisoned();
202 });
203 }
204
205 LLVM_ABI static void printDiff(raw_ostream &out, const CFG &Before,
206 const CFG &After);
208 FunctionAnalysisManager::Invalidator &);
209 };
210
211#if LLVM_ENABLE_ABI_BREAKING_CHECKS
213#endif
214
217
218private:
219 const PassesOptions &Opts;
220};
221
223public:
224 ExtendedIRTraits() = default;
227
230
231 virtual ~ExtendedIRTraits() = default;
232 virtual std::optional<std::string> getIRName(IRUnitRef IR) const = 0;
233};
234
235// Stores custom IR-name traits used to specialize instrumentation output for
236// non-standard IR representations.
238 ExtendedIRContext() = default;
241
244
246 // Register an ExtendedIRTraits implementation for this IR context.
247 void addTrait(std::unique_ptr<ExtendedIRTraits> trait) {
248 traits.push_back(std::move(trait));
249 }
250};
251
252// Base class for classes that report changes to the IR.
253// It presents an interface for such classes and provides calls
254// on various events as the new pass manager transforms the IR.
255// It also provides filtering of information based on hidden options
256// specifying which functions are interesting.
257// Calls are made for the following events/queries:
258// 1. The initial IR processed.
259// 2. To get the representation of the IR (of type \p T).
260// 3. When a pass does not change the IR.
261// 4. When a pass changes the IR (given both before and after representations
262// of type \p T).
263// 5. When an IR is invalidated.
264// 6. When a pass is run on an IR that is not interesting (based on options).
265// 7. When a pass is ignored (pass manager or adapter pass).
266// 8. To compare two IR representations (of type \p T).
267template <typename IRUnitT> class LLVM_ABI ChangeReporter {
268protected:
269 ChangeReporter(bool RunInVerboseMode) : VerboseMode(RunInVerboseMode) {}
270 void setContext(ExtendedIRContext *Context) { context = Context; }
271
272public:
273 virtual ~ChangeReporter();
274
275 // Determine if this pass/IR is interesting and if so, save the IR
276 // otherwise it is left on the stack without data.
277 void saveIRBeforePass(IRUnitRef IR, StringRef PassID, StringRef PassName);
278 // Compare the IR from before the pass after the pass.
279 void handleIRAfterPass(IRUnitRef IR, StringRef PassID, StringRef PassName);
280 // Handle the situation where a pass is invalidated.
281 void handleInvalidatedPass(StringRef PassID);
282
283protected:
284 // Register required callbacks.
285 void registerRequiredCallbacks(PassInstrumentationCallbacks &PIC);
286
287 // Called on the first IR processed.
288 virtual void handleInitialIR(IRUnitRef IR) = 0;
289 // Called before and after a pass to get the representation of the IR.
291 IRUnitT &Output) = 0;
292 // Called when the pass is not iteresting.
293 virtual void omitAfter(StringRef PassID, std::string &Name) = 0;
294 // Called when an interesting IR has changed.
295 virtual void handleAfter(StringRef PassID, std::string &Name,
296 const IRUnitT &Before, const IRUnitT &After,
297 IRUnitRef) = 0;
298 // Called when an interesting pass is invalidated.
300 // Called when the IR or pass is not interesting.
301 virtual void handleFiltered(StringRef PassID, std::string &Name) = 0;
302 // Called when an ignored pass is encountered.
303 virtual void handleIgnored(StringRef PassID, std::string &Name) = 0;
304
305 struct BeforeIR {
306 IRUnitT Data;
307 bool IsInteresting = false;
308 };
309
310 // Stack of IRs before passes and whether they matched the filters.
311 std::vector<BeforeIR> BeforeStack;
312 // Is this the first IR seen?
313 bool InitialIR = true;
314
315 // Run in verbose mode, printing everything?
316 const bool VerboseMode;
317
319};
320
321// An abstract template base class that handles printing banners and
322// reporting when things have not changed or are filtered out.
323template <typename IRUnitT>
325protected:
327
328 // Print a module dump of the first IR that is changed.
329 void handleInitialIR(IRUnitRef IR) override;
330 // Report that the IR was omitted because it did not change.
331 void omitAfter(StringRef PassID, std::string &Name) override;
332 // Report that the pass was invalidated.
333 void handleInvalidated(StringRef PassID) override;
334 // Report that the IR was filtered out.
335 void handleFiltered(StringRef PassID, std::string &Name) override;
336 // Report that the pass was ignored.
337 void handleIgnored(StringRef PassID, std::string &Name) override;
338 // Make substitutions in \p S suitable for reporting changes
339 // after the pass and then print it.
340
342};
343
344// A change printer based on the string representation of the IR as created
345// by unwrapAndPrint. The string representation is stored in a std::string
346// to preserve it as the IR changes in each pass. Note that the banner is
347// included in this representation but it is massaged before reporting.
348class LLVM_ABI IRChangedPrinter : public TextChangeReporter<std::string> {
349public:
350 IRChangedPrinter(const PassesOptions &Opts, bool VerboseMode)
354
355protected:
356 const PassesOptions &Opts;
357
358 // Called before and after a pass to get the representation of the IR.
360 std::string &Output) override;
361 // Called when an interesting IR has changed.
362 void handleAfter(StringRef PassID, std::string &Name,
363 const std::string &Before, const std::string &After,
364 IRUnitRef) override;
365};
366
368public:
369 explicit IRChangedTester(const PassesOptions &Opts)
373
374protected:
375 void handleIR(const std::string &IR, StringRef PassID);
376
377 // Check initial IR
378 void handleInitialIR(IRUnitRef IR) override;
379 // Do nothing.
380 void omitAfter(StringRef PassID, std::string &Name) override;
381 // Do nothing.
382 void handleInvalidated(StringRef PassID) override;
383 // Do nothing.
384 void handleFiltered(StringRef PassID, std::string &Name) override;
385 // Do nothing.
386 void handleIgnored(StringRef PassID, std::string &Name) override;
387
388 // Call test as interesting IR has changed.
389 void handleAfter(StringRef PassID, std::string &Name,
390 const std::string &Before, const std::string &After,
391 IRUnitRef) override;
392};
393
394// Information that needs to be saved for a basic block in order to compare
395// before and after the pass to determine if it was changed by a pass.
396template <typename T> class BlockDataT {
397public:
398 BlockDataT(const BasicBlock &B) : Label(B.getName().str()), Data(B) {
400 B.print(SS, nullptr, true, true);
401 }
402
405 B.print(SS);
406 }
407
408 bool operator==(const BlockDataT &That) const { return Body == That.Body; }
409 bool operator!=(const BlockDataT &That) const { return Body != That.Body; }
410
411 // Return the label of the represented basic block.
412 StringRef getLabel() const { return Label; }
413 // Return the string representation of the basic block.
414 StringRef getBody() const { return Body; }
415
416 // Return the associated data
417 const T &getData() const { return Data; }
418
419protected:
420 std::string Label;
421 std::string Body;
422
423 // Extra data associated with a basic block
425};
426
427template <typename T> class OrderedChangedData {
428public:
429 // Return the names in the order they were saved
430 std::vector<std::string> &getOrder() { return Order; }
431 const std::vector<std::string> &getOrder() const { return Order; }
432
433 // Return a map of names to saved representations
434 StringMap<T> &getData() { return Data; }
435 const StringMap<T> &getData() const { return Data; }
436
437 bool operator==(const OrderedChangedData<T> &That) const {
438 return Data == That.getData();
439 }
440
441 // Call the lambda \p HandlePair on each corresponding pair of data from
442 // \p Before and \p After. The order is based on the order in \p After
443 // with ones that are only in \p Before interspersed based on where they
444 // occur in \p Before. This is used to present the output in an order
445 // based on how the data is ordered in LLVM.
446 static void report(const OrderedChangedData &Before,
447 const OrderedChangedData &After,
448 function_ref<void(const T *, const T *)> HandlePair);
449
450protected:
451 std::vector<std::string> Order;
453};
454
455// Do not need extra information for patch-style change reporter.
457public:
460};
461
462// The data saved for comparing functions.
463template <typename T>
464class FuncDataT : public OrderedChangedData<BlockDataT<T>> {
465public:
466 FuncDataT(std::string S) : EntryBlockName(S) {}
467
468 // Return the name of the entry block
469 std::string getEntryBlockName() const { return EntryBlockName; }
470
471protected:
472 std::string EntryBlockName;
473};
474
475// The data saved for comparing IRs.
476template <typename T>
477class IRDataT : public OrderedChangedData<FuncDataT<T>> {};
478
479// Abstract template base class for a class that compares two IRs. The
480// class is created with the 2 IRs to compare and then compare is called.
481// The static function analyzeIR is used to build up the IR representation.
482template <typename T> class IRComparer {
483public:
486
487 // Compare the 2 IRs. \p handleFunctionCompare is called to handle the
488 // compare of a function. When \p InModule is set,
489 // this function is being handled as part of comparing a module.
490 void compare(
491 bool CompareModule,
492 std::function<void(bool InModule, unsigned Minor,
493 const FuncDataT<T> &Before, const FuncDataT<T> &After)>
494 CompareFunc);
495
496 // Analyze \p IR and build the IR representation in \p Data.
497 static void analyzeIR(IRUnitRef IR, IRDataT<T> &Data);
498
499protected:
500 // Generate the data for \p F into \p Data.
501 template <typename FunctionT>
502 static bool generateFunctionData(IRDataT<T> &Data, const FunctionT &F);
503
506};
507
508// A change printer that prints out in-line differences in the basic
509// blocks. It uses an InlineComparer to do the comparison so it shows
510// the differences prefixed with '-' and '+' for code that is removed
511// and added, respectively. Changes to the IR that do not affect basic
512// blocks are not reported as having changed the IR. The option
513// -print-module-scope does not affect this change reporter.
515 : public TextChangeReporter<IRDataT<EmptyData>> {
516public:
517 InLineChangePrinter(bool VerboseMode, bool ColourMode)
519 UseColour(ColourMode) {}
522
523protected:
524 // Create a representation of the IR.
526 IRDataT<EmptyData> &Output) override;
527
528 // Called when an interesting IR has changed.
529 void handleAfter(StringRef PassID, std::string &Name,
530 const IRDataT<EmptyData> &Before,
531 const IRDataT<EmptyData> &After, IRUnitRef) override;
532
534 StringRef Divider, bool InModule, unsigned Minor,
535 const FuncDataT<EmptyData> &Before,
536 const FuncDataT<EmptyData> &After);
537
539};
540
542 bool DebugLogging;
543
544public:
545 VerifyInstrumentation(bool DebugLogging) : DebugLogging(DebugLogging) {}
548};
549
550/// This class implements --time-trace functionality for new pass manager.
551/// It provides the pass-instrumentation callbacks that measure the pass
552/// execution time. They collect time tracing info by TimeProfiler.
554public:
556 // We intend this to be unique per-compilation, thus no copies.
558 void operator=(const TimeProfilingPassesHandler &) = delete;
559
561 ExtendedIRContext *IRContext = nullptr);
562
563private:
564 // Implementation of pass instrumentation callbacks.
565 void runBeforePass(StringRef PassID, IRUnitRef IR);
566 void runAfterPass();
567
568 ExtendedIRContext *IRContext = nullptr;
569};
570
571// Class that holds transitions between basic blocks. The transitions
572// are contained in a map of values to names of basic blocks.
573class DCData {
574public:
575 // Fill the map with the transitions from basic block \p B.
576 LLVM_ABI DCData(const BasicBlock &B);
578
579 // Return an iterator to the names of the successor blocks.
581 return Successors.begin();
582 }
584 return Successors.end();
585 }
586
587 // Return the label of the basic block reached on a transition on \p S.
589 assert(Successors.count(S) == 1 && "Expected to find successor.");
590 return Successors.find(S)->getValue();
591 }
592
593protected:
594 // Add a transition to \p Succ on \p Label
596 std::pair<std::string, std::string> SS{Succ.str(), Label.str()};
597 Successors.insert(SS);
598 }
599
601};
602
603// A change reporter that builds a website with links to pdf files showing
604// dot control flow graphs with changed instructions shown in colour.
605class LLVM_ABI DotCfgChangeReporter : public ChangeReporter<IRDataT<DCData>> {
606public:
607 DotCfgChangeReporter(const PassesOptions &Opts, bool Verbose);
608 ~DotCfgChangeReporter() override;
610
611protected:
612 // Initialize the HTML file and output the header.
613 bool initializeHTML();
614
615 // Called on the first IR processed.
616 void handleInitialIR(IRUnitRef IR) override;
617 // Called before and after a pass to get the representation of the IR.
619 IRDataT<DCData> &Output) override;
620 // Called when the pass is not iteresting.
621 void omitAfter(StringRef PassID, std::string &Name) override;
622 // Called when an interesting IR has changed.
623 void handleAfter(StringRef PassID, std::string &Name,
624 const IRDataT<DCData> &Before, const IRDataT<DCData> &After,
625 IRUnitRef) override;
626 // Called when an interesting pass is invalidated.
627 void handleInvalidated(StringRef PassID) override;
628 // Called when the IR or pass is not interesting.
629 void handleFiltered(StringRef PassID, std::string &Name) override;
630 // Called when an ignored pass is encountered.
631 void handleIgnored(StringRef PassID, std::string &Name) override;
632
633 // Generate the pdf file into \p Dir / \p PDFFileName using \p DotFile as
634 // input and return the html <a> tag with \Text as the content.
635 std::string genHTML(StringRef Text, StringRef DotFile,
636 StringRef PDFFileName) const;
637
639 StringRef Divider, bool InModule, unsigned Minor,
640 const FuncDataT<DCData> &Before,
641 const FuncDataT<DCData> &After);
642
643 const PassesOptions &Opts;
644 unsigned N = 0;
645 // -dot-cfg-dir with ~ expanded, made absolute.
646 std::string OutputDir;
647 std::unique_ptr<raw_fd_ostream> HTML;
648};
649
650// Print IR on crash.
652public:
653 explicit PrintCrashIRInstrumentation(const PassesOptions &Opts)
654 : Opts(Opts), SavedIR("*** Dump of IR Before Last Pass Unknown ***") {}
657 LLVM_ABI void reportCrashIR();
658
659protected:
660 const PassesOptions &Opts;
661 std::string SavedIR;
662
663private:
664 // The crash reporter that will report on a crash.
665 static PrintCrashIRInstrumentation *CrashReporter;
666 // Crash handler registered when print-on-crash is specified.
667 static void SignalHandler(void *);
668};
669
670/// This class provides an interface to register all the standard pass
671/// instrumentations and manages their state (if any).
673 const PassesOptions &Opts;
675 PrintPassInstrumentation PrintPass;
676 TimePassesHandler TimePasses;
677 TimeProfilingPassesHandler TimeProfilingPasses;
679 OptPassGateInstrumentation OptPassGate;
680 PreservedCFGCheckerInstrumentation PreservedCFGChecker;
681 IRChangedPrinter PrintChangedIR;
682 PseudoProbeVerifier PseudoProbeVerification;
683 InLineChangePrinter PrintChangedDiff;
684 DotCfgChangeReporter WebsiteChangeReporter;
685 PrintCrashIRInstrumentation PrintCrashIR;
686 IRChangedTester ChangeTester;
688 DroppedVariableStatsIR DroppedStatsIR;
689
690 uint64_t InstNamerNextID = 0;
691 bool VerifyEach;
692
693public:
695 StandardInstrumentations(LLVMContext &Context, bool DebugLogging,
696 bool VerifyEach = false,
697 PrintPassOptions PrintPassOpts = PrintPassOptions());
698
699 // Register all the standard instrumentation callbacks. If \p FAM is nullptr
700 // then PreservedCFGChecker is not enabled.
702 ModuleAnalysisManager *MAM = nullptr,
703 ExtendedIRContext *IRContext = nullptr);
704
705 TimePassesHandler &getTimePasses() { return TimePasses; }
706};
707
708extern template class BlockDataT<EmptyData>;
709extern template class FuncDataT<EmptyData>;
710extern template class IRDataT<EmptyData>;
711extern template class IRComparer<EmptyData>;
712
713} // namespace llvm
714
715#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:211
===- 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
void setContext(ExtendedIRContext *Context)
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
void handleAfter(StringRef PassID, std::string &Name, const IRDataT< DCData > &Before, const IRDataT< DCData > &After, IRUnitRef) override
DotCfgChangeReporter(const PassesOptions &Opts, bool Verbose)
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
std::string genHTML(StringRef Text, StringRef DotFile, StringRef PDFFileName) const
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 &)
ExtendedIRTraits & operator=(const ExtendedIRTraits &)=delete
ExtendedIRTraits & operator=(ExtendedIRTraits &&)=delete
ExtendedIRTraits(const ExtendedIRTraits &)=delete
virtual std::optional< std::string > getIRName(IRUnitRef IR) const =0
virtual ~ExtendedIRTraits()=default
ExtendedIRTraits(ExtendedIRTraits &&)=delete
std::string getEntryBlockName() const
~IRChangedPrinter() override
IRChangedPrinter(const PassesOptions &Opts, bool VerboseMode)
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
IRChangedTester(const PassesOptions &Opts)
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:76
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, ExtendedIRContext *IRContext=nullptr)
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC, ExtendedIRContext *IRContext=nullptr)
OptPassGateInstrumentation(const PassesOptions &Opts, LLVMContext &Context)
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
PreservedCFGCheckerInstrumentation(const PassesOptions &Opts)
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC, ModuleAnalysisManager &MAM)
PrintCrashIRInstrumentation(const PassesOptions &Opts)
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
Instrumentation to print IR before/after passes.
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC, ExtendedIRContext *IRContext=nullptr)
PrintIRInstrumentation(const PassesOptions &Opts)
PrintPassInstrumentation(bool Enabled, PrintPassOptions Opts)
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC, ExtendedIRContext *IRContext=nullptr)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM_ABI StandardInstrumentations(LLVMContext &Context, bool DebugLogging, bool VerifyEach=false, PrintPassOptions PrintPassOpts=PrintPassOptions())
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC, ModuleAnalysisManager *MAM=nullptr, ExtendedIRContext *IRContext=nullptr)
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.
void operator=(const TimeProfilingPassesHandler &)=delete
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC, ExtendedIRContext *IRContext=nullptr)
TimeProfilingPassesHandler(const TimeProfilingPassesHandler &)=delete
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:1762
@ 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
ExtendedIRContext & operator=(const ExtendedIRContext &)=delete
ExtendedIRContext(const ExtendedIRContext &)=delete
void addTrait(std::unique_ptr< ExtendedIRTraits > trait)
llvm::SmallVector< std::unique_ptr< ExtendedIRTraits > > traits
ExtendedIRContext & operator=(ExtendedIRContext &&)=delete
ExtendedIRContext(ExtendedIRContext &&)=delete
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.