This is an archive of the discontinued LLVM Phabricator instance.

Basic VTune support for JITLink
Needs ReviewPublic

Authored by pchintalapudi on Mar 20 2023, 2:59 AM.

Details

Reviewers
lhames
Summary

This patch introduces VTuneSupportPlugin as a JITLink equivalent to IntelJITEventListener to report JIT compiled methods. Integration of debug info and actual registration will be added in following revisions.

Depends on D146391

Diff Detail

Event Timeline

pchintalapudi created this revision.Mar 20 2023, 2:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 20 2023, 2:59 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
pchintalapudi requested review of this revision.Mar 20 2023, 2:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 20 2023, 2:59 AM
lhames added inline comments.Mar 20 2023, 8:38 PM
llvm/include/llvm/ExecutionEngine/Orc/VTuneSupportPlugin.h
13–14

Include guards should match the file name.

llvm/lib/ExecutionEngine/Orc/VTuneSupportPlugin.cpp
86

It looks like you're deregistering in notifyRemovingResources below, but you sould add the deregistration call as a deallocation action here (replacing the no-op (}) if possible. Deallocation actions reduce IPC traffic, and they can be run during executor teardown even if the connection to the JIT has dropped out. It also saves you the hassle of tracking resources in your plugin (it becomes the memory manager's problem).

149–161

You can use the lookupAndRecordAddrs utility in llvm/ExecutionEngine/Orc/LookupAndRecordAddrs.h to simplify this to:

auto &ES = EPC.getExecutionSession();
ExecutorAddr RegisterImplAddr;
ExecutorAddr UnregisterImplAddr;
if (auto Err = lookupAndRecordAddrs(
      ES, LookupKind::Static, makeJITDylibSearchOrder(&PJD),
      {
        {ES.intern(RegisterVTuneImplName), &RegisterImplAddr},
        {ES.intern(UnregisterVTuneImplName), &UnregisterImplAddr},
      }))
  return Err;
return std::make_unique<VTuneSupportPlugin>(
    EPC, RegisterImplAddr, UnregisterImplAddr, EmitDebugInfo);