16#if LLVM_USE_INTEL_JITEVENTS
24class JITEventWrapper {
26 static std::unique_ptr<IntelJITEventsWrapper>
Wrapper;
28std::unique_ptr<IntelJITEventsWrapper> JITEventWrapper::Wrapper;
32 const size_t StringsSize = MB.
Strings.size();
34 for (
const auto &MethodInfo : MB.
Methods) {
38 MethodMessage.
method_id = MethodInfo.MethodID;
39 if (MethodInfo.NameSI != 0 && MethodInfo.NameSI < StringsSize) {
41 const_cast<char *
>(MB.
Strings.at(MethodInfo.NameSI).data());
45 if (MethodInfo.ClassFileSI != 0 && MethodInfo.ClassFileSI < StringsSize) {
47 const_cast<char *
>(MB.
Strings.at(MethodInfo.ClassFileSI).data());
51 if (MethodInfo.SourceFileSI != 0 && MethodInfo.SourceFileSI < StringsSize) {
53 const_cast<char *
>(MB.
Strings.at(MethodInfo.SourceFileSI).data());
66 std::vector<LineNumberInfo> LineInfo;
67 for (
const auto &LInfo : MethodInfo.LineTable) {
71 if (LineInfo.size() == 0) {
78 JITEventWrapper::Wrapper->iJIT_NotifyEvent(
85static void registerJITLoaderVTuneUnregisterImpl(
86 const std::vector<std::pair<uint64_t, uint64_t>> &UM) {
87 for (
auto &Method : UM) {
88 JITEventWrapper::Wrapper->iJIT_NotifyEvent(
90 const_cast<uint64_t *
>(&Method.first));
96 using namespace orc::shared;
97 if (!JITEventWrapper::Wrapper)
100 return WrapperFunction<SPSError(SPSVTuneMethodBatch)>::handle(
101 Data,
Size, registerJITLoaderVTuneRegisterImpl)
107 using namespace orc::shared;
108 return WrapperFunction<void(SPSVTuneUnloadedMethodIDs)>::handle(
109 Data,
Size, registerJITLoaderVTuneUnregisterImpl)
115using SourceLocations = std::vector<std::pair<std::string, unsigned int>>;
116using NativeCodeMap = std::map<uint64_t, SourceLocations>;
117NativeCodeMap ReportedDebugFuncs;
120static int NotifyEvent(
iJIT_JVM_EVENT EventType,
void *EventSpecificData) {
123 if (!EventSpecificData) {
124 errs() <<
"Error: The JIT event listener did not provide a event data.";
136 errs() <<
"A function with a non-zero line count had no line table.";
139 std::pair<std::string, unsigned int> loc(
142 ReportedDebugFuncs[msg->
method_id].push_back(loc);
150 if (!EventSpecificData) {
151 errs() <<
"Error: The JIT event listener did not provide a event data.";
154 unsigned int UnloadId =
155 *
reinterpret_cast<unsigned int *
>(EventSpecificData);
156 assert(1 == ReportedDebugFuncs.erase(UnloadId));
157 outs() <<
"Method unload [" << UnloadId <<
"]\n";
171static unsigned int GetNewMethodID(
void) {
172 static unsigned int id = 0;
178 using namespace orc::shared;
180 NotifyEvent, NULL, NULL, IsProfilingActive, 0, 0, GetNewMethodID));
181 return WrapperFunction<SPSError(SPSVTuneMethodBatch)>::handle(
182 Data,
Size, registerJITLoaderVTuneRegisterImpl)
192 return llvm::make_error<StringError>(
"unsupported for Intel VTune",
196static void unsuppported(
const std::vector<std::pair<uint64_t, uint64_t>> &UM) {
202 using namespace orc::shared;
203 return WrapperFunction<SPSError(SPSVTuneMethodBatch)>::handle(
210 using namespace orc::shared;
211 return WrapperFunction<void(SPSVTuneUnloadedMethodIDs)>::handle(Data,
Size,
218 using namespace orc::shared;
219 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