13#define DEBUG_TYPE "orc"
21 : ES(ES), Registrar(
std::
move(Registrar)) {}
30 std::lock_guard<std::mutex> Lock(EHFramePluginMutex);
31 assert(!InProcessLinks.count(&MR) &&
32 "Link for MR already being tracked?");
33 InProcessLinks[&MR] = {Addr, Size};
38Error EHFrameRegistrationPlugin::notifyEmitted(
43 std::lock_guard<std::mutex> Lock(EHFramePluginMutex);
45 auto EHFrameRangeItr = InProcessLinks.find(&MR);
46 if (EHFrameRangeItr == InProcessLinks.end())
49 EmittedRange = EHFrameRangeItr->second;
50 assert(EmittedRange.
Start &&
"eh-frame addr to register can not be null");
51 InProcessLinks.erase(EHFrameRangeItr);
55 [&](
ResourceKey K) { EHFrameRanges[K].push_back(EmittedRange); }))
58 return Registrar->registerEHFrames(EmittedRange);
61Error EHFrameRegistrationPlugin::notifyFailed(
63 std::lock_guard<std::mutex> Lock(EHFramePluginMutex);
64 InProcessLinks.erase(&MR);
70 std::vector<ExecutorAddrRange> RangesToRemove;
72 ES.runSessionLocked([&] {
73 auto I = EHFrameRanges.find(K);
74 if (
I != EHFrameRanges.end()) {
75 RangesToRemove = std::move(I->second);
76 EHFrameRanges.erase(I);
81 while (!RangesToRemove.empty()) {
82 auto RangeToRemove = RangesToRemove.back();
83 RangesToRemove.pop_back();
84 assert(RangeToRemove.Start &&
"Untracked eh-frame range must not be null");
86 Registrar->deregisterEHFrames(RangeToRemove));
92void EHFrameRegistrationPlugin::notifyTransferringResources(
94 auto SI = EHFrameRanges.find(SrcKey);
95 if (SI == EHFrameRanges.end())
98 auto DI = EHFrameRanges.find(DstKey);
99 if (DI != EHFrameRanges.end()) {
100 auto &SrcRanges = SI->second;
101 auto &DstRanges = DI->second;
102 DstRanges.reserve(DstRanges.size() + SrcRanges.size());
103 for (
auto &SrcRange : SrcRanges)
104 DstRanges.push_back(std::move(SrcRange));
105 EHFrameRanges.erase(SI);
109 auto Tmp = std::move(SI->second);
110 EHFrameRanges.erase(SI);
111 EHFrameRanges[DstKey] = std::move(Tmp);
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
EHFrameRegistrationPlugin(ExecutionSession &ES, std::unique_ptr< jitlink::EHFrameRegistrar > Registrar)
void modifyPassConfig(MaterializationResponsibility &MR, jitlink::LinkGraph &G, jitlink::PassConfiguration &PassConfig) override
An ExecutionSession represents a running JIT program.
Represents an address in the executor process.
Represents a JIT'd dynamic library.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
Error withResourceKeyDo(Func &&F) const
Runs the given callback under the session lock, passing in the associated ResourceKey.
LinkGraphPassFunction createEHFrameRecorderPass(const Triple &TT, StoreFrameRangeFunction StoreFrameRange)
Creates a pass that records the address and size of the EH frame section.
Error joinErrors(Error E1, Error E2)
Concatenate errors.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
An LinkGraph pass configuration, consisting of a list of pre-prune, post-prune, and post-fixup passes...
LinkGraphPassList PostFixupPasses
Post-fixup passes.
Represents an address range in the exceutor process.