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