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_EXECUTION_ENGINE_JIT_EVENTLISTENER_H
16
#define LLVM_EXECUTION_ENGINE_JIT_EVENTLISTENER_H
18
#include "llvm/System/DataTypes.h"
19
#include "llvm/Support/DebugLoc.h"
25
class MachineFunction;
27
/// Empty for now, but this object will contain all details about the
28
/// generated machine code that a Listener might care about.
29
struct JITEvent_EmittedFunctionDetails {
30
const MachineFunction *MF;
33
// The address at which the current line changes.
35
// The new location information. These can be translated to
36
// DebugLocTuples using MF->getDebugLocTuple().
39
// This holds line boundary information sorted by address.
40
std::vector<LineStart> LineStarts;
43
/// JITEventListener - This interface is used by the JIT to notify clients about
44
/// significant events during compilation. For example, we could have
45
/// implementations for profilers and debuggers that need to know where
46
/// functions have been emitted.
48
/// Each method defaults to doing nothing, so you only need to override the ones
50
class JITEventListener {
53
virtual ~JITEventListener(); // Defined in JIT.cpp.
55
typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails;
56
/// NotifyFunctionEmitted - Called after a function has been successfully
57
/// emitted to memory. The function still has its MachineFunction attached,
58
/// if you should happen to need that.
59
virtual void NotifyFunctionEmitted(const Function &F,
60
void *Code, size_t Size,
61
const EmittedFunctionDetails &Details) {}
63
/// NotifyFreeingMachineCode - This is called inside of
64
/// freeMachineCodeForFunction(), after the global mapping is removed, but
65
/// before the machine code is returned to the allocator. OldPtr is the
66
/// address of the machine code and will be the same as the Code parameter to
67
/// a previous NotifyFunctionEmitted call. The Function passed to
68
/// NotifyFunctionEmitted may have been destroyed by the time of the matching
69
/// NotifyFreeingMachineCode call.
70
virtual void NotifyFreeingMachineCode(void *OldPtr) {}
73
// This returns NULL if support isn't available.
74
JITEventListener *createOProfileJITEventListener();
76
} // end namespace llvm.