LLVM  13.0.0git
JITEventListener.h
Go to the documentation of this file.
1 //===- JITEventListener.h - Exposes events from JIT compilation -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the JITEventListener interface, which lets users get
10 // callbacks when significant events happen during the JIT compilation process.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
15 #define LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
16 
17 #include "llvm-c/ExecutionEngine.h"
18 #include "llvm/Config/llvm-config.h"
20 #include "llvm/IR/DebugLoc.h"
22 #include <cstdint>
23 
24 namespace llvm {
25 
26 class IntelJITEventsWrapper;
27 class MachineFunction;
28 class OProfileWrapper;
29 
30 namespace object {
31 
32 class ObjectFile;
33 
34 } // end namespace object
35 
36 /// JITEventListener - Abstract interface for use by the JIT to notify clients
37 /// about significant events during compilation. For example, to notify
38 /// profilers and debuggers that need to know where functions have been emitted.
39 ///
40 /// The default implementation of each method does nothing.
42 public:
43  using ObjectKey = uint64_t;
44 
45  JITEventListener() = default;
46  virtual ~JITEventListener() = default;
47 
48  /// notifyObjectLoaded - Called after an object has had its sections allocated
49  /// and addresses assigned to all symbols. Note: Section memory will not have
50  /// been relocated yet. notifyFunctionLoaded will not be called for
51  /// individual functions in the object.
52  ///
53  /// ELF-specific information
54  /// The ObjectImage contains the generated object image
55  /// with section headers updated to reflect the address at which sections
56  /// were loaded and with relocations performed in-place on debug sections.
57  virtual void notifyObjectLoaded(ObjectKey K, const object::ObjectFile &Obj,
59 
60  /// notifyFreeingObject - Called just before the memory associated with
61  /// a previously emitted object is released.
62  virtual void notifyFreeingObject(ObjectKey K) {}
63 
64  // Get a pointe to the GDB debugger registration listener.
66 
67 #if LLVM_USE_INTEL_JITEVENTS
68  // Construct an IntelJITEventListener
70 
71  // Construct an IntelJITEventListener with a test Intel JIT API implementation
73  IntelJITEventsWrapper* AlternativeImpl);
74 #else
75  static JITEventListener *createIntelJITEventListener() { return nullptr; }
76 
78  IntelJITEventsWrapper* AlternativeImpl) {
79  return nullptr;
80  }
81 #endif // USE_INTEL_JITEVENTS
82 
83 #if LLVM_USE_OPROFILE
84  // Construct an OProfileJITEventListener
86 
87  // Construct an OProfileJITEventListener with a test opagent implementation
89  OProfileWrapper* AlternativeImpl);
90 #else
91  static JITEventListener *createOProfileJITEventListener() { return nullptr; }
92 
94  OProfileWrapper* AlternativeImpl) {
95  return nullptr;
96  }
97 #endif // USE_OPROFILE
98 
99 #if LLVM_USE_PERF
101 #else
103  {
104  return nullptr;
105  }
106 #endif // USE_PERF
107 
108 private:
109  virtual void anchor();
110 };
111 
113 
114 } // end namespace llvm
115 
116 #endif // LLVM_EXECUTIONENGINE_JITEVENTLISTENER_H
llvm
Definition: AllocatorList.h:23
llvm::JITEventListener::notifyObjectLoaded
virtual void notifyObjectLoaded(ObjectKey K, const object::ObjectFile &Obj, const RuntimeDyld::LoadedObjectInfo &L)
notifyObjectLoaded - Called after an object has had its sections allocated and addresses assigned to ...
Definition: JITEventListener.h:57
CBindingWrapping.h
RuntimeDyld.h
llvm::JITEventListener::createOProfileJITEventListener
static JITEventListener * createOProfileJITEventListener(OProfileWrapper *AlternativeImpl)
Definition: JITEventListener.h:93
DEFINE_SIMPLE_CONVERSION_FUNCTIONS
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref)
Definition: CBindingWrapping.h:19
llvm::JITEventListener::createIntelJITEventListener
static JITEventListener * createIntelJITEventListener(IntelJITEventsWrapper *AlternativeImpl)
Definition: JITEventListener.h:77
DebugLoc.h
object
bar al al movzbl eax ret Missed when stored in a memory object
Definition: README.txt:1411
llvm::codeview::CodeViewContainer::ObjectFile
@ ObjectFile
llvm::JITEventListener
JITEventListener - Abstract interface for use by the JIT to notify clients about significant events d...
Definition: JITEventListener.h:41
llvm::object::ObjectFile
This class is the base class for all object file types.
Definition: ObjectFile.h:225
llvm::OProfileWrapper
Definition: OProfileWrapper.h:28
llvm::JITEventListener::createOProfileJITEventListener
static JITEventListener * createOProfileJITEventListener()
Definition: JITEventListener.h:91
llvm::RuntimeDyld::LoadedObjectInfo
Information about the loaded object.
Definition: RuntimeDyld.h:70
llvm::JITEventListener::createIntelJITEventListener
static JITEventListener * createIntelJITEventListener()
Definition: JITEventListener.h:75
llvm::JITEventListener::createPerfJITEventListener
static JITEventListener * createPerfJITEventListener()
Definition: JITEventListener.h:102
ExecutionEngine.h
llvm::JITEventListener::~JITEventListener
virtual ~JITEventListener()=default
llvm::JITEventListener::notifyFreeingObject
virtual void notifyFreeingObject(ObjectKey K)
notifyFreeingObject - Called just before the memory associated with a previously emitted object is re...
Definition: JITEventListener.h:62
llvm::JITEventListener::ObjectKey
uint64_t ObjectKey
Definition: JITEventListener.h:43
llvm::JITEventListener::JITEventListener
JITEventListener()=default
llvm::JITEventListener::createGDBRegistrationListener
static JITEventListener * createGDBRegistrationListener()
Definition: GDBRegistrationListener.cpp:236
LLVMJITEventListenerRef
struct LLVMOpaqueJITEventListener * LLVMJITEventListenerRef
Definition: Types.h:163
llvm::IntelJITEventsWrapper
Definition: IntelJITEventsWrapper.h:31