LLVM: include/llvm/Passes/StandardInstrumentations.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef LLVM_PASSES_STANDARDINSTRUMENTATIONS_H
16#define LLVM_PASSES_STANDARDINSTRUMENTATIONS_H
17
33
34#include
35#include
36
37namespace llvm {
38
43
44
45
46
47
49public:
51
53
54private:
55 struct PassRunDescriptor {
57 const unsigned PassNumber;
58 const std::string IRFileDisplayName;
59 const std::string IRName;
61
62 PassRunDescriptor(const Module *M, unsigned PassNumber,
63 std::string &&IRFileDisplayName, std::string &&IRName,
65 : M{M}, PassNumber{PassNumber}, IRFileDisplayName(IRFileDisplayName),
66 IRName{IRName}, PassID(PassID) {}
67 };
68
71 void printAfterPassInvalidated(StringRef PassID);
72
73 bool shouldPrintBeforePass(StringRef PassID);
74 bool shouldPrintAfterPass(StringRef PassID);
75 bool shouldPrintBeforeCurrentPassNumber();
76 bool shouldPrintAfterCurrentPassNumber();
77 bool shouldPrintPassNumbers();
78 bool shouldPrintBeforeSomePassNumber();
79 bool shouldPrintAfterSomePassNumber();
80
81 void pushPassRunDescriptor(StringRef PassID, Any IR, unsigned PassNumber);
82 PassRunDescriptor popPassRunDescriptor(StringRef PassID);
83
84 enum class IRDumpFileSuffixType {
85 Before,
86 After,
87 Invalidated,
88 };
89
91 getFileSuffix(PrintIRInstrumentation::IRDumpFileSuffixType Type);
92 std::string fetchDumpFilename(StringRef PassId, StringRef IRFileDisplayName,
93 unsigned PassNumber,
94 IRDumpFileSuffixType SuffixType);
95
97
98
100
101
102 unsigned CurrentPassNumber = 0;
103};
104
106public:
109
110private:
111 bool DebugLogging;
113};
114
117 bool HasWrittenIR = false;
118public:
122};
123
132
133
136
137public:
139 : Enabled(Enabled), Opts(Opts) {}
141
142private:
145 int Indent = 0;
146};
147
149public:
150
151
158
159
160
161
162
163
164
165
166
168 std::optional<DenseMap<intptr_t, BBGuard>> BBGuards;
170
172
176
179 return BB.second.isPoisoned();
180 });
181 }
182
184 const CFG &After);
186 FunctionAnalysisManager::Invalidator &);
187 };
188
189#if LLVM_ENABLE_ABI_BREAKING_CHECKS
191#endif
192
195};
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
213protected:
215
216public:
218
219
220
222
224
225 void handleInvalidatedPass(StringRef PassID);
226
227protected:
228
230
231
233
235 IRUnitT &Output) = 0;
236
238
240 const IRUnitT &Before, const IRUnitT &After,
241 Any) = 0;
242
244
246
248
249
251
253
254
256};
257
258
259
260template
262protected:
264
265
267
269
271
273
275
276
277
279};
280
281
282
283
284
286public:
291
292protected:
293
295 std::string &Output) override;
296
298 const std::string &Before, const std::string &After,
299 Any) override;
300};
301
303public:
307
308protected:
310
311
313
315
317
319
321
322
324 const std::string &Before, const std::string &After,
325 Any) override;
326};
327
328
329
331public:
334 B.print(SS, nullptr, true, true);
335 }
336
341
344
345
347
349
350
352
353protected:
356
357
359};
360
362public:
363
365 const std::vectorstd::string &getOrder() const { return Order; }
366
367
370
374
375
376
377
378
379
382 function_ref<void(const T *, const T *)> HandlePair);
383
384protected:
385 std::vectorstd::string Order;
387};
388
389
395
396
397template
399public:
401
402
404
405protected:
407};
408
409
410template
412
413
414
415
417public:
420
421
422
423
425 bool CompareModule,
426 std::function<void(bool InModule, unsigned Minor,
428 CompareFunc);
429
430
432
433protected:
434
435 template
437
440};
441
442
443
444
445
446
447
450public:
456
457protected:
458
461
462
466
468 StringRef Divider, bool InModule, unsigned Minor,
471
473};
474
476 bool DebugLogging;
477
478public:
482};
483
484
485
486
488public:
490
493
495
496private:
497
499 void runAfterPass();
500};
501
502
503
505public:
506
509
510
517
518
523
524protected:
525
527 std::pair<std::string, std::string> SS{Succ.str(), Label.str()};
529 }
530
532};
533
534
535
537public:
541
542protected:
543
545
546
548
551
553
556 Any) override;
557
559
561
563
564
565
568
570 StringRef Divider, bool InModule, unsigned Minor,
573
575 std::unique_ptr<raw_fd_ostream> HTML;
576};
577
578
580public:
582 : SavedIR("*** Dump of IR Before Last Pass Unknown ***") {}
586
587protected:
589
590private:
591
593
594 static void SignalHandler(void *);
595};
596
597
598
615
616 bool VerifyEach;
617
618public:
621 bool VerifyEach = false,
623
624
625
628
630};
631
632extern template class BlockDataT;
633extern template class FuncDataT;
634extern template class IRDataT;
635extern template class IRComparer;
636
637}
638
639#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
===- DroppedVariableStatsIR.h - Opt Diagnostics -*- C++ -*-----------—===//
Legalize the Machine IR a function s Machine IR
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 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.
bool operator!=(const BlockDataT &That) const
Definition StandardInstrumentations.h:343
bool operator==(const BlockDataT &That) const
Definition StandardInstrumentations.h:342
StringRef getLabel() const
Definition StandardInstrumentations.h:346
BlockDataT(const MachineBasicBlock &B)
Definition StandardInstrumentations.h:337
std::string Label
Definition StandardInstrumentations.h:354
BlockDataT(const BasicBlock &B)
Definition StandardInstrumentations.h:332
T Data
Definition StandardInstrumentations.h:358
std::string Body
Definition StandardInstrumentations.h:355
const T & getData() const
Definition StandardInstrumentations.h:351
StringRef getBody() const
Definition StandardInstrumentations.h:348
CallbackVH(const CallbackVH &)=default
virtual void deleted()
Callback for Value destruction.
virtual void handleFiltered(StringRef PassID, std::string &Name)=0
virtual void handleAfter(StringRef PassID, std::string &Name, const IRUnitT &Before, const IRUnitT &After, Any)=0
virtual void handleIgnored(StringRef PassID, std::string &Name)=0
bool InitialIR
Definition StandardInstrumentations.h:252
virtual void generateIRRepresentation(Any IR, StringRef PassID, IRUnitT &Output)=0
virtual void handleInitialIR(Any IR)=0
virtual void handleInvalidated(StringRef PassID)=0
std::vector< IRUnitT > BeforeStack
Definition StandardInstrumentations.h:250
const bool VerboseMode
Definition StandardInstrumentations.h:255
virtual void omitAfter(StringRef PassID, std::string &Name)=0
ChangeReporter(bool RunInVerboseMode)
Definition StandardInstrumentations.h:214
void addSuccessorLabel(StringRef Succ, StringRef Label)
Definition StandardInstrumentations.h:526
StringRef getSuccessorLabel(StringRef S) const
Definition StandardInstrumentations.h:519
StringMap< std::string > Successors
Definition StandardInstrumentations.h:531
StringMap< std::string >::const_iterator end() const
Definition StandardInstrumentations.h:514
LLVM_ABI DCData(const BasicBlock &B)
StringMap< std::string >::const_iterator begin() const
Definition StandardInstrumentations.h:511
std::unique_ptr< raw_fd_ostream > HTML
Definition StandardInstrumentations.h:575
void handleInvalidated(StringRef PassID) override
void generateIRRepresentation(Any IR, StringRef PassID, IRDataT< DCData > &Output) override
static std::string genHTML(StringRef Text, StringRef DotFile, StringRef PDFFileName)
void handleInitialIR(Any IR) override
unsigned N
Definition StandardInstrumentations.h:574
void handleFunctionCompare(StringRef Name, StringRef Prefix, StringRef PassID, StringRef Divider, bool InModule, unsigned Minor, const FuncDataT< DCData > &Before, const FuncDataT< DCData > &After)
DotCfgChangeReporter(bool Verbose)
void handleIgnored(StringRef PassID, std::string &Name) override
void handleAfter(StringRef PassID, std::string &Name, const IRDataT< DCData > &Before, const IRDataT< DCData > &After, Any) 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 &)
Definition StandardInstrumentations.h:393
EmptyData(const BasicBlock &)
Definition StandardInstrumentations.h:392
FuncDataT(std::string S)
Definition StandardInstrumentations.h:400
std::string getEntryBlockName() const
Definition StandardInstrumentations.h:403
std::string EntryBlockName
Definition StandardInstrumentations.h:406
IRChangedPrinter(bool VerboseMode)
Definition StandardInstrumentations.h:287
~IRChangedPrinter() override
void handleAfter(StringRef PassID, std::string &Name, const std::string &Before, const std::string &After, Any) override
void generateIRRepresentation(Any 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, Any) override
void omitAfter(StringRef PassID, std::string &Name) override
IRChangedTester()
Definition StandardInstrumentations.h:304
void handleInvalidated(StringRef PassID) override
void handleIR(const std::string &IR, StringRef PassID)
void handleInitialIR(Any IR) override
void handleFiltered(StringRef PassID, std::string &Name) override
~IRChangedTester() override
const IRDataT< T > & Before
Definition StandardInstrumentations.h:438
static bool generateFunctionData(IRDataT< T > &Data, const FunctionT &F)
const IRDataT< T > & After
Definition StandardInstrumentations.h:439
IRComparer(const IRDataT< T > &Before, const IRDataT< T > &After)
Definition StandardInstrumentations.h:418
static void analyzeIR(Any IR, IRDataT< T > &Data)
void compare(bool CompareModule, std::function< void(bool InModule, unsigned Minor, const FuncDataT< T > &Before, const FuncDataT< T > &After)> CompareFunc)
bool UseColour
Definition StandardInstrumentations.h:472
InLineChangePrinter(bool VerboseMode, bool ColourMode)
Definition StandardInstrumentations.h:451
~InLineChangePrinter() override
void handleAfter(StringRef PassID, std::string &Name, const IRDataT< EmptyData > &Before, const IRDataT< EmptyData > &After, Any) override
void generateIRRepresentation(Any IR, StringRef PassID, IRDataT< EmptyData > &Output) 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.
A Module instance is used to store all the information related to an LLVM module.
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
OptNoneInstrumentation(bool DebugLogging)
Definition StandardInstrumentations.h:107
OptPassGateInstrumentation(LLVMContext &Context)
Definition StandardInstrumentations.h:119
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
LLVM_ABI bool shouldRun(StringRef PassName, Any IR)
bool operator==(const OrderedChangedData< T > &That) const
Definition StandardInstrumentations.h:371
static void report(const OrderedChangedData &Before, const OrderedChangedData &After, function_ref< void(const T *, const T *)> HandlePair)
const std::vector< std::string > & getOrder() const
Definition StandardInstrumentations.h:365
StringMap< T > & getData()
Definition StandardInstrumentations.h:368
std::vector< std::string > Order
Definition StandardInstrumentations.h:385
const StringMap< T > & getData() const
Definition StandardInstrumentations.h:369
StringMap< T > Data
Definition StandardInstrumentations.h:386
std::vector< std::string > & getOrder()
Definition StandardInstrumentations.h:364
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.
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC, ModuleAnalysisManager &MAM)
LLVM_ABI void reportCrashIR()
std::string SavedIR
Definition StandardInstrumentations.h:588
LLVM_ABI ~PrintCrashIRInstrumentation()
PrintCrashIRInstrumentation()
Definition StandardInstrumentations.h:581
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
Instrumentation to print IR before/after passes.
Definition StandardInstrumentations.h:48
LLVM_ABI ~PrintIRInstrumentation()
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
PrintPassInstrumentation(bool Enabled, PrintPassOptions Opts)
Definition StandardInstrumentations.h:138
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC, ModuleAnalysisManager *MAM=nullptr)
LLVM_ABI StandardInstrumentations(LLVMContext &Context, bool DebugLogging, bool VerifyEach=false, PrintPassOptions PrintPassOpts=PrintPassOptions())
TimePassesHandler & getTimePasses()
Definition StandardInstrumentations.h:629
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringMapIterBase< ValueTy, true > const_iterator
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
void handleInitialIR(Any IR) override
void handleInvalidated(StringRef PassID) override
TextChangeReporter(bool Verbose)
void omitAfter(StringRef PassID, std::string &Name) override
raw_ostream & Out
Definition StandardInstrumentations.h:278
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.
Definition StandardInstrumentations.h:487
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
void operator=(const TimeProfilingPassesHandler &)=delete
LLVM_ABI TimeProfilingPassesHandler()
TimeProfilingPassesHandler(const TimeProfilingPassesHandler &)=delete
The instances of the Type class are immutable: once they are created, they are never changed.
Value * getValPtr() const
VerifyInstrumentation(bool DebugLogging)
Definition StandardInstrumentations.h:479
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.
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.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
@ Enabled
Convert any .debug_str_offsets tables to DWARF64 if needed.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Implement std::hash so that hash_code can be used in STL containers.
BBGuard(const BasicBlock *BB)
Definition StandardInstrumentations.h:153
bool isPoisoned() const
Definition StandardInstrumentations.h:156
void deleted() override
Callback for Value destruction.
Definition StandardInstrumentations.h:154
void allUsesReplacedWith(Value *) override
Callback for Value RAUW.
Definition StandardInstrumentations.h:155
std::optional< DenseMap< intptr_t, BBGuard > > BBGuards
Definition StandardInstrumentations.h:168
static LLVM_ABI void printDiff(raw_ostream &out, const CFG &Before, const CFG &After)
LLVM_ABI CFG(const Function *F, bool TrackBBLifetime)
bool isPoisoned() const
Definition StandardInstrumentations.h:177
bool operator==(const CFG &G) const
Definition StandardInstrumentations.h:173
LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
DenseMap< const BasicBlock *, DenseMap< const BasicBlock *, unsigned > > Graph
Definition StandardInstrumentations.h:169
bool SkipAnalyses
Don't print information for analyses.
Definition StandardInstrumentations.h:128
bool Verbose
Print adaptors and pass managers.
Definition StandardInstrumentations.h:126
bool Indent
Indent based on hierarchy.
Definition StandardInstrumentations.h:130