LLVM  4.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 "RuntimeDyld.h"
19 #include "llvm/Config/llvm-config.h"
20 #include "llvm/IR/DebugLoc.h"
21 #include <cstdint>
22 #include <vector>
23 
24 namespace llvm {
25 
26 class IntelJITEventsWrapper;
27 class MachineFunction;
28 class OProfileWrapper;
29 
30 namespace object {
31  class ObjectFile;
32 } // end namespace object
33 
34 /// JITEvent_EmittedFunctionDetails - Helper struct for containing information
35 /// about a generated machine code function.
37  struct LineStart {
38  /// The address at which the current line changes.
39  uintptr_t Address;
40 
41  /// The new location information. These can be translated to DebugLocTuples
42  /// using MF->getDebugLocTuple().
44  };
45 
46  /// The machine function the struct contains information for.
48 
49  /// The list of line boundary information, sorted by address.
50  std::vector<LineStart> LineStarts;
51 };
52 
53 /// JITEventListener - Abstract interface for use by the JIT to notify clients
54 /// about significant events during compilation. For example, to notify
55 /// profilers and debuggers that need to know where functions have been emitted.
56 ///
57 /// The default implementation of each method does nothing.
59 public:
61 
62 public:
63  JITEventListener() = default;
64  virtual ~JITEventListener() = default;
65 
66  /// NotifyObjectEmitted - Called after an object has been successfully
67  /// emitted to memory. NotifyFunctionEmitted will not be called for
68  /// individual functions in the object.
69  ///
70  /// ELF-specific information
71  /// The ObjectImage contains the generated object image
72  /// with section headers updated to reflect the address at which sections
73  /// were loaded and with relocations performed in-place on debug sections.
74  virtual void NotifyObjectEmitted(const object::ObjectFile &Obj,
76 
77  /// NotifyFreeingObject - Called just before the memory associated with
78  /// a previously emitted object is released.
79  virtual void NotifyFreeingObject(const object::ObjectFile &Obj) {}
80 
81  // Get a pointe to the GDB debugger registration listener.
83 
84 #if LLVM_USE_INTEL_JITEVENTS
85  // Construct an IntelJITEventListener
87 
88  // Construct an IntelJITEventListener with a test Intel JIT API implementation
90  IntelJITEventsWrapper* AlternativeImpl);
91 #else
92  static JITEventListener *createIntelJITEventListener() { return nullptr; }
93 
95  IntelJITEventsWrapper* AlternativeImpl) {
96  return nullptr;
97  }
98 #endif // USE_INTEL_JITEVENTS
99 
100 #if LLVM_USE_OPROFILE
101  // Construct an OProfileJITEventListener
103 
104  // Construct an OProfileJITEventListener with a test opagent implementation
106  OProfileWrapper* AlternativeImpl);
107 #else
108  static JITEventListener *createOProfileJITEventListener() { return nullptr; }
109 
111  OProfileWrapper* AlternativeImpl) {
112  return nullptr;
113  }
114 #endif // USE_OPROFILE
115 
116 private:
117  virtual void anchor();
118 };
119 
120 } // end namespace llvm
121 
122 #endif // LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
MachineLoop * L
static JITEventListener * createIntelJITEventListener()
Information about the loaded object.
Definition: RuntimeDyld.h:67
JITEvent_EmittedFunctionDetails - Helper struct for containing information about a generated machine ...
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...
static JITEventListener * createGDBRegistrationListener()
This class is the base class for all object file types.
Definition: ObjectFile.h:178
A debug info location.
Definition: DebugLoc.h:34
virtual ~JITEventListener()=default
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 * createOProfileJITEventListener(OProfileWrapper *AlternativeImpl)
JITEvent_EmittedFunctionDetails EmittedFunctionDetails
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.
uintptr_t Address
The address at which the current line changes.
static JITEventListener * createOProfileJITEventListener()