1 //===- JITEventListener.h - Exposes events from JIT compilation -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the JITEventListener interface, which lets users get
11 // callbacks when significant events happen during the JIT compilation process.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
16 #define LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
18 #include "RuntimeDyld.h"
19 #include "llvm/Config/llvm-config.h"
20 #include "llvm/IR/DebugLoc.h"
21 #include "llvm/Support/DataTypes.h"
26 class MachineFunction;
27 class OProfileWrapper;
28 class IntelJITEventsWrapper;
34 /// JITEvent_EmittedFunctionDetails - Helper struct for containing information
35 /// about a generated machine code function.
36 struct JITEvent_EmittedFunctionDetails {
38 /// The address at which the current line changes.
41 /// The new location information. These can be translated to DebugLocTuples
42 /// using MF->getDebugLocTuple().
46 /// The machine function the struct contains information for.
47 const MachineFunction *MF;
49 /// The list of line boundary information, sorted by address.
50 std::vector<LineStart> LineStarts;
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.
57 /// The default implementation of each method does nothing.
58 class JITEventListener {
60 typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails;
64 virtual ~JITEventListener() {}
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.
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,
75 const RuntimeDyld::LoadedObjectInfo &L) {}
77 /// NotifyFreeingObject - Called just before the memory associated with
78 /// a previously emitted object is released.
79 virtual void NotifyFreeingObject(const object::ObjectFile &Obj) {}
81 // Get a pointe to the GDB debugger registration listener.
82 static JITEventListener *createGDBRegistrationListener();
84 #if LLVM_USE_INTEL_JITEVENTS
85 // Construct an IntelJITEventListener
86 static JITEventListener *createIntelJITEventListener();
88 // Construct an IntelJITEventListener with a test Intel JIT API implementation
89 static JITEventListener *createIntelJITEventListener(
90 IntelJITEventsWrapper* AlternativeImpl);
92 static JITEventListener *createIntelJITEventListener() { return nullptr; }
94 static JITEventListener *createIntelJITEventListener(
95 IntelJITEventsWrapper* AlternativeImpl) {
98 #endif // USE_INTEL_JITEVENTS
100 #if LLVM_USE_OPROFILE
101 // Construct an OProfileJITEventListener
102 static JITEventListener *createOProfileJITEventListener();
104 // Construct an OProfileJITEventListener with a test opagent implementation
105 static JITEventListener *createOProfileJITEventListener(
106 OProfileWrapper* AlternativeImpl);
109 static JITEventListener *createOProfileJITEventListener() { return nullptr; }
111 static JITEventListener *createOProfileJITEventListener(
112 OProfileWrapper* AlternativeImpl) {
115 #endif // USE_OPROFILE
117 virtual void anchor();
120 } // end namespace llvm.
122 #endif // defined LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H