15#ifndef LLVM_PASSES_STANDARDINSTRUMENTATIONS_H
16#define LLVM_PASSES_STANDARDINSTRUMENTATIONS_H
58 struct PassRunDescriptor {
60 const unsigned PassNumber;
61 const std::string IRFileDisplayName;
62 const std::string IRName;
65 PassRunDescriptor(
const Module *M,
unsigned PassNumber,
66 std::string &&IRFileDisplayName, std::string &&IRName,
68 : M{M}, PassNumber{PassNumber}, IRFileDisplayName(IRFileDisplayName),
78 bool shouldPrintBeforeCurrentPassNumber();
79 bool shouldPrintAfterCurrentPassNumber();
80 bool shouldPrintPassNumbers();
81 bool shouldPrintBeforeSomePassNumber();
82 bool shouldPrintAfterSomePassNumber();
88 enum class IRDumpFileSuffixType {
95 getFileSuffix(PrintIRInstrumentation::IRDumpFileSuffixType
Type);
98 IRDumpFileSuffixType SuffixType);
106 unsigned CurrentPassNumber = 0;
124 bool HasWrittenIR =
false;
150 : Enabled(Enabled), Opts(Opts) {}
181 std::optional<DenseMap<intptr_t, BBGuard>>
BBGuards;
192 return BB.second.isPoisoned();
199 FunctionAnalysisManager::Invalidator &);
202#if LLVM_ENABLE_ABI_BREAKING_CHECKS
235 void addTrait(std::unique_ptr<ExtendedIRTraits> trait) {
236 traits.push_back(std::move(trait));
279 IRUnitT &Output) = 0;
284 const IRUnitT &Before,
const IRUnitT &After,
311template <
typename IRUnitT>
346 std::string &Output)
override;
349 const std::string &Before,
const std::string &After,
375 const std::string &Before,
const std::string &After,
385 B.print(SS,
nullptr,
true,
true);
477 std::function<
void(
bool InModule,
unsigned Minor,
486 template <
typename FunctionT>
519 StringRef Divider,
bool InModule,
unsigned Minor,
581 std::pair<std::string, std::string> SS{Succ.
str(), Label.str()};
624 StringRef Divider,
bool InModule,
unsigned Minor,
629 std::unique_ptr<raw_fd_ostream>
HTML;
636 :
SavedIR(
"*** Dump of IR Before Last Pass Unknown ***") {}
648 static void SignalHandler(
void *);
675 bool VerifyEach =
false,
687extern template class BlockDataT<EmptyData>;
688extern template class FuncDataT<EmptyData>;
689extern template class IRDataT<EmptyData>;
690extern 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++ -*-----------—===//
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
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
bool operator==(const BlockDataT &That) const
StringRef getLabel() const
BlockDataT(const MachineBasicBlock &B)
BlockDataT(const BasicBlock &B)
const T & getData() const
StringRef getBody() const
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
ExtendedIRContext * context
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)
DotCfgChangeReporter(bool Verbose)
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
ExtendedIRTraits()=default
virtual std::optional< std::string > getIRName(IRUnitRef IR) const =0
virtual ~ExtendedIRTraits()=default
ExtendedIRTraits(ExtendedIRTraits &&)=delete
std::string getEntryBlockName() const
std::string EntryBlockName
IRChangedPrinter(bool VerboseMode)
~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...
void generateIRRepresentation(IRUnitRef IR, StringRef PassID, IRDataT< EmptyData > &Output) override
InLineChangePrinter(bool VerboseMode, bool ColourMode)
~InLineChangePrinter() override
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.
A Module instance is used to store all the information related to an LLVM module.
OptNoneInstrumentation(bool DebugLogging)
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC, ExtendedIRContext *IRContext=nullptr)
LLVM_ABI void registerCallbacks(PassInstrumentationCallbacks &PIC, ExtendedIRContext *IRContext=nullptr)
OptPassGateInstrumentation(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
StringMap< T > & getData()
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.
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, 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)
TimePassesHandler & getTimePasses()
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
StringMapIterBase< ValueTy, true > const_iterator
Represent a constant reference to a string, i.e.
std::string str() const
Get the contents as an std::string.
void handleInvalidated(StringRef PassID) override
void handleInitialIR(IRUnitRef IR) override
TextChangeReporter(bool Verbose)
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 TimeProfilingPassesHandler()
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.
Value * getValPtr() const
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.
@ 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.
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()=default
ExtendedIRContext(ExtendedIRContext &&)=delete
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)
LLVM_ABI CFG(const Function *F, bool TrackBBLifetime)
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.