LLVM 17.0.0git
EPCEHFrameRegistrar.cpp
Go to the documentation of this file.
1//===------ EPCEHFrameRegistrar.cpp - EPC-based eh-frame registration -----===//
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
10
13
14using namespace llvm::orc::shared;
15
16namespace llvm {
17namespace orc {
18
21 std::optional<ExecutorAddr> RegistrationFunctionsDylib) {
22 // FIXME: Proper mangling here -- we really need to decouple linker mangling
23 // from DataLayout.
24
25 // Find the addresses of the registration/deregistration functions in the
26 // executor process.
27 auto &EPC = ES.getExecutorProcessControl();
28
29 if (!RegistrationFunctionsDylib) {
30 if (auto D = EPC.loadDylib(nullptr))
31 RegistrationFunctionsDylib = *D;
32 else
33 return D.takeError();
34 }
35
36 std::string RegisterWrapperName, DeregisterWrapperName;
37 if (EPC.getTargetTriple().isOSBinFormatMachO()) {
38 RegisterWrapperName += '_';
39 DeregisterWrapperName += '_';
40 }
41 RegisterWrapperName += "llvm_orc_registerEHFrameSectionWrapper";
42 DeregisterWrapperName += "llvm_orc_deregisterEHFrameSectionWrapper";
43
44 SymbolLookupSet RegistrationSymbols;
45 RegistrationSymbols.add(EPC.intern(RegisterWrapperName));
46 RegistrationSymbols.add(EPC.intern(DeregisterWrapperName));
47
48 auto Result =
49 EPC.lookupSymbols({{*RegistrationFunctionsDylib, RegistrationSymbols}});
50 if (!Result)
51 return Result.takeError();
52
53 assert(Result->size() == 1 && "Unexpected number of dylibs in result");
54 assert((*Result)[0].size() == 2 &&
55 "Unexpected number of addresses in result");
56
57 auto RegisterEHFrameWrapperFnAddr = (*Result)[0][0];
58 auto DeregisterEHFrameWrapperFnAddr = (*Result)[0][1];
59
60 return std::make_unique<EPCEHFrameRegistrar>(
61 ES, ExecutorAddr(RegisterEHFrameWrapperFnAddr),
62 ExecutorAddr(DeregisterEHFrameWrapperFnAddr));
63}
64
66 return ES.callSPSWrapper<void(SPSExecutorAddrRange)>(
67 RegisterEHFrameWrapperFnAddr, EHFrameSection);
68}
69
71 ExecutorAddrRange EHFrameSection) {
72 return ES.callSPSWrapper<void(SPSExecutorAddrRange)>(
73 DeregisterEHFrameWrapperFnAddr, EHFrameSection);
74}
75
76} // end namespace orc
77} // end namespace llvm
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
return ToRemove size() > 0
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
Tagged union holding either a T or a Error.
Definition: Error.h:470
Error deregisterEHFrames(ExecutorAddrRange EHFrameSection) override
static Expected< std::unique_ptr< EPCEHFrameRegistrar > > Create(ExecutionSession &ES, std::optional< ExecutorAddr > RegistrationFunctionsDylib=std::nullopt)
Create from a ExecutorProcessControl instance alone.
Error registerEHFrames(ExecutorAddrRange EHFrameSection) override
An ExecutionSession represents a running JIT program.
Definition: Core.h:1373
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
Definition: Core.h:1416
Error callSPSWrapper(ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
Definition: Core.h:1621
Represents an address in the executor process.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:180
SymbolLookupSet & add(SymbolStringPtr Name, SymbolLookupFlags Flags=SymbolLookupFlags::RequiredSymbol)
Add an element to the set.
Definition: Core.h:241
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Represents an address range in the exceutor process.