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