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 | |
23 | namespace llvm { |
24 | |
25 | namespace orc { |
26 | |
27 | class VTuneSupportPlugin : public ObjectLinkingLayer::Plugin { |
28 | public: |
29 | VTuneSupportPlugin(ExecutorProcessControl &EPC, ExecutorAddr RegisterImplAddr, |
30 | ExecutorAddr UnregisterImplAddr, bool EmitDebugInfo) |
31 | : EPC(EPC), RegisterVTuneImplAddr(RegisterImplAddr), |
32 | UnregisterVTuneImplAddr(UnregisterImplAddr), |
33 | EmitDebugInfo(EmitDebugInfo) {} |
34 | |
35 | void modifyPassConfig(MaterializationResponsibility &MR, |
36 | jitlink::LinkGraph &G, |
37 | jitlink::PassConfiguration &Config) override; |
38 | |
39 | Error notifyEmitted(MaterializationResponsibility &MR) override; |
40 | Error notifyFailed(MaterializationResponsibility &MR) override; |
41 | Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override; |
42 | void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey, |
43 | ResourceKey SrcKey) override; |
44 | |
45 | static Expected<std::unique_ptr<VTuneSupportPlugin>> |
46 | Create(ExecutorProcessControl &EPC, JITDylib &JD, bool EmitDebugInfo, |
47 | bool TestMode = false); |
48 | |
49 | private: |
50 | ExecutorProcessControl &EPC; |
51 | ExecutorAddr RegisterVTuneImplAddr; |
52 | ExecutorAddr UnregisterVTuneImplAddr; |
53 | std::mutex PluginMutex; |
54 | uint64_t NextMethodID = 0; |
55 | DenseMap<MaterializationResponsibility *, std::pair<uint64_t, uint64_t>> |
56 | PendingMethodIDs; |
57 | DenseMap<ResourceKey, SmallVector<std::pair<uint64_t, uint64_t>>> |
58 | LoadedMethodIDs; |
59 | bool EmitDebugInfo; |
60 | }; |
61 | |
62 | } // end namespace orc |
63 | |
64 | } // end namespace llvm |
65 | |
66 | #endif |
67 | |