1 //===--- VTuneSupportPlugin.h -- Support for VTune profiler ---*- 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 // Handles support for registering code with VIntel Tune's Amplifier JIT API. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_EXECUTIONENGINE_ORC_DEBUGGING_VTUNESUPPORT_H 14 #define LLVM_EXECUTIONENGINE_ORC_DEBUGGING_VTUNESUPPORT_H 15 16 #include "llvm/ADT/DenseMap.h" 17 #include "llvm/ADT/SmallVector.h" 18 #include "llvm/ExecutionEngine/Orc/Core.h" 19 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h" 20 #include "llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h" 21 #include "llvm/ExecutionEngine/Orc/Shared/VTuneSharedStructs.h" 22 #include "llvm/Support/Compiler.h" 23 24 namespace llvm { 25 26 namespace orc { 27 28 class LLVM_ABI VTuneSupportPlugin : public ObjectLinkingLayer::Plugin { 29 public: VTuneSupportPlugin(ExecutorProcessControl & EPC,ExecutorAddr RegisterImplAddr,ExecutorAddr UnregisterImplAddr,bool EmitDebugInfo)30 VTuneSupportPlugin(ExecutorProcessControl &EPC, ExecutorAddr RegisterImplAddr, 31 ExecutorAddr UnregisterImplAddr, bool EmitDebugInfo) 32 : EPC(EPC), RegisterVTuneImplAddr(RegisterImplAddr), 33 UnregisterVTuneImplAddr(UnregisterImplAddr), 34 EmitDebugInfo(EmitDebugInfo) {} 35 36 void modifyPassConfig(MaterializationResponsibility &MR, 37 jitlink::LinkGraph &G, 38 jitlink::PassConfiguration &Config) override; 39 40 Error notifyEmitted(MaterializationResponsibility &MR) override; 41 Error notifyFailed(MaterializationResponsibility &MR) override; 42 Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override; 43 void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey, 44 ResourceKey SrcKey) override; 45 46 static Expected<std::unique_ptr<VTuneSupportPlugin>> 47 Create(ExecutorProcessControl &EPC, JITDylib &JD, bool EmitDebugInfo, 48 bool TestMode = false); 49 50 private: 51 ExecutorProcessControl &EPC; 52 ExecutorAddr RegisterVTuneImplAddr; 53 ExecutorAddr UnregisterVTuneImplAddr; 54 std::mutex PluginMutex; 55 uint64_t NextMethodID = 0; 56 DenseMap<MaterializationResponsibility *, std::pair<uint64_t, uint64_t>> 57 PendingMethodIDs; 58 DenseMap<ResourceKey, SmallVector<std::pair<uint64_t, uint64_t>>> 59 LoadedMethodIDs; 60 bool EmitDebugInfo; 61 }; 62 63 } // end namespace orc 64 65 } // end namespace llvm 66 67 #endif 68