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