Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:51

0001 //===--- VTuneSupportPlugin.h -- Support for VTune profiler ---*- C++ -*---===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // Handles support for registering code with VIntel Tune's Amplifier JIT API.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_EXECUTIONENGINE_ORC_DEBUGGING_VTUNESUPPORT_H
0014 #define LLVM_EXECUTIONENGINE_ORC_DEBUGGING_VTUNESUPPORT_H
0015 
0016 #include "llvm/ADT/DenseMap.h"
0017 #include "llvm/ADT/SmallVector.h"
0018 #include "llvm/ExecutionEngine/Orc/Core.h"
0019 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
0020 #include "llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h"
0021 #include "llvm/ExecutionEngine/Orc/Shared/VTuneSharedStructs.h"
0022 
0023 namespace llvm {
0024 
0025 namespace orc {
0026 
0027 class VTuneSupportPlugin : public ObjectLinkingLayer::Plugin {
0028 public:
0029   VTuneSupportPlugin(ExecutorProcessControl &EPC, ExecutorAddr RegisterImplAddr,
0030                      ExecutorAddr UnregisterImplAddr, bool EmitDebugInfo)
0031       : EPC(EPC), RegisterVTuneImplAddr(RegisterImplAddr),
0032         UnregisterVTuneImplAddr(UnregisterImplAddr),
0033         EmitDebugInfo(EmitDebugInfo) {}
0034 
0035   void modifyPassConfig(MaterializationResponsibility &MR,
0036                         jitlink::LinkGraph &G,
0037                         jitlink::PassConfiguration &Config) override;
0038 
0039   Error notifyEmitted(MaterializationResponsibility &MR) override;
0040   Error notifyFailed(MaterializationResponsibility &MR) override;
0041   Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override;
0042   void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey,
0043                                    ResourceKey SrcKey) override;
0044 
0045   static Expected<std::unique_ptr<VTuneSupportPlugin>>
0046   Create(ExecutorProcessControl &EPC, JITDylib &JD, bool EmitDebugInfo,
0047          bool TestMode = false);
0048 
0049 private:
0050   ExecutorProcessControl &EPC;
0051   ExecutorAddr RegisterVTuneImplAddr;
0052   ExecutorAddr UnregisterVTuneImplAddr;
0053   std::mutex PluginMutex;
0054   uint64_t NextMethodID = 0;
0055   DenseMap<MaterializationResponsibility *, std::pair<uint64_t, uint64_t>>
0056       PendingMethodIDs;
0057   DenseMap<ResourceKey, SmallVector<std::pair<uint64_t, uint64_t>>>
0058       LoadedMethodIDs;
0059   bool EmitDebugInfo;
0060 };
0061 
0062 } // end namespace orc
0063 
0064 } // end namespace llvm
0065 
0066 #endif