15#ifndef LLVM_PASSES_STANDARDINSTRUMENTATIONS_H
16#define LLVM_PASSES_STANDARDINSTRUMENTATIONS_H
42class PassInstrumentationCallbacks;
55 struct PassRunDescriptor {
57 const unsigned PassNumber;
58 const std::string IRFileDisplayName;
59 const std::string IRName;
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) {}
71 void printAfterPassInvalidated(
StringRef PassID);
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();
81 void pushPassRunDescriptor(
StringRef PassID,
Any IR,
unsigned PassNumber);
82 PassRunDescriptor popPassRunDescriptor(
StringRef PassID);
84 enum class IRDumpFileSuffixType {
91 getFileSuffix(PrintIRInstrumentation::IRDumpFileSuffixType
Type);
94 IRDumpFileSuffixType SuffixType);
102 unsigned CurrentPassNumber = 0;
117 bool HasWrittenIR =
false;
139 : Enabled(Enabled), Opts(Opts) {}
168 std::optional<DenseMap<intptr_t, BBGuard>>
BBGuards;
179 return BB.second.isPoisoned();
189#if LLVM_ENABLE_ABI_BREAKING_CHECKS
225 void handleInvalidatedPass(
StringRef PassID);
235 IRUnitT &Output) = 0;
240 const IRUnitT &Before,
const IRUnitT &After,
252 bool InitialIR =
true;
260template <
typename IRUnitT>
266 void handleInitialIR(
Any IR)
override;
268 void omitAfter(
StringRef PassID, std::string &
Name)
override;
270 void handleInvalidated(
StringRef PassID)
override;
272 void handleFiltered(
StringRef PassID, std::string &
Name)
override;
274 void handleIgnored(
StringRef PassID, std::string &
Name)
override;
295 std::string &Output)
override;
298 const std::string &Before,
const std::string &After,
309 void handleIR(
const std::string &
IR,
StringRef PassID);
312 void handleInitialIR(
Any IR)
override;
314 void omitAfter(
StringRef PassID, std::string &
Name)
override;
316 void handleInvalidated(
StringRef PassID)
override;
318 void handleFiltered(
StringRef PassID, std::string &
Name)
override;
320 void handleIgnored(
StringRef PassID, std::string &
Name)
override;
324 const std::string &Before,
const std::string &After,
334 B.print(SS,
nullptr,
true,
true);
426 std::function<
void(
bool InModule,
unsigned Minor,
435 template <
typename FunctionT>
453 UseColour(ColourMode) {}
468 StringRef Divider,
bool InModule,
unsigned Minor,
527 std::pair<std::string, std::string> SS{Succ.
str(), Label.str()};
544 bool initializeHTML();
547 void handleInitialIR(
Any IR)
override;
552 void omitAfter(
StringRef PassID, std::string &
Name)
override;
558 void handleInvalidated(
StringRef PassID)
override;
560 void handleFiltered(
StringRef PassID, std::string &
Name)
override;
562 void handleIgnored(
StringRef PassID, std::string &
Name)
override;
570 StringRef Divider,
bool InModule,
unsigned Minor,
575 std::unique_ptr<raw_fd_ostream>
HTML;
582 :
SavedIR(
"*** Dump of IR Before Last Pass Unknown ***") {}
594 static void SignalHandler(
void *);
632extern template class BlockDataT<EmptyData>;
633extern template class FuncDataT<EmptyData>;
634extern template class IRDataT<EmptyData>;
635extern template class IRComparer<EmptyData>;
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
Machine Check Debug Module
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[]
API to communicate dependencies between analyses during invalidation.
A container for analyses that lazily runs them and caches their results.
LLVM Basic Block Representation.
bool operator!=(const BlockDataT &That) const
bool operator==(const BlockDataT &That) const
StringRef getLabel() const
BlockDataT(const MachineBasicBlock &B)
BlockDataT(const BasicBlock &B)
const T & getData() const
StringRef getBody() const
Value handle with callbacks on RAUW and destruction.
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
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
virtual void omitAfter(StringRef PassID, std::string &Name)=0
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
StringMap< std::string >::const_iterator begin() const
std::unique_ptr< raw_fd_ostream > HTML
A class to collect and print dropped debug information due to LLVM IR optimization passes.
EmptyData(const MachineBasicBlock &)
EmptyData(const BasicBlock &)
std::string getEntryBlockName() const
std::string EntryBlockName
IRChangedPrinter(bool VerboseMode)
~IRChangedPrinter() override
const IRDataT< T > & Before
static bool generateFunctionData(IRDataT< T > &Data, const FunctionT &F)
const IRDataT< T > & After
IRComparer(const IRDataT< T > &Before, const IRDataT< T > &After)
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)
InLineChangePrinter(bool VerboseMode, bool ColourMode)
~InLineChangePrinter() override
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)
OptPassGateInstrumentation(LLVMContext &Context)
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
LLVM_ABI bool shouldRun(StringRef PassName, Any IR)
Extensions to this class implement mechanisms to disable passes and individual optimizations at compi...
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
StringMap< T > & getData()
std::vector< std::string > Order
const StringMap< T > & getData() const
std::vector< std::string > & getOrder()
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()
LLVM_ABI ~PrintCrashIRInstrumentation()
PrintCrashIRInstrumentation()
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
Instrumentation to print IR before/after passes.
LLVM_ABI ~PrintIRInstrumentation()
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC)
PrintPassInstrumentation(bool Enabled, PrintPassOptions Opts)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This class provides an interface to register all the standard pass instrumentations and manages their...
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC, ModuleAnalysisManager *MAM=nullptr)
TimePassesHandler & getTimePasses()
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
iterator find(StringRef Key)
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
This class implements -time-passes functionality for new pass manager.
This class implements –time-trace functionality for new pass manager.
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
LLVM Value Representation.
VerifyInstrumentation(bool DebugLogging)
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.
Implement std::hash so that hash_code can be used in STL containers.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
BBGuard(const BasicBlock *BB)
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)
bool operator==(const CFG &G) const
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.