LLVM  8.0.1
StandardInstrumentations.h
Go to the documentation of this file.
1 //===- StandardInstrumentations.h ------------------------------*- C++ -*--===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 ///
11 /// This header defines a class that provides bookkeeping for all standard
12 /// (i.e in-tree) pass instrumentations.
13 ///
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_PASSES_STANDARDINSTRUMENTATIONS_H
17 #define LLVM_PASSES_STANDARDINSTRUMENTATIONS_H
18 
19 #include "llvm/ADT/SmallVector.h"
21 #include "llvm/IR/PassTimingInfo.h"
22 
23 #include <string>
24 #include <utility>
25 
26 namespace llvm {
27 
28 class Module;
29 
30 /// Instrumentation to print IR before/after passes.
31 ///
32 /// Needs state to be able to print module after pass that invalidates IR unit
33 /// (typically Loop or SCC).
35 public:
36  PrintIRInstrumentation() = default;
38 
40 
41 private:
42  bool printBeforePass(StringRef PassID, Any IR);
43  void printAfterPass(StringRef PassID, Any IR);
44  void printAfterPassInvalidated(StringRef PassID);
45 
46  using PrintModuleDesc = std::tuple<const Module *, std::string, StringRef>;
47 
48  void pushModuleDesc(StringRef PassID, Any IR);
49  PrintModuleDesc popModuleDesc(StringRef PassID);
50 
51  /// Stack of Module description, enough to print the module after a given
52  /// pass.
53  SmallVector<PrintModuleDesc, 2> ModuleDescStack;
54  bool StoreModuleDesc = false;
55 };
56 
57 /// This class provides an interface to register all the standard pass
58 /// instrumentations and manages their state (if any).
60  PrintIRInstrumentation PrintIR;
61  TimePassesHandler TimePasses;
62 
63 public:
64  StandardInstrumentations() = default;
65 
67 };
68 } // namespace llvm
69 
70 #endif
Definition: Any.h:27
This class represents lattice values for constants.
Definition: AllocatorList.h:24
This header defines classes/functions to handle pass execution timing information with interfaces for...
This file defines the Pass Instrumentation classes that provide instrumentation points into the pass ...
This class provides an interface to register all the standard pass instrumentations and manages their...
void registerCallbacks(PassInstrumentationCallbacks &PIC)
This class implements -time-passes functionality for new pass manager.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Instrumentation to print IR before/after passes.
Statically lint checks LLVM IR
Definition: Lint.cpp:193