LLVM: lib/ExecutionEngine/Orc/UnwindInfoRegistrationPlugin.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
10
14
15#define DEBUG_TYPE "orc"
16
18
20
21Expected<std::shared_ptr>
23
25
26 auto &EPC = ES.getExecutorProcessControl();
27 if (auto Err = EPC.getBootstrapSymbols(
28 {{Register, rt_alt::UnwindInfoManagerRegisterActionName},
29 {Deregister, rt_alt::UnwindInfoManagerDeregisterActionName}}))
30 return std::move(Err);
31
32 return std::make_shared(ES, Register,
33 Deregister);
34}
35
39
41 [this](LinkGraph &G) { return addUnwindInfoRegistrationActions(G); });
42}
43
44Error UnwindInfoRegistrationPlugin::addUnwindInfoRegistrationActions(
47
48 std::vector<Block *> CodeBlocks;
49
52 return;
53
54 SecRange.Start = (*Sec.blocks().begin())->getAddress();
55 for (auto *B : Sec.blocks()) {
56 auto R = B->getRange();
57 SecRange.Start = std::min(SecRange.Start, R.Start);
58 SecRange.End = std::max(SecRange.End, R.End);
59 for (auto &E : B->edges()) {
60 if (E.getKind() != Edge::KeepAlive || !E.getTarget().isDefined())
61 continue;
62 auto &TargetBlock = E.getTarget().getBlock();
63 auto &TargetSection = TargetBlock.getSection();
65 CodeBlocks.push_back(&TargetBlock);
66 }
67 }
68 };
69
70 if (auto *EHFrame = G.findSectionByName(MachOEHFrameSectionName))
71 ScanUnwindInfoSection(*EHFrame, EHFrameRange);
72
73 if (auto *UnwindInfo = G.findSectionByName(MachOUnwindInfoSectionName))
74 ScanUnwindInfoSection(*UnwindInfo, UnwindInfoRange);
75
76 if (CodeBlocks.empty())
78
79 if ((EHFrameRange == ExecutorAddrRange() &&
80 UnwindInfoRange == ExecutorAddrRange()))
82
84 return LHS->getAddress() < RHS->getAddress();
85 });
86
88 for (auto *B : CodeBlocks) {
89 if (CodeRanges.empty() || CodeRanges.back().End != B->getAddress())
90 CodeRanges.push_back(B->getRange());
91 else
92 CodeRanges.back().End = B->getRange().End;
93 }
94
95 ExecutorAddr DSOBase;
96 if (auto *DSOBaseSym = G.findAbsoluteSymbolByName(DSOBaseName))
97 DSOBase = DSOBaseSym->getAddress();
98 else if (auto *DSOBaseSym = G.findExternalSymbolByName(DSOBaseName))
99 DSOBase = DSOBaseSym->getAddress();
100 else if (auto *DSOBaseSym = G.findDefinedSymbolByName(DSOBaseName))
101 DSOBase = DSOBaseSym->getAddress();
102 else
104 " could not find dso base symbol",
106
107 using namespace shared;
108 using SPSRegisterArgs =
109 SPSArgList<SPSSequence, SPSExecutorAddr,
111 using SPSDeregisterArgs = SPSArgList<SPSSequence>;
112
113 G.allocActions().push_back(
114 {cantFail(WrapperFunctionCall::Create(
115 Register, CodeRanges, DSOBase, EHFrameRange, UnwindInfoRange)),
116 cantFail(WrapperFunctionCall::Create(Deregister,
117 CodeRanges))});
118
120}
121
122}
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Module.h This file contains the declarations for the Module class.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Wrapper class representing virtual and physical registers.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represents an object file section.
iterator_range< block_iterator > blocks()
Returns an iterator over the blocks defined in this section.
bool empty() const
Returns true if this section is empty (contains no blocks or symbols).
An ExecutionSession represents a running JIT program.
Represents an address in the executor process.
Tracks responsibility for materialization, and mediates interactions between MaterializationUnits and...
void modifyPassConfig(MaterializationResponsibility &MR, jitlink::LinkGraph &G, jitlink::PassConfiguration &PassConfig) override
Definition UnwindInfoRegistrationPlugin.cpp:36
static Expected< std::shared_ptr< UnwindInfoRegistrationPlugin > > Create(ExecutionSession &ES, ExecutorAddr Register, ExecutorAddr Deregister)
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
void sort(IteratorTy Start, IteratorTy End)
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
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.