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 "llvm/Config/llvm-config.h"
19 #include "llvm/IR/DebugLoc.h"
20 #include "llvm/Support/DataTypes.h"
25 class MachineFunction;
26 class OProfileWrapper;
27 class IntelJITEventsWrapper;
30 /// JITEvent_EmittedFunctionDetails - Helper struct for containing information
31 /// about a generated machine code function.
32 struct JITEvent_EmittedFunctionDetails {
34 /// The address at which the current line changes.
37 /// The new location information. These can be translated to DebugLocTuples
38 /// using MF->getDebugLocTuple().
42 /// The machine function the struct contains information for.
43 const MachineFunction *MF;
45 /// The list of line boundary information, sorted by address.
46 std::vector<LineStart> LineStarts;
49 /// JITEventListener - Abstract interface for use by the JIT to notify clients
50 /// about significant events during compilation. For example, to notify
51 /// profilers and debuggers that need to know where functions have been emitted.
53 /// The default implementation of each method does nothing.
54 class JITEventListener {
56 typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails;
60 virtual ~JITEventListener();
62 /// NotifyObjectEmitted - Called after an object has been successfully
63 /// emitted to memory. NotifyFunctionEmitted will not be called for
64 /// individual functions in the object.
66 /// ELF-specific information
67 /// The ObjectImage contains the generated object image
68 /// with section headers updated to reflect the address at which sections
69 /// were loaded and with relocations performed in-place on debug sections.
70 virtual void NotifyObjectEmitted(const ObjectImage &Obj) {}
72 /// NotifyFreeingObject - Called just before the memory associated with
73 /// a previously emitted object is released.
74 virtual void NotifyFreeingObject(const ObjectImage &Obj) {}
76 #if LLVM_USE_INTEL_JITEVENTS
77 // Construct an IntelJITEventListener
78 static JITEventListener *createIntelJITEventListener();
80 // Construct an IntelJITEventListener with a test Intel JIT API implementation
81 static JITEventListener *createIntelJITEventListener(
82 IntelJITEventsWrapper* AlternativeImpl);
84 static JITEventListener *createIntelJITEventListener() { return nullptr; }
86 static JITEventListener *createIntelJITEventListener(
87 IntelJITEventsWrapper* AlternativeImpl) {
90 #endif // USE_INTEL_JITEVENTS
93 // Construct an OProfileJITEventListener
94 static JITEventListener *createOProfileJITEventListener();
96 // Construct an OProfileJITEventListener with a test opagent implementation
97 static JITEventListener *createOProfileJITEventListener(
98 OProfileWrapper* AlternativeImpl);
101 static JITEventListener *createOProfileJITEventListener() { return nullptr; }
103 static JITEventListener *createOProfileJITEventListener(
104 OProfileWrapper* AlternativeImpl) {
107 #endif // USE_OPROFILE
111 } // end namespace llvm.
113 #endif // defined LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H