LLVM  7.0.0
JITEventListener.h
Go to the documentation of this file.
1 //===- JITEventListener.h - Exposes events from JIT compilation -*- 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 //
10 // This file defines the JITEventListener interface, which lets users get
11 // callbacks when significant events happen during the JIT compilation process.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
16 #define LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
17 
18 #include "llvm-c/ExecutionEngine.h"
19 #include "llvm/Config/llvm-config.h"
21 #include "llvm/IR/DebugLoc.h"
23 #include <cstdint>
24 #include <vector>
25 
26 namespace llvm {
27 
28 class IntelJITEventsWrapper;
29 class MachineFunction;
30 class OProfileWrapper;
31 
32 namespace object {
33 
34 class ObjectFile;
35 
36 } // end namespace object
37 
38 /// JITEvent_EmittedFunctionDetails - Helper struct for containing information
39 /// about a generated machine code function.
41  struct LineStart {
42  /// The address at which the current line changes.
43  uintptr_t Address;
44 
45  /// The new location information. These can be translated to DebugLocTuples
46  /// using MF->getDebugLocTuple().
48  };
49 
50  /// The machine function the struct contains information for.
52 
53  /// The list of line boundary information, sorted by address.
54  std::vector<LineStart> LineStarts;
55 };
56 
57 /// JITEventListener - Abstract interface for use by the JIT to notify clients
58 /// about significant events during compilation. For example, to notify
59 /// profilers and debuggers that need to know where functions have been emitted.
60 ///
61 /// The default implementation of each method does nothing.
63 public:
65 
66 public:
67  JITEventListener() = default;
68  virtual ~JITEventListener() = default;
69 
70  /// NotifyObjectEmitted - Called after an object has been successfully
71  /// emitted to memory. NotifyFunctionEmitted will not be called for
72  /// individual functions in the object.
73  ///
74  /// ELF-specific information
75  /// The ObjectImage contains the generated object image
76  /// with section headers updated to reflect the address at which sections
77  /// were loaded and with relocations performed in-place on debug sections.
78  virtual void NotifyObjectEmitted(const object::ObjectFile &Obj,
80 
81  /// NotifyFreeingObject - Called just before the memory associated with
82  /// a previously emitted object is released.
83  virtual void NotifyFreeingObject(const object::ObjectFile &Obj) {}
84 
85  // Get a pointe to the GDB debugger registration listener.
86  static JITEventListener *createGDBRegistrationListener();
87 
88 #if LLVM_USE_INTEL_JITEVENTS
89  // Construct an IntelJITEventListener
90  static JITEventListener *createIntelJITEventListener();
91 
92  // Construct an IntelJITEventListener with a test Intel JIT API implementation
93  static JITEventListener *createIntelJITEventListener(
94  IntelJITEventsWrapper* AlternativeImpl);
95 #else
96  static JITEventListener *createIntelJITEventListener() { return nullptr; }
97 
99  IntelJITEventsWrapper* AlternativeImpl) {
100  return nullptr;
101  }
102 #endif // USE_INTEL_JITEVENTS
103 
104 #if LLVM_USE_OPROFILE
105  // Construct an OProfileJITEventListener
106  static JITEventListener *createOProfileJITEventListener();
107 
108  // Construct an OProfileJITEventListener with a test opagent implementation
109  static JITEventListener *createOProfileJITEventListener(
110  OProfileWrapper* AlternativeImpl);
111 #else
112  static JITEventListener *createOProfileJITEventListener() { return nullptr; }
113 
115  OProfileWrapper* AlternativeImpl) {
116  return nullptr;
117  }
118 #endif // USE_OPROFILE
119 
120 #if LLVM_USE_PERF
121  static JITEventListener *createPerfJITEventListener();
122 #else
124  {
125  return nullptr;
126  }
127 #endif // USE_PERF
128 
129 private:
130  virtual void anchor();
131 };
132 
134 
135 } // end namespace llvm
136 
137 #endif // LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
static JITEventListener * createIntelJITEventListener()
Information about the loaded object.
Definition: RuntimeDyld.h:69
JITEvent_EmittedFunctionDetails - Helper struct for containing information about a generated machine ...
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
virtual void NotifyFreeingObject(const object::ObjectFile &Obj)
NotifyFreeingObject - Called just before the memory associated with a previously emitted object is re...
JITEventListener - Abstract interface for use by the JIT to notify clients about significant events d...
This class is the base class for all object file types.
Definition: ObjectFile.h:190
A debug info location.
Definition: DebugLoc.h:34
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
DebugLoc Loc
The new location information.
std::vector< LineStart > LineStarts
The list of line boundary information, sorted by address.
static JITEventListener * createIntelJITEventListener(IntelJITEventsWrapper *AlternativeImpl)
static JITEventListener * createPerfJITEventListener()
static JITEventListener * createOProfileJITEventListener(OProfileWrapper *AlternativeImpl)
const MachineFunction * MF
The machine function the struct contains information for.
virtual void NotifyObjectEmitted(const object::ObjectFile &Obj, const RuntimeDyld::LoadedObjectInfo &L)
NotifyObjectEmitted - Called after an object has been successfully emitted to memory.
struct LLVMOpaqueJITEventListener * LLVMJITEventListenerRef
Definition: Types.h:150
uintptr_t Address
The address at which the current line changes.
static JITEventListener * createOProfileJITEventListener()