From 76e1521b0acff739c0425d0fcbb9360fc17f1af8 Mon Sep 17 00:00:00 2001 From: Prem Chintalapudi Date: Tue, 18 Apr 2023 17:15:32 -0400 Subject: Non-debuginfo JITLink perf jitdump support This patch ports PerfJITEventListener to a JITLink plugin, but adds unwind record support and drops debuginfo support temporarily. Debuginfo can be enabled in the future by providing a way to obtain a DWARFContext from a LinkGraph. See D146060 for an experimental implementation that adds debuginfo parsing. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D146169 --- llvm/tools/llvm-jitlink/llvm-jitlink.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'llvm/tools/llvm-jitlink') diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp index 332e3e7..a6789a6 100644 --- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp @@ -28,8 +28,10 @@ #include "llvm/ExecutionEngine/Orc/MachOPlatform.h" #include "llvm/ExecutionEngine/Orc/MapperJITLinkMemoryManager.h" #include "llvm/ExecutionEngine/Orc/ObjectFileInterface.h" +#include "llvm/ExecutionEngine/Orc/PerfSupportPlugin.h" #include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h" +#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" @@ -140,6 +142,11 @@ static cl::opt cl::desc("Enable debugger suppport (default = !-noexec)"), cl::init(true), cl::Hidden, cl::cat(JITLinkCategory)); +static cl::opt PerfSupport("perf-support", + cl::desc("Enable perf profiling support"), + cl::init(false), cl::Hidden, + cl::cat(JITLinkCategory)); + static cl::opt NoProcessSymbols("no-process-syms", cl::desc("Do not resolve to llvm-jitlink process symbols"), @@ -248,10 +255,14 @@ static cl::opt UseSharedMemory( static ExitOnError ExitOnErr; static LLVM_ATTRIBUTE_USED void linkComponents() { - errs() << (void *)&llvm_orc_registerEHFrameSectionWrapper - << (void *)&llvm_orc_deregisterEHFrameSectionWrapper - << (void *)&llvm_orc_registerJITLoaderGDBWrapper - << (void *)&llvm_orc_registerJITLoaderGDBAllocAction; + errs() << "Linking in runtime functions\n" + << (void *)&llvm_orc_registerEHFrameSectionWrapper << '\n' + << (void *)&llvm_orc_deregisterEHFrameSectionWrapper << '\n' + << (void *)&llvm_orc_registerJITLoaderGDBWrapper << '\n' + << (void *)&llvm_orc_registerJITLoaderGDBAllocAction << '\n' + << (void *)&llvm_orc_registerJITLoaderPerfStart << '\n' + << (void *)&llvm_orc_registerJITLoaderPerfEnd << '\n' + << (void *)&llvm_orc_registerJITLoaderPerfImpl << '\n'; } static bool UseTestResultOverride = false; @@ -989,6 +1000,10 @@ Session::Session(std::unique_ptr EPC, Error &Err) ObjLayer.addPlugin(ExitOnErr( GDBJITDebugInfoRegistrationPlugin::Create(this->ES, *MainJD, TT))); + if (PerfSupport && TT.isOSBinFormatELF()) + ObjLayer.addPlugin(ExitOnErr(PerfSupportPlugin::Create( + this->ES.getExecutorProcessControl(), *MainJD, true))); + // Set up the platform. if (TT.isOSBinFormatMachO() && !OrcRuntime.empty()) { if (auto P = -- cgit v1.1