LLVM  14.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"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/IR/BasicBlock.h"
22 #include "llvm/IR/OptBisect.h"
23 #include "llvm/IR/PassTimingInfo.h"
24 #include "llvm/IR/ValueHandle.h"
27 
28 #include <string>
29 #include <utility>
30 
31 namespace llvm {
32 
33 class Module;
34 class Function;
35 class PassInstrumentationCallbacks;
36 
37 /// Instrumentation to print IR before/after passes.
38 ///
39 /// Needs state to be able to print module after pass that invalidates IR unit
40 /// (typically Loop or SCC).
42 public:
44 
46 
47 private:
48  void printBeforePass(StringRef PassID, Any IR);
49  void printAfterPass(StringRef PassID, Any IR);
50  void printAfterPassInvalidated(StringRef PassID);
51 
52  bool shouldPrintBeforePass(StringRef PassID);
53  bool shouldPrintAfterPass(StringRef PassID);
54 
55  using PrintModuleDesc = std::tuple<const Module *, std::string, StringRef>;
56 
57  void pushModuleDesc(StringRef PassID, Any IR);
58  PrintModuleDesc popModuleDesc(StringRef PassID);
59 
61  /// Stack of Module description, enough to print the module after a given
62  /// pass.
63  SmallVector<PrintModuleDesc, 2> ModuleDescStack;
64 };
65 
67 public:
68  OptNoneInstrumentation(bool DebugLogging) : DebugLogging(DebugLogging) {}
70 
71 private:
72  bool DebugLogging;
73  bool shouldRun(StringRef PassID, Any IR);
74 };
75 
77 public:
80 };
81 
83  /// Print adaptors and pass managers.
84  bool Verbose = false;
85  /// Don't print information for analyses.
86  bool SkipAnalyses = false;
87  /// Indent based on hierarchy.
88  bool Indent = false;
89 };
90 
91 // Debug logging for transformation and analysis passes.
93  raw_ostream &print();
94 
95 public:
97  : Enabled(Enabled), Opts(Opts) {}
99 
100 private:
101  bool Enabled;
102  PrintPassOptions Opts;
103  int Indent = 0;
104 };
105 
107 public:
108  // Keeps sticky poisoned flag for the given basic block once it has been
109  // deleted or RAUWed.
110  struct BBGuard final : public CallbackVH {
112  void deleted() override { CallbackVH::deleted(); }
114  bool isPoisoned() const { return !getValPtr(); }
115  };
116 
117  // CFG is a map BB -> {(Succ, Multiplicity)}, where BB is a non-leaf basic
118  // block, {(Succ, Multiplicity)} set of all pairs of the block's successors
119  // and the multiplicity of the edge (BB->Succ). As the mapped sets are
120  // unordered the order of successors is not tracked by the CFG. In other words
121  // this allows basic block successors to be swapped by a pass without
122  // reporting a CFG change. CFG can be guarded by basic block tracking pointers
123  // in the Graph (BBGuard). That is if any of the block is deleted or RAUWed
124  // then the CFG is treated poisoned and no block pointer of the Graph is used.
125  struct CFG {
128 
129  CFG(const Function *F, bool TrackBBLifetime);
130 
131  bool operator==(const CFG &G) const {
132  return !isPoisoned() && !G.isPoisoned() && Graph == G.Graph;
133  }
134 
135  bool isPoisoned() const {
136  return BBGuards &&
137  std::any_of(BBGuards->begin(), BBGuards->end(),
138  [](const auto &BB) { return BB.second.isPoisoned(); });
139  }
140 
141  static void printDiff(raw_ostream &out, const CFG &Before,
142  const CFG &After);
143  bool invalidate(Function &F, const PreservedAnalyses &PA,
145  };
146 
147 #ifdef LLVM_ENABLE_ABI_BREAKING_CHECKS
148  SmallVector<StringRef, 8> PassStack;
149 #endif
150 
154 };
155 
156 // Base class for classes that report changes to the IR.
157 // It presents an interface for such classes and provides calls
158 // on various events as the new pass manager transforms the IR.
159 // It also provides filtering of information based on hidden options
160 // specifying which functions are interesting.
161 // Calls are made for the following events/queries:
162 // 1. The initial IR processed.
163 // 2. To get the representation of the IR (of type \p T).
164 // 3. When a pass does not change the IR.
165 // 4. When a pass changes the IR (given both before and after representations
166 // of type \p T).
167 // 5. When an IR is invalidated.
168 // 6. When a pass is run on an IR that is not interesting (based on options).
169 // 7. When a pass is ignored (pass manager or adapter pass).
170 // 8. To compare two IR representations (of type \p T).
171 template <typename IRUnitT> class ChangeReporter {
172 protected:
173  ChangeReporter(bool RunInVerboseMode) : VerboseMode(RunInVerboseMode) {}
174 
175 public:
176  virtual ~ChangeReporter();
177 
178  // Determine if this pass/IR is interesting and if so, save the IR
179  // otherwise it is left on the stack without data.
180  void saveIRBeforePass(Any IR, StringRef PassID);
181  // Compare the IR from before the pass after the pass.
182  void handleIRAfterPass(Any IR, StringRef PassID);
183  // Handle the situation where a pass is invalidated.
184  void handleInvalidatedPass(StringRef PassID);
185 
186 protected:
187  // Register required callbacks.
189 
190  // Return true when this is a defined function for which printing
191  // of changes is desired.
192  bool isInterestingFunction(const Function &F);
193 
194  // Return true when this is a pass for which printing of changes is desired.
195  bool isInterestingPass(StringRef PassID);
196 
197  // Return true when this is a pass on IR for which printing
198  // of changes is desired.
199  bool isInteresting(Any IR, StringRef PassID);
200 
201  // Called on the first IR processed.
202  virtual void handleInitialIR(Any IR) = 0;
203  // Called before and after a pass to get the representation of the IR.
204  virtual void generateIRRepresentation(Any IR, StringRef PassID,
205  IRUnitT &Output) = 0;
206  // Called when the pass is not iteresting.
207  virtual void omitAfter(StringRef PassID, std::string &Name) = 0;
208  // Called when an interesting IR has changed.
209  virtual void handleAfter(StringRef PassID, std::string &Name,
210  const IRUnitT &Before, const IRUnitT &After,
211  Any) = 0;
212  // Called when an interesting pass is invalidated.
213  virtual void handleInvalidated(StringRef PassID) = 0;
214  // Called when the IR or pass is not interesting.
215  virtual void handleFiltered(StringRef PassID, std::string &Name) = 0;
216  // Called when an ignored pass is encountered.
217  virtual void handleIgnored(StringRef PassID, std::string &Name) = 0;
218 
219  // Stack of IRs before passes.
220  std::vector<IRUnitT> BeforeStack;
221  // Is this the first IR seen?
222  bool InitialIR = true;
223 
224  // Run in verbose mode, printing everything?
225  const bool VerboseMode;
226 };
227 
228 // An abstract template base class that handles printing banners and
229 // reporting when things have not changed or are filtered out.
230 template <typename IRUnitT>
231 class TextChangeReporter : public ChangeReporter<IRUnitT> {
232 protected:
234 
235  // Print a module dump of the first IR that is changed.
236  void handleInitialIR(Any IR) override;
237  // Report that the IR was omitted because it did not change.
238  void omitAfter(StringRef PassID, std::string &Name) override;
239  // Report that the pass was invalidated.
240  void handleInvalidated(StringRef PassID) override;
241  // Report that the IR was filtered out.
242  void handleFiltered(StringRef PassID, std::string &Name) override;
243  // Report that the pass was ignored.
244  void handleIgnored(StringRef PassID, std::string &Name) override;
245  // Make substitutions in \p S suitable for reporting changes
246  // after the pass and then print it.
247 
249 };
250 
251 // A change printer based on the string representation of the IR as created
252 // by unwrapAndPrint. The string representation is stored in a std::string
253 // to preserve it as the IR changes in each pass. Note that the banner is
254 // included in this representation but it is massaged before reporting.
255 class IRChangedPrinter : public TextChangeReporter<std::string> {
256 public:
259  ~IRChangedPrinter() override;
261 
262 protected:
263  // Called before and after a pass to get the representation of the IR.
265  std::string &Output) override;
266  // Called when an interesting IR has changed.
267  void handleAfter(StringRef PassID, std::string &Name,
268  const std::string &Before, const std::string &After,
269  Any) override;
270 };
271 
272 // Information that needs to be saved for a basic block in order to compare
273 // before and after the pass to determine if it was changed by a pass.
274 template <typename T> class BlockDataT {
275 public:
276  BlockDataT(const BasicBlock &B) : Label(B.getName().str()), Data(B) {
278  B.print(SS, nullptr, true, true);
279  }
280 
281  bool operator==(const BlockDataT &That) const { return Body == That.Body; }
282  bool operator!=(const BlockDataT &That) const { return Body != That.Body; }
283 
284  // Return the label of the represented basic block.
285  StringRef getLabel() const { return Label; }
286  // Return the string representation of the basic block.
287  StringRef getBody() const { return Body; }
288 
289  // Return the associated data
290  const T &getData() const { return Data; }
291 
292 protected:
293  std::string Label;
294  std::string Body;
295 
296  // Extra data associated with a basic block
298 };
299 
300 template <typename T> class OrderedChangedData {
301 public:
302  // Return the names in the order they were saved
303  std::vector<std::string> &getOrder() { return Order; }
304  const std::vector<std::string> &getOrder() const { return Order; }
305 
306  // Return a map of names to saved representations
307  StringMap<T> &getData() { return Data; }
308  const StringMap<T> &getData() const { return Data; }
309 
310  bool operator==(const OrderedChangedData<T> &That) const {
311  return Data == That.getData();
312  }
313 
314  // Call the lambda \p HandlePair on each corresponding pair of data from
315  // \p Before and \p After. The order is based on the order in \p After
316  // with ones that are only in \p Before interspersed based on where they
317  // occur in \p Before. This is used to present the output in an order
318  // based on how the data is ordered in LLVM.
319  static void report(const OrderedChangedData &Before,
320  const OrderedChangedData &After,
321  function_ref<void(const T *, const T *)> HandlePair);
322 
323 protected:
324  std::vector<std::string> Order;
326 };
327 
328 // Do not need extra information for patch-style change reporter.
329 class EmptyData {
330 public:
331  EmptyData(const BasicBlock &) {}
332 };
333 
334 // The data saved for comparing functions.
335 template <typename T>
336 class FuncDataT : public OrderedChangedData<BlockDataT<T>> {
337 public:
338  FuncDataT(std::string S) : EntryBlockName(S) {}
339 
340  // Return the name of the entry block
341  std::string getEntryBlockName() const { return EntryBlockName; }
342 
343 protected:
344  std::string EntryBlockName;
345 };
346 
347 // The data saved for comparing IRs.
348 template <typename T>
349 class IRDataT : public OrderedChangedData<FuncDataT<T>> {};
350 
351 // Abstract template base class for a class that compares two IRs. The
352 // class is created with the 2 IRs to compare and then compare is called.
353 // The static function analyzeIR is used to build up the IR representation.
354 template <typename T> class IRComparer {
355 public:
357  : Before(Before), After(After) {}
358 
359  // Compare the 2 IRs. \p handleFunctionCompare is called to handle the
360  // compare of a function. When \p InModule is set,
361  // this function is being handled as part of comparing a module.
362  void compare(
363  bool CompareModule,
364  std::function<void(bool InModule, unsigned Minor,
365  const FuncDataT<T> &Before, const FuncDataT<T> &After)>
366  CompareFunc);
367 
368  // Analyze \p IR and build the IR representation in \p Data.
369  static void analyzeIR(Any IR, IRDataT<T> &Data);
370 
371 protected:
372  // Generate the data for \p F into \p Data.
373  static bool generateFunctionData(IRDataT<T> &Data, const Function &F);
374 
377 };
378 
379 // A change printer that prints out in-line differences in the basic
380 // blocks. It uses an InlineComparer to do the comparison so it shows
381 // the differences prefixed with '-' and '+' for code that is removed
382 // and added, respectively. Changes to the IR that do not affect basic
383 // blocks are not reported as having changed the IR. The option
384 // -print-module-scope does not affect this change reporter.
385 class InLineChangePrinter : public TextChangeReporter<IRDataT<EmptyData>> {
386 public:
387  InLineChangePrinter(bool VerboseMode, bool ColourMode)
389  UseColour(ColourMode) {}
390  ~InLineChangePrinter() override;
392 
393 protected:
394  // Create a representation of the IR.
395  virtual void generateIRRepresentation(Any IR, StringRef PassID,
396  IRDataT<EmptyData> &Output) override;
397 
398  // Called when an interesting IR has changed.
399  virtual void handleAfter(StringRef PassID, std::string &Name,
400  const IRDataT<EmptyData> &Before,
401  const IRDataT<EmptyData> &After, Any) override;
402 
404  StringRef Divider, bool InModule, unsigned Minor,
405  const FuncDataT<EmptyData> &Before,
406  const FuncDataT<EmptyData> &After);
407 
408  bool UseColour;
409 };
410 
412  bool DebugLogging;
413 
414 public:
415  VerifyInstrumentation(bool DebugLogging) : DebugLogging(DebugLogging) {}
417 };
418 
419 // Class that holds transitions between basic blocks. The transitions
420 // are contained in a map of values to names of basic blocks.
421 class DCData {
422 public:
423  // Fill the map with the transitions from basic block \p B.
424  DCData(const BasicBlock &B);
425 
426  // Return an iterator to the names of the successor blocks.
428  return Successors.begin();
429  }
431  return Successors.end();
432  }
433 
434  // Return the label of the basic block reached on a transition on \p S.
436  assert(Successors.count(S) == 1 && "Expected to find successor.");
437  return Successors.find(S)->getValue();
438  }
439 
440 protected:
441  // Add a transition to \p Succ on \p Label
443  std::pair<std::string, std::string> SS{Succ.str(), Label.str()};
445  }
446 
448 };
449 
450 // A change reporter that builds a website with links to pdf files showing
451 // dot control flow graphs with changed instructions shown in colour.
452 class DotCfgChangeReporter : public ChangeReporter<IRDataT<DCData>> {
453 public:
455  ~DotCfgChangeReporter() override;
457 
458 protected:
459  // Initialize the HTML file and output the header.
460  bool initializeHTML();
461 
462  // Called on the first IR processed.
463  void handleInitialIR(Any IR) override;
464  // Called before and after a pass to get the representation of the IR.
466  IRDataT<DCData> &Output) override;
467  // Called when the pass is not iteresting.
468  void omitAfter(StringRef PassID, std::string &Name) override;
469  // Called when an interesting IR has changed.
470  void handleAfter(StringRef PassID, std::string &Name,
471  const IRDataT<DCData> &Before, const IRDataT<DCData> &After,
472  Any) override;
473  // Called when an interesting pass is invalidated.
474  void handleInvalidated(StringRef PassID) override;
475  // Called when the IR or pass is not interesting.
476  void handleFiltered(StringRef PassID, std::string &Name) override;
477  // Called when an ignored pass is encountered.
478  void handleIgnored(StringRef PassID, std::string &Name) override;
479 
480  // Generate the pdf file into \p Dir / \p PDFFileName using \p DotFile as
481  // input and return the html <a> tag with \Text as the content.
482  static std::string genHTML(StringRef Text, StringRef DotFile,
483  StringRef PDFFileName);
484 
486  StringRef Divider, bool InModule, unsigned Minor,
487  const FuncDataT<DCData> &Before,
488  const FuncDataT<DCData> &After);
489 
490  unsigned N = 0;
491  std::unique_ptr<raw_fd_ostream> HTML;
492 };
493 
494 /// This class provides an interface to register all the standard pass
495 /// instrumentations and manages their state (if any).
497  PrintIRInstrumentation PrintIR;
498  PrintPassInstrumentation PrintPass;
499  TimePassesHandler TimePasses;
500  OptNoneInstrumentation OptNone;
502  PreservedCFGCheckerInstrumentation PreservedCFGChecker;
503  IRChangedPrinter PrintChangedIR;
504  PseudoProbeVerifier PseudoProbeVerification;
505  InLineChangePrinter PrintChangedDiff;
506  DotCfgChangeReporter WebsiteChangeReporter;
507  VerifyInstrumentation Verify;
508 
509  bool VerifyEach;
510 
511 public:
512  StandardInstrumentations(bool DebugLogging, bool VerifyEach = false,
513  PrintPassOptions PrintPassOpts = PrintPassOptions());
514 
515  // Register all the standard instrumentation callbacks. If \p FAM is nullptr
516  // then PreservedCFGChecker is not enabled.
518  FunctionAnalysisManager *FAM = nullptr);
519 
520  TimePassesHandler &getTimePasses() { return TimePasses; }
521 };
522 
523 extern template class ChangeReporter<std::string>;
524 extern template class TextChangeReporter<std::string>;
525 
526 extern template class BlockDataT<EmptyData>;
527 extern template class FuncDataT<EmptyData>;
528 extern template class IRDataT<EmptyData>;
529 extern template class ChangeReporter<IRDataT<EmptyData>>;
530 extern template class TextChangeReporter<IRDataT<EmptyData>>;
531 extern template class IRComparer<EmptyData>;
532 
533 } // namespace llvm
534 
535 #endif
llvm::OrderedChangedData
Definition: StandardInstrumentations.h:300
llvm::BlockDataT::getData
const T & getData() const
Definition: StandardInstrumentations.h:290
llvm::BlockDataT::getLabel
StringRef getLabel() const
Definition: StandardInstrumentations.h:285
llvm::InLineChangePrinter::~InLineChangePrinter
~InLineChangePrinter() override
Definition: StandardInstrumentations.cpp:1210
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
llvm::ChangeReporter::omitAfter
virtual void omitAfter(StringRef PassID, std::string &Name)=0
llvm::IRDataT
Definition: StandardInstrumentations.h:349
llvm::ChangeReporter::ChangeReporter
ChangeReporter(bool RunInVerboseMode)
Definition: StandardInstrumentations.h:173
llvm::IRComparer::generateFunctionData
static bool generateFunctionData(IRDataT< T > &Data, const Function &F)
Definition: StandardInstrumentations.cpp:740
getName
static StringRef getName(Value *V)
Definition: ProvenanceAnalysisEvaluator.cpp:42
llvm::PreservedCFGCheckerInstrumentation::BBGuard::isPoisoned
bool isPoisoned() const
Definition: StandardInstrumentations.h:114
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::CallbackVH::deleted
virtual void deleted()
Callback for Value destruction.
Definition: ValueHandle.h:414
llvm::DotCfgChangeReporter::~DotCfgChangeReporter
~DotCfgChangeReporter() override
Definition: StandardInstrumentations.cpp:2077
llvm::BlockDataT::operator!=
bool operator!=(const BlockDataT &That) const
Definition: StandardInstrumentations.h:282
llvm::ChangeReporter::handleFiltered
virtual void handleFiltered(StringRef PassID, std::string &Name)=0
llvm::cl::Prefix
@ Prefix
Definition: CommandLine.h:164
llvm::OrderedChangedData::getOrder
std::vector< std::string > & getOrder()
Definition: StandardInstrumentations.h:303
llvm::Function
Definition: Function.h:62
StringRef.h
llvm::TextChangeReporter::handleIgnored
void handleIgnored(StringRef PassID, std::string &Name) override
Definition: StandardInstrumentations.cpp:586
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:625
llvm::TextChangeReporter::TextChangeReporter
TextChangeReporter(bool Verbose)
Definition: StandardInstrumentations.cpp:554
llvm::InlinerFunctionImportStatsOpts::Verbose
@ Verbose
llvm::SmallVector< PrintModuleDesc, 2 >
llvm::DotCfgChangeReporter::generateIRRepresentation
void generateIRRepresentation(Any IR, StringRef PassID, IRDataT< DCData > &Output) override
Definition: StandardInstrumentations.cpp:1986
llvm::DotCfgChangeReporter::handleFunctionCompare
void handleFunctionCompare(StringRef Name, StringRef Prefix, StringRef PassID, StringRef Divider, bool InModule, unsigned Minor, const FuncDataT< DCData > &Before, const FuncDataT< DCData > &After)
Definition: StandardInstrumentations.cpp:1901
llvm::TextChangeReporter::handleInitialIR
void handleInitialIR(Any IR) override
Definition: StandardInstrumentations.cpp:557
llvm::PrintPassInstrumentation::PrintPassInstrumentation
PrintPassInstrumentation(bool Enabled, PrintPassOptions Opts)
Definition: StandardInstrumentations.h:96
llvm::StandardInstrumentations::registerCallbacks
void registerCallbacks(PassInstrumentationCallbacks &PIC, FunctionAnalysisManager *FAM=nullptr)
Definition: StandardInstrumentations.cpp:2132
llvm::DotCfgChangeReporter::DotCfgChangeReporter
DotCfgChangeReporter(bool Verbose)
Definition: StandardInstrumentations.cpp:1893
llvm::OptNoneInstrumentation::OptNoneInstrumentation
OptNoneInstrumentation(bool DebugLogging)
Definition: StandardInstrumentations.h:68
llvm::PrintIRInstrumentation::~PrintIRInstrumentation
~PrintIRInstrumentation()
Definition: StandardInstrumentations.cpp:754
llvm::BlockDataT::BlockDataT
BlockDataT(const BasicBlock &B)
Definition: StandardInstrumentations.h:276
llvm::PreservedCFGCheckerInstrumentation
Definition: StandardInstrumentations.h:106
llvm::InLineChangePrinter::handleFunctionCompare
void handleFunctionCompare(StringRef Name, StringRef Prefix, StringRef PassID, StringRef Divider, bool InModule, unsigned Minor, const FuncDataT< EmptyData > &Before, const FuncDataT< EmptyData > &After)
Definition: StandardInstrumentations.cpp:1234
llvm::DCData::end
StringMap< std::string >::const_iterator end() const
Definition: StandardInstrumentations.h:430
llvm::DotCfgChangeReporter::registerCallbacks
void registerCallbacks(PassInstrumentationCallbacks &PIC)
Definition: StandardInstrumentations.cpp:2102
FAM
FunctionAnalysisManager FAM
Definition: PassBuilderBindings.cpp:59
llvm::DotCfgChangeReporter::omitAfter
void omitAfter(StringRef PassID, std::string &Name) override
Definition: StandardInstrumentations.cpp:1991
llvm::StringMap::end
iterator end()
Definition: StringMap.h:203
llvm::ChangeReporter::isInterestingFunction
bool isInterestingFunction(const Function &F)
Definition: StandardInstrumentations.cpp:449
llvm::ChangeReporter::handleAfter
virtual void handleAfter(StringRef PassID, std::string &Name, const IRUnitT &Before, const IRUnitT &After, Any)=0
llvm::IRChangedPrinter::generateIRRepresentation
void generateIRRepresentation(Any IR, StringRef PassID, std::string &Output) override
Definition: StandardInstrumentations.cpp:598
llvm::DotCfgChangeReporter::handleInitialIR
void handleInitialIR(Any IR) override
Definition: StandardInstrumentations.cpp:1962
PIC
PassInstrumentationCallbacks PIC
Definition: PassBuilderBindings.cpp:55
OptBisect.h
llvm::ValueHandleBase::getValPtr
Value * getValPtr() const
Definition: ValueHandle.h:99
llvm::PrintPassInstrumentation
Definition: StandardInstrumentations.h:92
llvm::Optional
Definition: APInt.h:33
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::IRComparer::IRComparer
IRComparer(const IRDataT< T > &Before, const IRDataT< T > &After)
Definition: StandardInstrumentations.h:356
llvm::TextChangeReporter::handleInvalidated
void handleInvalidated(StringRef PassID) override
Definition: StandardInstrumentations.cpp:573
STLExtras.h
llvm::InLineChangePrinter::generateIRRepresentation
virtual void generateIRRepresentation(Any IR, StringRef PassID, IRDataT< EmptyData > &Output) override
Definition: StandardInstrumentations.cpp:1212
llvm::StringMap::find
iterator find(StringRef Key)
Definition: StringMap.h:216
llvm::PreservedCFGCheckerInstrumentation::CFG::printDiff
static void printDiff(raw_ostream &out, const CFG &Before, const CFG &After)
Definition: StandardInstrumentations.cpp:1014
llvm::StandardInstrumentations::StandardInstrumentations
StandardInstrumentations(bool DebugLogging, bool VerifyEach=false, PrintPassOptions PrintPassOpts=PrintPassOptions())
Definition: StandardInstrumentations.cpp:2119
llvm::ChangeReporter::saveIRBeforePass
void saveIRBeforePass(Any IR, StringRef PassID)
Definition: StandardInstrumentations.cpp:475
llvm::OrderedChangedData::Data
StringMap< T > Data
Definition: StandardInstrumentations.h:325
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::ChangeReporter::handleIgnored
virtual void handleIgnored(StringRef PassID, std::string &Name)=0
llvm::PreservedCFGCheckerInstrumentation::registerCallbacks
void registerCallbacks(PassInstrumentationCallbacks &PIC, FunctionAnalysisManager &FAM)
Definition: StandardInstrumentations.cpp:1108
llvm::ChangeReporter::registerRequiredCallbacks
void registerRequiredCallbacks(PassInstrumentationCallbacks &PIC)
Definition: StandardInstrumentations.cpp:538
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:58
llvm::FuncDataT::getEntryBlockName
std::string getEntryBlockName() const
Definition: StandardInstrumentations.h:341
llvm::IRChangedPrinter::IRChangedPrinter
IRChangedPrinter(bool VerboseMode)
Definition: StandardInstrumentations.h:257
llvm::ChangeReporter::BeforeStack
std::vector< IRUnitT > BeforeStack
Definition: StandardInstrumentations.h:220
PassTimingInfo.h
CommandLine.h
llvm::TextChangeReporter::Out
raw_ostream & Out
Definition: StandardInstrumentations.h:248
llvm::IRComparer::compare
void compare(bool CompareModule, std::function< void(bool InModule, unsigned Minor, const FuncDataT< T > &Before, const FuncDataT< T > &After)> CompareFunc)
Definition: StandardInstrumentations.cpp:692
llvm::PrintPassOptions::SkipAnalyses
bool SkipAnalyses
Don't print information for analyses.
Definition: StandardInstrumentations.h:86
llvm::PrintIRInstrumentation::registerCallbacks
void registerCallbacks(PassInstrumentationCallbacks &PIC)
Definition: StandardInstrumentations.cpp:853
llvm::DCData::DCData
DCData(const BasicBlock &B)
Definition: StandardInstrumentations.cpp:1870
llvm::OptNoneInstrumentation::registerCallbacks
void registerCallbacks(PassInstrumentationCallbacks &PIC)
Definition: StandardInstrumentations.cpp:875
llvm::OrderedChangedData::operator==
bool operator==(const OrderedChangedData< T > &That) const
Definition: StandardInstrumentations.h:310
llvm::DotCfgChangeReporter::genHTML
static std::string genHTML(StringRef Text, StringRef DotFile, StringRef PDFFileName)
Definition: StandardInstrumentations.cpp:1943
llvm::FuncDataT
Definition: StandardInstrumentations.h:336
llvm::StandardInstrumentations::getTimePasses
TimePassesHandler & getTimePasses()
Definition: StandardInstrumentations.h:520
llvm::PrintPassOptions
Definition: StandardInstrumentations.h:82
llvm::OptBisect
This class implements a mechanism to disable passes and individual optimizations at compile time base...
Definition: OptBisect.h:45
llvm::PseudoProbeVerifier
Definition: SampleProfileProbe.h:59
llvm::OrderedChangedData::getData
StringMap< T > & getData()
Definition: StandardInstrumentations.h:307
llvm::StringMap::insert
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:274
llvm::VerifyInstrumentation::registerCallbacks
void registerCallbacks(PassInstrumentationCallbacks &PIC)
Definition: StandardInstrumentations.cpp:1174
llvm::DotCfgChangeReporter
Definition: StandardInstrumentations.h:452
llvm::InLineChangePrinter::InLineChangePrinter
InLineChangePrinter(bool VerboseMode, bool ColourMode)
Definition: StandardInstrumentations.h:387
llvm::DCData::Successors
StringMap< std::string > Successors
Definition: StandardInstrumentations.h:447
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::FuncDataT::FuncDataT
FuncDataT(std::string S)
Definition: StandardInstrumentations.h:338
llvm::OrderedChangedData::report
static void report(const OrderedChangedData &Before, const OrderedChangedData &After, function_ref< void(const T *, const T *)> HandlePair)
Definition: StandardInstrumentations.cpp:624
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::PreservedCFGCheckerInstrumentation::BBGuard::BBGuard
BBGuard(const BasicBlock *BB)
Definition: StandardInstrumentations.h:111
llvm::IRComparer::After
const IRDataT< T > & After
Definition: StandardInstrumentations.h:376
llvm::BlockDataT
Definition: StandardInstrumentations.h:274
IR
Statically lint checks LLVM IR
Definition: Lint.cpp:746
llvm::DotCfgChangeReporter::N
unsigned N
Definition: StandardInstrumentations.h:490
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:670
llvm::ChangeReporter::handleInitialIR
virtual void handleInitialIR(Any IR)=0
llvm::StringRef::str
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:244
llvm::PrintPassOptions::Indent
bool Indent
Indent based on hierarchy.
Definition: StandardInstrumentations.h:88
llvm::DotCfgChangeReporter::handleAfter
void handleAfter(StringRef PassID, std::string &Name, const IRDataT< DCData > &Before, const IRDataT< DCData > &After, Any) override
Definition: StandardInstrumentations.cpp:2000
llvm::DCData::addSuccessorLabel
void addSuccessorLabel(StringRef Succ, StringRef Label)
Definition: StandardInstrumentations.h:442
llvm::StringMap< T >
llvm::DotCfgChangeReporter::handleIgnored
void handleIgnored(StringRef PassID, std::string &Name) override
Definition: StandardInstrumentations.cpp:2033
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::PrintIRInstrumentation
Instrumentation to print IR before/after passes.
Definition: StandardInstrumentations.h:41
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
BasicBlock.h
llvm::cl::opt< bool >
llvm::ChangeReporter
Definition: StandardInstrumentations.h:171
llvm::PreservedCFGCheckerInstrumentation::BBGuard::deleted
void deleted() override
Callback for Value destruction.
Definition: StandardInstrumentations.h:112
llvm::OptNoneInstrumentation
Definition: StandardInstrumentations.h:66
llvm::StandardInstrumentations
This class provides an interface to register all the standard pass instrumentations and manages their...
Definition: StandardInstrumentations.h:496
llvm::IRChangedPrinter
Definition: StandardInstrumentations.h:255
llvm::TextChangeReporter::handleFiltered
void handleFiltered(StringRef PassID, std::string &Name) override
Definition: StandardInstrumentations.cpp:578
llvm::DenseMap
Definition: DenseMap.h:714
llvm::TextChangeReporter
Definition: StandardInstrumentations.h:231
llvm::EmptyData
Definition: StandardInstrumentations.h:329
llvm::ChangeReporter::isInteresting
bool isInteresting(Any IR, StringRef PassID)
Definition: StandardInstrumentations.cpp:466
llvm::BlockDataT::Label
std::string Label
Definition: StandardInstrumentations.h:293
llvm::FuncDataT::EntryBlockName
std::string EntryBlockName
Definition: StandardInstrumentations.h:344
llvm::PreservedCFGCheckerInstrumentation::CFG::BBGuards
Optional< DenseMap< intptr_t, BBGuard > > BBGuards
Definition: StandardInstrumentations.h:126
llvm::BlockDataT::getBody
StringRef getBody() const
Definition: StandardInstrumentations.h:287
llvm::StringMap::begin
iterator begin()
Definition: StringMap.h:202
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::ChangeReporter::handleIRAfterPass
void handleIRAfterPass(Any IR, StringRef PassID)
Definition: StandardInstrumentations.cpp:496
llvm::IRComparer::analyzeIR
static void analyzeIR(Any IR, IRDataT< T > &Data)
Definition: StandardInstrumentations.cpp:719
llvm::OptBisectInstrumentation::OptBisectInstrumentation
OptBisectInstrumentation()
Definition: StandardInstrumentations.h:78
llvm::DotCfgChangeReporter::initializeHTML
bool initializeHTML()
Definition: StandardInstrumentations.cpp:2041
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::PreservedCFGCheckerInstrumentation::CFG::invalidate
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Definition: StandardInstrumentations.cpp:1100
SampleProfileProbe.h
llvm::PreservedCFGCheckerInstrumentation::CFG
Definition: StandardInstrumentations.h:125
llvm::InLineChangePrinter::UseColour
bool UseColour
Definition: StandardInstrumentations.h:408
llvm::IRChangedPrinter::handleAfter
void handleAfter(StringRef PassID, std::string &Name, const std::string &Before, const std::string &After, Any) override
Definition: StandardInstrumentations.cpp:605
llvm::InLineChangePrinter
Definition: StandardInstrumentations.h:385
llvm::any_of
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:1588
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
VerifyEach
bool VerifyEach
Definition: PassBuilderBindings.cpp:52
llvm::ChangeReporter::generateIRRepresentation
virtual void generateIRRepresentation(Any IR, StringRef PassID, IRUnitT &Output)=0
llvm::PreservedCFGCheckerInstrumentation::CFG::isPoisoned
bool isPoisoned() const
Definition: StandardInstrumentations.h:135
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::PreservedCFGCheckerInstrumentation::BBGuard::allUsesReplacedWith
void allUsesReplacedWith(Value *) override
Callback for Value RAUW.
Definition: StandardInstrumentations.h:113
ValueHandle.h
llvm::PreservedCFGCheckerInstrumentation::CFG::operator==
bool operator==(const CFG &G) const
Definition: StandardInstrumentations.h:131
llvm::VerifyInstrumentation
Definition: StandardInstrumentations.h:411
llvm::PrintPassOptions::Verbose
bool Verbose
Print adaptors and pass managers.
Definition: StandardInstrumentations.h:84
llvm::InLineChangePrinter::handleAfter
virtual void handleAfter(StringRef PassID, std::string &Name, const IRDataT< EmptyData > &Before, const IRDataT< EmptyData > &After, Any) override
Definition: StandardInstrumentations.cpp:1217
llvm::Any
Definition: Any.h:26
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
std
Definition: BitVector.h:838
llvm::EmptyData::EmptyData
EmptyData(const BasicBlock &)
Definition: StandardInstrumentations.h:331
llvm::IRComparer::Before
const IRDataT< T > & Before
Definition: StandardInstrumentations.h:375
llvm::DotCfgChangeReporter::handleInvalidated
void handleInvalidated(StringRef PassID) override
Definition: StandardInstrumentations.cpp:2016
llvm::TextChangeReporter::omitAfter
void omitAfter(StringRef PassID, std::string &Name) override
Definition: StandardInstrumentations.cpp:567
llvm::InLineChangePrinter::registerCallbacks
void registerCallbacks(PassInstrumentationCallbacks &PIC)
Definition: StandardInstrumentations.cpp:1255
llvm::OrderedChangedData::getOrder
const std::vector< std::string > & getOrder() const
Definition: StandardInstrumentations.h:304
llvm::StringMap::count
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Definition: StringMap.h:244
llvm::OptBisectInstrumentation::registerCallbacks
void registerCallbacks(PassInstrumentationCallbacks &PIC)
Definition: StandardInstrumentations.cpp:896
llvm::PreservedCFGCheckerInstrumentation::BBGuard
Definition: StandardInstrumentations.h:110
llvm::CallbackVH
Value handle with callbacks on RAUW and destruction.
Definition: ValueHandle.h:383
llvm::BlockDataT::Data
T Data
Definition: StandardInstrumentations.h:297
llvm::ChangeReporter::handleInvalidated
virtual void handleInvalidated(StringRef PassID)=0
llvm::ChangeReporter::handleInvalidatedPass
void handleInvalidatedPass(StringRef PassID)
Definition: StandardInstrumentations.cpp:525
llvm::PreservedCFGCheckerInstrumentation::CFG::CFG
CFG(const Function *F, bool TrackBBLifetime)
Definition: StandardInstrumentations.cpp:973
llvm::ChangeReporter::InitialIR
bool InitialIR
Definition: StandardInstrumentations.h:222
llvm::X86AS::SS
@ SS
Definition: X86.h:189
SmallVector.h
llvm::BlockDataT::Body
std::string Body
Definition: StandardInstrumentations.h:294
llvm::PassInstrumentationCallbacks
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
Definition: PassInstrumentation.h:66
llvm::ChangeReporter::VerboseMode
const bool VerboseMode
Definition: StandardInstrumentations.h:225
llvm::DCData::begin
StringMap< std::string >::const_iterator begin() const
Definition: StandardInstrumentations.h:427
llvm::BlockDataT::operator==
bool operator==(const BlockDataT &That) const
Definition: StandardInstrumentations.h:281
llvm::ChangeReporter::~ChangeReporter
virtual ~ChangeReporter()
Definition: StandardInstrumentations.cpp:444
llvm::DCData
Definition: StandardInstrumentations.h:421
llvm::TimePassesHandler
This class implements -time-passes functionality for new pass manager.
Definition: PassTimingInfo.h:46
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::ChangeReporter::isInterestingPass
bool isInterestingPass(StringRef PassID)
Definition: StandardInstrumentations.cpp:454
llvm::IRChangedPrinter::registerCallbacks
void registerCallbacks(PassInstrumentationCallbacks &PIC)
Definition: StandardInstrumentations.cpp:592
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
llvm::OptBisectInstrumentation
Definition: StandardInstrumentations.h:76
llvm::IRChangedPrinter::~IRChangedPrinter
~IRChangedPrinter() override
Definition: StandardInstrumentations.cpp:590
llvm::DotCfgChangeReporter::HTML
std::unique_ptr< raw_fd_ostream > HTML
Definition: StandardInstrumentations.h:491
llvm::IRComparer
Definition: StandardInstrumentations.h:354
llvm::DCData::getSuccessorLabel
const StringRef getSuccessorLabel(StringRef S) const
Definition: StandardInstrumentations.h:435
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::OrderedChangedData::getData
const StringMap< T > & getData() const
Definition: StandardInstrumentations.h:308
llvm::DotCfgChangeReporter::handleFiltered
void handleFiltered(StringRef PassID, std::string &Name) override
Definition: StandardInstrumentations.cpp:2024
llvm::OrderedChangedData::Order
std::vector< std::string > Order
Definition: StandardInstrumentations.h:324
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::PreservedCFGCheckerInstrumentation::CFG::Graph
DenseMap< const BasicBlock *, DenseMap< const BasicBlock *, unsigned > > Graph
Definition: StandardInstrumentations.h:127
llvm::VerifyInstrumentation::VerifyInstrumentation
VerifyInstrumentation(bool DebugLogging)
Definition: StandardInstrumentations.h:415
llvm::PrintPassInstrumentation::registerCallbacks
void registerCallbacks(PassInstrumentationCallbacks &PIC)
Definition: StandardInstrumentations.cpp:913
SpecialSubKind::string
@ string
llvm::PreservedCFGCheckerInstrumentation::VerifyPreservedCFG
static cl::opt< bool > VerifyPreservedCFG
Definition: StandardInstrumentations.h:151