Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===----- PerfSupportPlugin.h ----- Utils for perf support -----*- 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 perf
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_EXECUTIONENGINE_ORC_PERFSUPPORTPLUGIN_H
0014 #define LLVM_EXECUTIONENGINE_ORC_PERFSUPPORTPLUGIN_H
0015 
0016 #include "llvm/ExecutionEngine/Orc/Shared/PerfSharedStructs.h"
0017 
0018 #include "llvm/ExecutionEngine/Orc/Core.h"
0019 #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
0020 
0021 namespace llvm {
0022 namespace orc {
0023 
0024 /// Log perf jitdump events for each object (see
0025 /// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/Documentation/jitdump-specification.txt).
0026 /// Currently has support for dumping code load records and unwind info records.
0027 class PerfSupportPlugin : public ObjectLinkingLayer::Plugin {
0028 public:
0029   PerfSupportPlugin(ExecutorProcessControl &EPC,
0030                     ExecutorAddr RegisterPerfStartAddr,
0031                     ExecutorAddr RegisterPerfEndAddr,
0032                     ExecutorAddr RegisterPerfImplAddr, bool EmitDebugInfo,
0033                     bool EmitUnwindInfo);
0034   ~PerfSupportPlugin();
0035 
0036   void modifyPassConfig(MaterializationResponsibility &MR,
0037                         jitlink::LinkGraph &G,
0038                         jitlink::PassConfiguration &Config) override;
0039 
0040   Error notifyFailed(MaterializationResponsibility &MR) override {
0041     return Error::success();
0042   }
0043 
0044   Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override {
0045     return Error::success();
0046   }
0047 
0048   void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey,
0049                                    ResourceKey SrcKey) override {}
0050 
0051   static Expected<std::unique_ptr<PerfSupportPlugin>>
0052   Create(ExecutorProcessControl &EPC, JITDylib &JD, bool EmitDebugInfo,
0053          bool EmitUnwindInfo);
0054 
0055 private:
0056   ExecutorProcessControl &EPC;
0057   ExecutorAddr RegisterPerfStartAddr;
0058   ExecutorAddr RegisterPerfEndAddr;
0059   ExecutorAddr RegisterPerfImplAddr;
0060   std::atomic<uint64_t> CodeIndex;
0061   bool EmitDebugInfo;
0062   bool EmitUnwindInfo;
0063 };
0064 
0065 } // namespace orc
0066 } // namespace llvm
0067 
0068 #endif // LLVM_EXECUTIONENGINE_ORC_PERFSUPPORTPLUGIN_H