LLVM  10.0.0svn
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/SmallVector.h"
20 #include "llvm/IR/PassTimingInfo.h"
21 
22 #include <string>
23 #include <utility>
24 
25 namespace llvm {
26 
27 class Module;
28 
29 /// Instrumentation to print IR before/after passes.
30 ///
31 /// Needs state to be able to print module after pass that invalidates IR unit
32 /// (typically Loop or SCC).
34 public:
35  PrintIRInstrumentation() = default;
37 
39 
40 private:
41  bool printBeforePass(StringRef PassID, Any IR);
42  void printAfterPass(StringRef PassID, Any IR);
43  void printAfterPassInvalidated(StringRef PassID);
44 
45  using PrintModuleDesc = std::tuple<const Module *, std::string, StringRef>;
46 
47  void pushModuleDesc(StringRef PassID, Any IR);
48  PrintModuleDesc popModuleDesc(StringRef PassID);
49 
50  /// Stack of Module description, enough to print the module after a given
51  /// pass.
52  SmallVector<PrintModuleDesc, 2> ModuleDescStack;
53  bool StoreModuleDesc = false;
54 };
55 
56 /// This class provides an interface to register all the standard pass
57 /// instrumentations and manages their state (if any).
59  PrintIRInstrumentation PrintIR;
60  TimePassesHandler TimePasses;
61 
62 public:
63  StandardInstrumentations() = default;
64 
66 
67  TimePassesHandler &getTimePasses() { return TimePasses; }
68 };
69 } // namespace llvm
70 
71 #endif
Definition: Any.h:26
This class represents lattice values for constants.
Definition: AllocatorList.h:23
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:48
Instrumentation to print IR before/after passes.
Statically lint checks LLVM IR
Definition: Lint.cpp:192