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/Support/DataTypes.h"
23 /// Empty for now, but this object will contain all details about the
24 /// generated machine code that a Listener might care about.
25 struct JITEvent_EmittedFunctionDetails {
28 /// JITEventListener - This interface is used by the JIT to notify clients about
29 /// significant events during compilation. For example, we could have
30 /// implementations for profilers and debuggers that need to know where
31 /// functions have been emitted.
33 /// Each method defaults to doing nothing, so you only need to override the ones
35 class JITEventListener {
38 virtual ~JITEventListener(); // Defined in JIT.cpp.
40 typedef JITEvent_EmittedFunctionDetails EmittedFunctionDetails;
41 /// NotifyFunctionEmitted - Called after a function has been successfully
42 /// emitted to memory. The function still has its MachineFunction attached,
43 /// if you should happen to need that.
44 virtual void NotifyFunctionEmitted(const Function &F,
45 void *Code, size_t Size,
46 const EmittedFunctionDetails &Details) {}
48 /// NotifyFreeingMachineCode - This is called inside of
49 /// freeMachineCodeForFunction(), after the global mapping is removed, but
50 /// before the machine code is returned to the allocator. OldPtr is the
51 /// address of the machine code.
52 virtual void NotifyFreeingMachineCode(const Function &F, void *OldPtr) {}
55 // These return NULL if support isn't available.
56 JITEventListener *createMacOSJITEventListener();
57 JITEventListener *createOProfileJITEventListener();
59 } // end namespace llvm.