15#if LLVM_USE_INTEL_JITEVENTS
23class JITEventWrapper {
25 static std::unique_ptr<IntelJITEventsWrapper>
Wrapper;
27std::unique_ptr<IntelJITEventsWrapper> JITEventWrapper::Wrapper;
31 const size_t StringsSize = MB.
Strings.size();
33 for (
const auto &MethodInfo : MB.
Methods) {
37 MethodMessage.
method_id = MethodInfo.MethodID;
38 if (MethodInfo.NameSI != 0 && MethodInfo.NameSI < StringsSize) {
40 const_cast<char *
>(MB.
Strings.at(MethodInfo.NameSI).data());
44 if (MethodInfo.ClassFileSI != 0 && MethodInfo.ClassFileSI < StringsSize) {
46 const_cast<char *
>(MB.
Strings.at(MethodInfo.ClassFileSI).data());
50 if (MethodInfo.SourceFileSI != 0 && MethodInfo.SourceFileSI < StringsSize) {
52 const_cast<char *
>(MB.
Strings.at(MethodInfo.SourceFileSI).data());
65 std::vector<LineNumberInfo> LineInfo;
66 for (
const auto &LInfo : MethodInfo.LineTable) {
70 if (LineInfo.size() == 0) {
77 JITEventWrapper::Wrapper->iJIT_NotifyEvent(
84static void registerJITLoaderVTuneUnregisterImpl(
85 const std::vector<std::pair<uint64_t, uint64_t>> &UM) {
86 for (
auto &Method : UM) {
87 JITEventWrapper::Wrapper->iJIT_NotifyEvent(
89 const_cast<uint64_t *
>(&Method.first));
95 using namespace orc::shared;
96 if (!JITEventWrapper::Wrapper)
99 return WrapperFunction<SPSError(SPSVTuneMethodBatch)>::handle(
100 Data,
Size, registerJITLoaderVTuneRegisterImpl)
106 using namespace orc::shared;
107 return WrapperFunction<void(SPSVTuneUnloadedMethodIDs)>::handle(
108 Data,
Size, registerJITLoaderVTuneUnregisterImpl)
114using SourceLocations = std::vector<std::pair<std::string, unsigned int>>;
115using NativeCodeMap = std::map<uint64_t, SourceLocations>;
116NativeCodeMap ReportedDebugFuncs;
119static int NotifyEvent(
iJIT_JVM_EVENT EventType,
void *EventSpecificData) {
122 if (!EventSpecificData) {
123 errs() <<
"Error: The JIT event listener did not provide a event data.";
135 errs() <<
"A function with a non-zero line count had no line table.";
138 std::pair<std::string, unsigned int> loc(
141 ReportedDebugFuncs[msg->
method_id].push_back(loc);
149 if (!EventSpecificData) {
150 errs() <<
"Error: The JIT event listener did not provide a event data.";
153 unsigned int UnloadId =
154 *
reinterpret_cast<unsigned int *
>(EventSpecificData);
155 assert(1 == ReportedDebugFuncs.erase(UnloadId));
156 outs() <<
"Method unload [" << UnloadId <<
"]\n";
170static unsigned int GetNewMethodID(
void) {
171 static unsigned int id = 0;
177 using namespace orc::shared;
179 NotifyEvent, NULL, NULL, IsProfilingActive, 0, 0, GetNewMethodID));
180 return WrapperFunction<SPSError(SPSVTuneMethodBatch)>::handle(
181 Data,
Size, registerJITLoaderVTuneRegisterImpl)
191 return llvm::make_error<StringError>(
"unsupported for Intel VTune",
195static void unsuppported(
const std::vector<std::pair<uint64_t, uint64_t>> &UM) {
201 using namespace orc::shared;
202 return WrapperFunction<SPSError(SPSVTuneMethodBatch)>::handle(
209 using namespace orc::shared;
210 return WrapperFunction<void(SPSVTuneUnloadedMethodIDs)>::handle(Data,
Size,
217 using namespace orc::shared;
218 return WrapperFunction<SPSError(SPSVTuneMethodBatch)>::handle(
amdgpu aa AMDGPU Address space based Alias Analysis Wrapper
static Error unsupportedBatch(const VTuneMethodBatch &MB)
llvm::orc::shared::CWrapperFunctionResult llvm_orc_registerVTuneImpl(const char *Data, uint64_t Size)
llvm::orc::shared::CWrapperFunctionResult llvm_orc_unregisterVTuneImpl(const char *Data, uint64_t Size)
llvm::orc::shared::CWrapperFunctionResult llvm_orc_test_registerVTuneImpl(const char *Data, uint64_t Size)
static void unsuppported(const std::vector< std::pair< uint64_t, uint64_t > > &UM)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
@ iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED
@ iJVM_EVENT_TYPE_METHOD_UNLOAD_START
enum iJIT_jvm_event iJIT_JVM_EVENT
enum _iJIT_IsProfilingActiveFlags iJIT_IsProfilingActiveFlags
std::vector< SourceLocation > SourceLocations
This is an optimization pass for GlobalISel generic memory operations.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
unsigned int line_number_size
pLineNumberInfo line_number_table
unsigned int user_data_size
void * method_load_address