From 96679128ab9c8e3e39c0b747ebd13ff73db646ac Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 11 Mar 2025 14:58:25 +1100 Subject: [PATCH 1/2] [ORC] Remove EHFrameRegistrar, use allocation actions for eh-frame registration. This simplifies resource management, and should improve performance for most use cases. --- .../ExecutionEngine/JITLink/EHFrameSupport.h | 32 +---- .../Orc/EHFrameRegistrationPlugin.h | 41 +++--- .../ExecutionEngine/Orc/EPCEHFrameRegistrar.h | 58 --------- .../JITLink/EHFrameSupport.cpp | 52 ++------ llvm/lib/ExecutionEngine/Orc/CMakeLists.txt | 1 - .../Orc/EHFrameRegistrationPlugin.cpp | 117 +++++------------- .../Orc/EPCEHFrameRegistrar.cpp | 49 -------- llvm/lib/ExecutionEngine/Orc/LLJIT.cpp | 8 +- llvm/tools/llvm-jitlink/llvm-jitlink.cpp | 7 +- 9 files changed, 71 insertions(+), 294 deletions(-) delete mode 100644 llvm/include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h delete mode 100644 llvm/lib/ExecutionEngine/Orc/EPCEHFrameRegistrar.cpp diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/EHFrameSupport.h b/llvm/include/llvm/ExecutionEngine/JITLink/EHFrameSupport.h index 7fb61b6a021af..6bfa5506017df 100644 --- a/llvm/include/llvm/ExecutionEngine/JITLink/EHFrameSupport.h +++ b/llvm/include/llvm/ExecutionEngine/JITLink/EHFrameSupport.h @@ -83,35 +83,9 @@ class EHFrameCFIBlockInspector { }; }; -/// Supports registration/deregistration of EH-frames in a target process. -class EHFrameRegistrar { -public: - virtual ~EHFrameRegistrar(); - virtual Error registerEHFrames(orc::ExecutorAddrRange EHFrameSection) = 0; - virtual Error deregisterEHFrames(orc::ExecutorAddrRange EHFrameSection) = 0; -}; - -/// Registers / Deregisters EH-frames in the current process. -class InProcessEHFrameRegistrar final : public EHFrameRegistrar { -public: - Error registerEHFrames(orc::ExecutorAddrRange EHFrameSection) override; - - Error deregisterEHFrames(orc::ExecutorAddrRange EHFrameSection) override; -}; - -using StoreFrameRangeFunction = std::function; - -/// Creates a pass that records the address and size of the EH frame section. -/// If no eh-frame section is found then the address and size will both be given -/// as zero. -/// -/// Authors of JITLinkContexts can use this function to register a post-fixup -/// pass that records the range of the eh-frame section. This range can -/// be used after finalization to register and deregister the frame. -LinkGraphPassFunction -createEHFrameRecorderPass(const Triple &TT, - StoreFrameRangeFunction StoreFrameRange); +/// Returns a pointer to the DWARF eh-frame section if the graph contains a +/// non-empty one, otherwise returns null. +Section *getEHFrameSection(LinkGraph &G); } // end namespace jitlink } // end namespace llvm diff --git a/llvm/include/llvm/ExecutionEngine/Orc/EHFrameRegistrationPlugin.h b/llvm/include/llvm/ExecutionEngine/Orc/EHFrameRegistrationPlugin.h index 6cbbc0c94a37f..fb035d890eee5 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/EHFrameRegistrationPlugin.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/EHFrameRegistrationPlugin.h @@ -19,37 +19,38 @@ #include #include -namespace llvm { - -namespace jitlink { -class EHFrameRegistrar; -} // namespace jitlink - -namespace orc { +namespace llvm::orc { +/// Adds AllocationActions to register and deregister eh-frame sections in the +/// absence of native Platform support. class EHFrameRegistrationPlugin : public LinkGraphLinkingLayer::Plugin { public: - EHFrameRegistrationPlugin( - ExecutionSession &ES, - std::unique_ptr Registrar); + static Expected> + Create(ExecutionSession &ES); + + EHFrameRegistrationPlugin(ExecutionSession &ES, ExecutorAddr RegisterEHFrame, + ExecutorAddr DeregisterEHFrame) + : ES(ES), RegisterEHFrame(RegisterEHFrame), + DeregisterEHFrame(DeregisterEHFrame) {} + void modifyPassConfig(MaterializationResponsibility &MR, jitlink::LinkGraph &G, jitlink::PassConfiguration &PassConfig) override; - Error notifyEmitted(MaterializationResponsibility &MR) override; - Error notifyFailed(MaterializationResponsibility &MR) override; - Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override; + Error notifyFailed(MaterializationResponsibility &MR) override { + return Error::success(); + } + Error notifyRemovingResources(JITDylib &JD, ResourceKey K) override { + return Error::success(); + } void notifyTransferringResources(JITDylib &JD, ResourceKey DstKey, - ResourceKey SrcKey) override; + ResourceKey SrcKey) override {} private: - std::mutex EHFramePluginMutex; ExecutionSession &ES; - std::unique_ptr Registrar; - DenseMap InProcessLinks; - DenseMap> EHFrameRanges; + ExecutorAddr RegisterEHFrame; + ExecutorAddr DeregisterEHFrame; }; -} // end namespace orc -} // end namespace llvm +} // namespace llvm::orc #endif // LLVM_EXECUTIONENGINE_ORC_EHFRAMEREGISTRATIONPLUGIN_H diff --git a/llvm/include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h b/llvm/include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h deleted file mode 100644 index 182e9ed1041a6..0000000000000 --- a/llvm/include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h +++ /dev/null @@ -1,58 +0,0 @@ -//===-- EPCEHFrameRegistrar.h - EPC based eh-frame registration -*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// ExecutorProcessControl based eh-frame registration. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_EXECUTIONENGINE_ORC_EPCEHFRAMEREGISTRAR_H -#define LLVM_EXECUTIONENGINE_ORC_EPCEHFRAMEREGISTRAR_H - -#include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h" -#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h" - -namespace llvm { -namespace orc { - -class ExecutionSession; - -/// Register/Deregisters EH frames in a remote process via a -/// ExecutorProcessControl instance. -class EPCEHFrameRegistrar : public jitlink::EHFrameRegistrar { -public: - /// Create from a ExecutorProcessControl instance alone. This will use - /// the EPC's lookupSymbols method to find the registration/deregistration - /// function addresses by name. - /// - /// If RegistrationFunctionsDylib is non-None then it will be searched to - /// find the registration functions. If it is None then the process dylib - /// will be loaded to find the registration functions. - static Expected> - Create(ExecutionSession &ES); - - /// Create a EPCEHFrameRegistrar with the given ExecutorProcessControl - /// object and registration/deregistration function addresses. - EPCEHFrameRegistrar(ExecutionSession &ES, - ExecutorAddr RegisterEHFrameSectionWrapper, - ExecutorAddr DeregisterEHFRameSectionWrapper) - : ES(ES), RegisterEHFrameSectionWrapper(RegisterEHFrameSectionWrapper), - DeregisterEHFrameSectionWrapper(DeregisterEHFRameSectionWrapper) {} - - Error registerEHFrames(ExecutorAddrRange EHFrameSection) override; - Error deregisterEHFrames(ExecutorAddrRange EHFrameSection) override; - -private: - ExecutionSession &ES; - ExecutorAddr RegisterEHFrameSectionWrapper; - ExecutorAddr DeregisterEHFrameSectionWrapper; -}; - -} // end namespace orc -} // end namespace llvm - -#endif // LLVM_EXECUTIONENGINE_ORC_EPCEHFRAMEREGISTRAR_H diff --git a/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp b/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp index 540dfdad5831b..72e5f701f89a7 100644 --- a/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp @@ -639,20 +639,6 @@ Error EHFrameNullTerminator::operator()(LinkGraph &G) { return Error::success(); } -EHFrameRegistrar::~EHFrameRegistrar() = default; - -Error InProcessEHFrameRegistrar::registerEHFrames( - orc::ExecutorAddrRange EHFrameSection) { - return orc::registerEHFrameSection(EHFrameSection.Start.toPtr(), - EHFrameSection.size()); -} - -Error InProcessEHFrameRegistrar::deregisterEHFrames( - orc::ExecutorAddrRange EHFrameSection) { - return orc::deregisterEHFrameSection(EHFrameSection.Start.toPtr(), - EHFrameSection.size()); -} - EHFrameCFIBlockInspector EHFrameCFIBlockInspector::FromEdgeScan(Block &B) { if (B.edges_empty()) return EHFrameCFIBlockInspector(nullptr); @@ -678,36 +664,24 @@ EHFrameCFIBlockInspector::EHFrameCFIBlockInspector(Edge &CIEEdge, Edge *LSDAEdge) : CIEEdge(&CIEEdge), PCBeginEdge(&PCBeginEdge), LSDAEdge(LSDAEdge) {} -LinkGraphPassFunction -createEHFrameRecorderPass(const Triple &TT, - StoreFrameRangeFunction StoreRangeAddress) { +Section *getEHFrameSection(LinkGraph &G) { const char *EHFrameSectionName = nullptr; - if (TT.getObjectFormat() == Triple::MachO) + switch (G.getTargetTriple().getObjectFormat()) { + case Triple::MachO: EHFrameSectionName = "__TEXT,__eh_frame"; - else + break; + case Triple::ELF: EHFrameSectionName = ".eh_frame"; + break; + default: + return nullptr; + } - auto RecordEHFrame = - [EHFrameSectionName, - StoreFrameRange = std::move(StoreRangeAddress)](LinkGraph &G) -> Error { - // Search for a non-empty eh-frame and record the address of the first - // symbol in it. - orc::ExecutorAddr Addr; - size_t Size = 0; - if (auto *S = G.findSectionByName(EHFrameSectionName)) { - auto R = SectionRange(*S); - Addr = R.getStart(); - Size = R.getSize(); - } - if (!Addr && Size != 0) - return make_error( - StringRef(EHFrameSectionName) + - " section can not have zero address with non-zero size"); - StoreFrameRange(Addr, Size); - return Error::success(); - }; + if (auto *S = G.findSectionByName(EHFrameSectionName)) + if (!S->empty()) + return S; - return RecordEHFrame; + return nullptr; } } // end namespace jitlink diff --git a/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt b/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt index c701a05ee301f..431f9590a874e 100644 --- a/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt +++ b/llvm/lib/ExecutionEngine/Orc/CMakeLists.txt @@ -18,7 +18,6 @@ add_llvm_component_library(LLVMOrcJIT EHFrameRegistrationPlugin.cpp EPCDynamicLibrarySearchGenerator.cpp EPCDebugObjectRegistrar.cpp - EPCEHFrameRegistrar.cpp EPCGenericDylibManager.cpp EPCGenericJITLinkMemoryManager.cpp EPCGenericRTDyldMemoryManager.cpp diff --git a/llvm/lib/ExecutionEngine/Orc/EHFrameRegistrationPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/EHFrameRegistrationPlugin.cpp index 161bd68ff0854..cad2a4906e7c9 100644 --- a/llvm/lib/ExecutionEngine/Orc/EHFrameRegistrationPlugin.cpp +++ b/llvm/lib/ExecutionEngine/Orc/EHFrameRegistrationPlugin.cpp @@ -10,6 +10,7 @@ #include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h" #include "llvm/ExecutionEngine/Orc/Shared/MachOObjectFormat.h" +#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h" #define DEBUG_TYPE "orc" @@ -17,14 +18,26 @@ using namespace llvm::jitlink; namespace llvm::orc { -EHFrameRegistrationPlugin::EHFrameRegistrationPlugin( - ExecutionSession &ES, std::unique_ptr Registrar) - : ES(ES), Registrar(std::move(Registrar)) {} +Expected> +EHFrameRegistrationPlugin::Create(ExecutionSession &ES) { + // Lookup addresseses of the registration/deregistration functions in the + // bootstrap map. + ExecutorAddr RegisterEHFrameSectionWrapper; + ExecutorAddr DeregisterEHFrameSectionWrapper; + if (auto Err = ES.getExecutorProcessControl().getBootstrapSymbols( + {{RegisterEHFrameSectionWrapper, + rt::RegisterEHFrameSectionWrapperName}, + {DeregisterEHFrameSectionWrapper, + rt::DeregisterEHFrameSectionWrapperName}})) + return std::move(Err); + + return std::make_unique( + ES, RegisterEHFrameSectionWrapper, DeregisterEHFrameSectionWrapper); +} void EHFrameRegistrationPlugin::modifyPassConfig( MaterializationResponsibility &MR, LinkGraph &LG, PassConfiguration &PassConfig) { - if (LG.getTargetTriple().isOSBinFormatMachO()) PassConfig.PrePrunePasses.insert( PassConfig.PrePrunePasses.begin(), [](LinkGraph &G) { @@ -33,92 +46,20 @@ void EHFrameRegistrationPlugin::modifyPassConfig( return Error::success(); }); - PassConfig.PostFixupPasses.push_back(createEHFrameRecorderPass( - LG.getTargetTriple(), [this, &MR](ExecutorAddr Addr, size_t Size) { - if (Addr) { - std::lock_guard Lock(EHFramePluginMutex); - assert(!InProcessLinks.count(&MR) && - "Link for MR already being tracked?"); - InProcessLinks[&MR] = {Addr, Size}; - } - })); -} - -Error EHFrameRegistrationPlugin::notifyEmitted( - MaterializationResponsibility &MR) { - - ExecutorAddrRange EmittedRange; - { - std::lock_guard Lock(EHFramePluginMutex); - - auto EHFrameRangeItr = InProcessLinks.find(&MR); - if (EHFrameRangeItr == InProcessLinks.end()) - return Error::success(); - - EmittedRange = EHFrameRangeItr->second; - assert(EmittedRange.Start && "eh-frame addr to register can not be null"); - InProcessLinks.erase(EHFrameRangeItr); - } - - if (auto Err = MR.withResourceKeyDo( - [&](ResourceKey K) { EHFrameRanges[K].push_back(EmittedRange); })) - return Err; - - return Registrar->registerEHFrames(EmittedRange); -} - -Error EHFrameRegistrationPlugin::notifyFailed( - MaterializationResponsibility &MR) { - std::lock_guard Lock(EHFramePluginMutex); - InProcessLinks.erase(&MR); - return Error::success(); -} - -Error EHFrameRegistrationPlugin::notifyRemovingResources(JITDylib &JD, - ResourceKey K) { - std::vector RangesToRemove; - - ES.runSessionLocked([&] { - auto I = EHFrameRanges.find(K); - if (I != EHFrameRanges.end()) { - RangesToRemove = std::move(I->second); - EHFrameRanges.erase(I); + PassConfig.PostFixupPasses.push_back([this](LinkGraph &G) -> Error { + if (auto *EHFrame = getEHFrameSection(G)) { + using namespace shared; + auto R = SectionRange(*EHFrame).getRange(); + G.allocActions().push_back( + {cantFail( + WrapperFunctionCall::Create>( + RegisterEHFrame, R)), + cantFail( + WrapperFunctionCall::Create>( + DeregisterEHFrame, R))}); } + return Error::success(); }); - - Error Err = Error::success(); - while (!RangesToRemove.empty()) { - auto RangeToRemove = RangesToRemove.back(); - RangesToRemove.pop_back(); - assert(RangeToRemove.Start && "Untracked eh-frame range must not be null"); - Err = joinErrors(std::move(Err), - Registrar->deregisterEHFrames(RangeToRemove)); - } - - return Err; -} - -void EHFrameRegistrationPlugin::notifyTransferringResources( - JITDylib &JD, ResourceKey DstKey, ResourceKey SrcKey) { - auto SI = EHFrameRanges.find(SrcKey); - if (SI == EHFrameRanges.end()) - return; - - auto DI = EHFrameRanges.find(DstKey); - if (DI != EHFrameRanges.end()) { - auto &SrcRanges = SI->second; - auto &DstRanges = DI->second; - DstRanges.reserve(DstRanges.size() + SrcRanges.size()); - for (auto &SrcRange : SrcRanges) - DstRanges.push_back(std::move(SrcRange)); - EHFrameRanges.erase(SI); - } else { - // We need to move SrcKey's ranges over without invalidating the SI - // iterator. - auto Tmp = std::move(SI->second); - EHFrameRanges.erase(SI); - EHFrameRanges[DstKey] = std::move(Tmp); - } } } // namespace llvm::orc diff --git a/llvm/lib/ExecutionEngine/Orc/EPCEHFrameRegistrar.cpp b/llvm/lib/ExecutionEngine/Orc/EPCEHFrameRegistrar.cpp deleted file mode 100644 index f15315260ab01..0000000000000 --- a/llvm/lib/ExecutionEngine/Orc/EPCEHFrameRegistrar.cpp +++ /dev/null @@ -1,49 +0,0 @@ -//===------ EPCEHFrameRegistrar.cpp - EPC-based eh-frame registration -----===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h" - -#include "llvm/ExecutionEngine/Orc/Core.h" -#include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h" - -using namespace llvm::orc::shared; - -namespace llvm { -namespace orc { - -Expected> -EPCEHFrameRegistrar::Create(ExecutionSession &ES) { - - // Lookup addresseses of the registration/deregistration functions in the - // bootstrap map. - ExecutorAddr RegisterEHFrameSectionWrapper; - ExecutorAddr DeregisterEHFrameSectionWrapper; - if (auto Err = ES.getExecutorProcessControl().getBootstrapSymbols( - {{RegisterEHFrameSectionWrapper, - rt::RegisterEHFrameSectionWrapperName}, - {DeregisterEHFrameSectionWrapper, - rt::DeregisterEHFrameSectionWrapperName}})) - return std::move(Err); - - return std::make_unique( - ES, RegisterEHFrameSectionWrapper, DeregisterEHFrameSectionWrapper); -} - -Error EPCEHFrameRegistrar::registerEHFrames(ExecutorAddrRange EHFrameSection) { - return ES.callSPSWrapper( - RegisterEHFrameSectionWrapper, EHFrameSection); -} - -Error EPCEHFrameRegistrar::deregisterEHFrames( - ExecutorAddrRange EHFrameSection) { - return ES.callSPSWrapper( - DeregisterEHFrameSectionWrapper, EHFrameSection); -} - -} // end namespace orc -} // end namespace llvm diff --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp index a48b2624eccda..1886ea062c8d5 100644 --- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp +++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp @@ -14,7 +14,6 @@ #include "llvm/ExecutionEngine/Orc/EHFrameRegistrationPlugin.h" #include "llvm/ExecutionEngine/Orc/ELFNixPlatform.h" #include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h" -#include "llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h" #include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h" #include "llvm/ExecutionEngine/Orc/MachOPlatform.h" #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h" @@ -1252,12 +1251,11 @@ Expected setUpGenericLLVMIRPlatform(LLJIT &J) { // Otherwise fall back to standard unwind registration. if (UseEHFrames) { auto &ES = J.getExecutionSession(); - if (auto EHFrameRegistrar = EPCEHFrameRegistrar::Create(ES)) { - OLL->addPlugin(std::make_unique( - ES, std::move(*EHFrameRegistrar))); + if (auto EHFP = EHFrameRegistrationPlugin::Create(ES)) { + OLL->addPlugin(std::move(*EHFP)); LLVM_DEBUG(dbgs() << "Enabled eh-frame support.\n"); } else - return EHFrameRegistrar.takeError(); + return EHFP.takeError(); } } diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp index e4ed5b2aefb9a..9cadee0ba09ad 100644 --- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp @@ -27,7 +27,6 @@ #include "llvm/ExecutionEngine/Orc/ELFNixPlatform.h" #include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h" #include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h" -#include "llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h" #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h" #include "llvm/ExecutionEngine/Orc/GetDylibInterface.h" #include "llvm/ExecutionEngine/Orc/IndirectionUtils.h" @@ -1248,13 +1247,11 @@ Session::Session(std::unique_ptr EPC, Error &Err) if (!UseEHFrames) ObjLayer.addPlugin(ExitOnErr(UnwindInfoRegistrationPlugin::Create(ES))); else - ObjLayer.addPlugin(std::make_unique( - ES, ExitOnErr(EPCEHFrameRegistrar::Create(ES)))); + ObjLayer.addPlugin(ExitOnErr(EHFrameRegistrationPlugin::Create(ES))); } } else if (TT.isOSBinFormatELF()) { if (!NoExec) - ObjLayer.addPlugin(std::make_unique( - ES, ExitOnErr(EPCEHFrameRegistrar::Create(this->ES)))); + ObjLayer.addPlugin(ExitOnErr(EHFrameRegistrationPlugin::Create(ES))); if (DebuggerSupport) ObjLayer.addPlugin(std::make_unique( ES, ExitOnErr(createJITLoaderGDBRegistrar(this->ES)), true, true)); From f77ab84f02448a417527e0051fa76ab096d9e46e Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 11 Mar 2025 16:12:52 +1100 Subject: [PATCH 2/2] Rename eh-frame registration functions to reflect their new status as actions, clang-format patch. --- .../Orc/EHFrameRegistrationPlugin.h | 7 +++---- .../llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h | 4 ++-- .../Orc/TargetProcess/RegisterEHFrames.h | 4 ++-- .../Orc/EHFrameRegistrationPlugin.cpp | 14 +++++++------- .../Orc/EPCGenericRTDyldMemoryManager.cpp | 5 +++-- llvm/lib/ExecutionEngine/Orc/LLJIT.cpp | 4 ++-- .../lib/ExecutionEngine/Orc/Shared/OrcRTBridge.cpp | 8 ++++---- .../TargetProcess/DefaultHostBootstrapValues.cpp | 8 ++++---- .../Orc/TargetProcess/RegisterEHFrames.cpp | 4 ++-- .../Orc/TargetProcess/SimpleRemoteEPCServer.cpp | 8 ++++---- llvm/tools/lli/lli.cpp | 4 ++-- .../llvm-jitlink-executor.cpp | 4 ++-- llvm/tools/llvm-jitlink/llvm-jitlink.cpp | 4 ++-- 13 files changed, 39 insertions(+), 39 deletions(-) diff --git a/llvm/include/llvm/ExecutionEngine/Orc/EHFrameRegistrationPlugin.h b/llvm/include/llvm/ExecutionEngine/Orc/EHFrameRegistrationPlugin.h index fb035d890eee5..6f25b998fb005 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/EHFrameRegistrationPlugin.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/EHFrameRegistrationPlugin.h @@ -28,10 +28,10 @@ class EHFrameRegistrationPlugin : public LinkGraphLinkingLayer::Plugin { static Expected> Create(ExecutionSession &ES); - EHFrameRegistrationPlugin(ExecutionSession &ES, ExecutorAddr RegisterEHFrame, + EHFrameRegistrationPlugin(ExecutorAddr RegisterEHFrame, ExecutorAddr DeregisterEHFrame) - : ES(ES), RegisterEHFrame(RegisterEHFrame), - DeregisterEHFrame(DeregisterEHFrame) {} + : RegisterEHFrame(RegisterEHFrame), DeregisterEHFrame(DeregisterEHFrame) { + } void modifyPassConfig(MaterializationResponsibility &MR, jitlink::LinkGraph &G, @@ -46,7 +46,6 @@ class EHFrameRegistrationPlugin : public LinkGraphLinkingLayer::Plugin { ResourceKey SrcKey) override {} private: - ExecutionSession &ES; ExecutorAddr RegisterEHFrame; ExecutorAddr DeregisterEHFrame; }; diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h index 0f59edd429332..927939e63bbfd 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h @@ -44,8 +44,8 @@ extern const char *MemoryWriteUInt64sWrapperName; extern const char *MemoryWriteBuffersWrapperName; extern const char *MemoryWritePointersWrapperName; -extern const char *RegisterEHFrameSectionWrapperName; -extern const char *DeregisterEHFrameSectionWrapperName; +extern const char *RegisterEHFrameSectionAllocActionName; +extern const char *DeregisterEHFrameSectionAllocActionName; extern const char *RunAsMainWrapperName; extern const char *RunAsVoidFunctionWrapperName; diff --git a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h index d375f6034616a..0c56fa885cf4d 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h @@ -35,9 +35,9 @@ Error deregisterEHFrameSection(const void *EHFrameSectionAddr, } // end namespace llvm extern "C" LLVM_ABI llvm::orc::shared::CWrapperFunctionResult -llvm_orc_registerEHFrameSectionWrapper(const char *Data, uint64_t Size); +llvm_orc_registerEHFrameSectionAllocAction(const char *Data, uint64_t Size); extern "C" LLVM_ABI llvm::orc::shared::CWrapperFunctionResult -llvm_orc_deregisterEHFrameSectionWrapper(const char *Data, uint64_t Size); +llvm_orc_deregisterEHFrameSectionAllocAction(const char *Data, uint64_t Size); #endif // LLVM_EXECUTIONENGINE_ORC_TARGETPROCESS_REGISTEREHFRAMES_H diff --git a/llvm/lib/ExecutionEngine/Orc/EHFrameRegistrationPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/EHFrameRegistrationPlugin.cpp index cad2a4906e7c9..b34c3434b256c 100644 --- a/llvm/lib/ExecutionEngine/Orc/EHFrameRegistrationPlugin.cpp +++ b/llvm/lib/ExecutionEngine/Orc/EHFrameRegistrationPlugin.cpp @@ -22,17 +22,17 @@ Expected> EHFrameRegistrationPlugin::Create(ExecutionSession &ES) { // Lookup addresseses of the registration/deregistration functions in the // bootstrap map. - ExecutorAddr RegisterEHFrameSectionWrapper; - ExecutorAddr DeregisterEHFrameSectionWrapper; + ExecutorAddr RegisterEHFrameSectionAllocAction; + ExecutorAddr DeregisterEHFrameSectionAllocAction; if (auto Err = ES.getExecutorProcessControl().getBootstrapSymbols( - {{RegisterEHFrameSectionWrapper, - rt::RegisterEHFrameSectionWrapperName}, - {DeregisterEHFrameSectionWrapper, - rt::DeregisterEHFrameSectionWrapperName}})) + {{RegisterEHFrameSectionAllocAction, + rt::RegisterEHFrameSectionAllocActionName}, + {DeregisterEHFrameSectionAllocAction, + rt::DeregisterEHFrameSectionAllocActionName}})) return std::move(Err); return std::make_unique( - ES, RegisterEHFrameSectionWrapper, DeregisterEHFrameSectionWrapper); + RegisterEHFrameSectionAllocAction, DeregisterEHFrameSectionAllocAction); } void EHFrameRegistrationPlugin::modifyPassConfig( diff --git a/llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp b/llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp index 060f17c957ef9..fec7062ff79a6 100644 --- a/llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp +++ b/llvm/lib/ExecutionEngine/Orc/EPCGenericRTDyldMemoryManager.cpp @@ -28,8 +28,9 @@ EPCGenericRTDyldMemoryManager::CreateWithDefaultBootstrapSymbols( {SAs.Finalize, rt::SimpleExecutorMemoryManagerFinalizeWrapperName}, {SAs.Deallocate, rt::SimpleExecutorMemoryManagerDeallocateWrapperName}, - {SAs.RegisterEHFrame, rt::RegisterEHFrameSectionWrapperName}, - {SAs.DeregisterEHFrame, rt::DeregisterEHFrameSectionWrapperName}})) + {SAs.RegisterEHFrame, rt::RegisterEHFrameSectionAllocActionName}, + {SAs.DeregisterEHFrame, + rt::DeregisterEHFrameSectionAllocActionName}})) return std::move(Err); return std::make_unique(EPC, std::move(SAs)); } diff --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp index 1886ea062c8d5..7d385f4cf2fbb 100644 --- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp +++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp @@ -1340,8 +1340,8 @@ LLLazyJIT::LLLazyJIT(LLLazyJITBuilderState &S, Error &Err) : LLJIT(S, Err) { // In-process LLJIT uses eh-frame section wrappers via EPC, so we need to force // them to be linked in. LLVM_ATTRIBUTE_USED void linkComponents() { - errs() << (void *)&llvm_orc_registerEHFrameSectionWrapper - << (void *)&llvm_orc_deregisterEHFrameSectionWrapper; + errs() << (void *)&llvm_orc_registerEHFrameSectionAllocAction + << (void *)&llvm_orc_deregisterEHFrameSectionAllocAction; } } // End namespace orc. diff --git a/llvm/lib/ExecutionEngine/Orc/Shared/OrcRTBridge.cpp b/llvm/lib/ExecutionEngine/Orc/Shared/OrcRTBridge.cpp index d3b3f121cfcd9..4e5b800100b9c 100644 --- a/llvm/lib/ExecutionEngine/Orc/Shared/OrcRTBridge.cpp +++ b/llvm/lib/ExecutionEngine/Orc/Shared/OrcRTBridge.cpp @@ -52,10 +52,10 @@ const char *MemoryWriteBuffersWrapperName = const char *MemoryWritePointersWrapperName = "__llvm_orc_bootstrap_mem_write_pointers_wrapper"; -const char *RegisterEHFrameSectionWrapperName = - "llvm_orc_registerEHFrameSectionWrapper"; -const char *DeregisterEHFrameSectionWrapperName = - "llvm_orc_deregisterEHFrameSectionWrapper"; +const char *RegisterEHFrameSectionAllocActionName = + "llvm_orc_registerEHFrameAllocAction"; +const char *DeregisterEHFrameSectionAllocActionName = + "llvm_orc_deregisterEHFrameAllocAction"; const char *RunAsMainWrapperName = "__llvm_orc_bootstrap_run_as_main_wrapper"; const char *RunAsVoidFunctionWrapperName = diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/DefaultHostBootstrapValues.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/DefaultHostBootstrapValues.cpp index c95b7ac5159fe..a30e87243ada8 100644 --- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/DefaultHostBootstrapValues.cpp +++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/DefaultHostBootstrapValues.cpp @@ -22,10 +22,10 @@ void addDefaultBootstrapValuesForHostProcess( StringMap &BootstrapSymbols) { // FIXME: We probably shouldn't set these on Windows? - BootstrapSymbols[rt::RegisterEHFrameSectionWrapperName] = - ExecutorAddr::fromPtr(&llvm_orc_registerEHFrameSectionWrapper); - BootstrapSymbols[rt::DeregisterEHFrameSectionWrapperName] = - ExecutorAddr::fromPtr(&llvm_orc_deregisterEHFrameSectionWrapper); + BootstrapSymbols[rt::RegisterEHFrameSectionAllocActionName] = + ExecutorAddr::fromPtr(&llvm_orc_registerEHFrameSectionAllocAction); + BootstrapSymbols[rt::DeregisterEHFrameSectionAllocActionName] = + ExecutorAddr::fromPtr(&llvm_orc_deregisterEHFrameSectionAllocAction); #ifdef __APPLE__ if (!dlsym(RTLD_DEFAULT, "__unw_add_find_dynamic_unwind_sections")) diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.cpp index f11a73bb5c7ac..fbaf2bae25f4b 100644 --- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.cpp +++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.cpp @@ -164,14 +164,14 @@ static Error deregisterEHFrameWrapper(ExecutorAddrRange EHFrame) { } extern "C" orc::shared::CWrapperFunctionResult -llvm_orc_registerEHFrameSectionWrapper(const char *Data, uint64_t Size) { +llvm_orc_registerEHFrameSectionAllocAction(const char *Data, uint64_t Size) { return WrapperFunction::handle( Data, Size, registerEHFrameWrapper) .release(); } extern "C" orc::shared::CWrapperFunctionResult -llvm_orc_deregisterEHFrameSectionWrapper(const char *Data, uint64_t Size) { +llvm_orc_deregisterEHFrameSectionAllocAction(const char *Data, uint64_t Size) { return WrapperFunction::handle( Data, Size, deregisterEHFrameWrapper) .release(); diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp index 4862b2d3e7f79..0ac68122317a9 100644 --- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp +++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp @@ -207,10 +207,10 @@ Error SimpleRemoteEPCServer::sendSetupMessage( "Dispatch function name should not be set"); EI.BootstrapSymbols[ExecutorSessionObjectName] = ExecutorAddr::fromPtr(this); EI.BootstrapSymbols[DispatchFnName] = ExecutorAddr::fromPtr(jitDispatchEntry); - EI.BootstrapSymbols[rt::RegisterEHFrameSectionWrapperName] = - ExecutorAddr::fromPtr(&llvm_orc_registerEHFrameSectionWrapper); - EI.BootstrapSymbols[rt::DeregisterEHFrameSectionWrapperName] = - ExecutorAddr::fromPtr(&llvm_orc_deregisterEHFrameSectionWrapper); + EI.BootstrapSymbols[rt::RegisterEHFrameSectionAllocActionName] = + ExecutorAddr::fromPtr(&llvm_orc_registerEHFrameSectionAllocAction); + EI.BootstrapSymbols[rt::DeregisterEHFrameSectionAllocActionName] = + ExecutorAddr::fromPtr(&llvm_orc_deregisterEHFrameSectionAllocAction); using SPSSerialize = shared::SPSArgList; diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp index 1417a58ab4487..ed1a80d3c1bc9 100644 --- a/llvm/tools/lli/lli.cpp +++ b/llvm/tools/lli/lli.cpp @@ -285,8 +285,8 @@ namespace { } LLVM_ATTRIBUTE_USED void linkComponents() { - errs() << (void *)&llvm_orc_registerEHFrameSectionWrapper - << (void *)&llvm_orc_deregisterEHFrameSectionWrapper + errs() << (void *)&llvm_orc_registerEHFrameSectionAllocAction + << (void *)&llvm_orc_deregisterEHFrameSectionAllocAction << (void *)&llvm_orc_registerJITLoaderGDBWrapper << (void *)&llvm_orc_registerJITLoaderGDBAllocAction; } diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp index 8553eb70ebe49..8d33ae1edcaaa 100644 --- a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp +++ b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp @@ -42,8 +42,8 @@ using namespace llvm::orc; ExitOnError ExitOnErr; LLVM_ATTRIBUTE_USED void linkComponents() { - errs() << (void *)&llvm_orc_registerEHFrameSectionWrapper - << (void *)&llvm_orc_deregisterEHFrameSectionWrapper + errs() << (void *)&llvm_orc_registerEHFrameSectionAllocAction + << (void *)&llvm_orc_deregisterEHFrameSectionAllocAction << (void *)&llvm_orc_registerJITLoaderGDBWrapper << (void *)&llvm_orc_registerJITLoaderGDBAllocAction; } diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp index 9cadee0ba09ad..8a17abd58e98a 100644 --- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp +++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp @@ -336,8 +336,8 @@ static ExitOnError ExitOnErr; static LLVM_ATTRIBUTE_USED void linkComponents() { errs() << "Linking in runtime functions\n" - << (void *)&llvm_orc_registerEHFrameSectionWrapper << '\n' - << (void *)&llvm_orc_deregisterEHFrameSectionWrapper << '\n' + << (void *)&llvm_orc_registerEHFrameSectionAllocAction << '\n' + << (void *)&llvm_orc_deregisterEHFrameSectionAllocAction << '\n' << (void *)&llvm_orc_registerJITLoaderGDBWrapper << '\n' << (void *)&llvm_orc_registerJITLoaderGDBAllocAction << '\n' << (void *)&llvm_orc_registerJITLoaderPerfStart << '\n'