13#ifndef LLVM_EXECUTIONENGINE_JITLINK_PERGRAPHGOTANDPLTSTUBSBUILDER_H
14#define LLVM_EXECUTIONENGINE_JITLINK_PERGRAPHGOTANDPLTSTUBSBUILDER_H
19#define DEBUG_TYPE "jitlink"
31template <
typename BuilderImplT>
39 LLVM_DEBUG(
dbgs() <<
"Running Per-Graph GOT and Stubs builder:\n");
43 std::vector<Block *> Worklist(
G.
blocks().begin(),
G.
blocks().end());
45 for (
auto *
B : Worklist)
46 for (
auto &
E :
B->edges()) {
47 if (impl().isGOTEdgeToFix(
E)) {
50 <<
" edge at " <<
B->getFixupAddress(
E) <<
" ("
51 <<
B->getAddress() <<
" + "
52 <<
formatv(
"{0:x}",
E.getOffset()) <<
")\n";
55 }
else if (impl().isExternalBranchEdge(
E)) {
58 <<
" edge at " <<
B->getFixupAddress(
E) <<
" ("
59 <<
B->getAddress() <<
" + "
60 <<
formatv(
"{0:x}",
E.getOffset()) <<
")\n";
71 assert(
Target.hasName() &&
"GOT edge cannot point to anonymous target");
76 if (GOTEntryI == GOTEntries.end()) {
77 auto &GOTEntry = impl().createGOTEntry(
Target);
83 GOTEntries.insert(std::make_pair(
Target.
getName(), &GOTEntry)).first;
86 assert(GOTEntryI != GOTEntries.end() &&
"Could not get GOT entry symbol");
88 {
dbgs() <<
" Using GOT entry " << *GOTEntryI->second <<
"\n"; });
89 return *GOTEntryI->second;
94 "External branch edge can not point to an anonymous target");
97 if (StubI == PLTStubs.end()) {
98 auto &StubSymbol = impl().createPLTStub(
Target);
101 << StubSymbol <<
"\n";
104 PLTStubs.insert(std::make_pair(
Target.
getName(), &StubSymbol)).first;
107 assert(StubI != PLTStubs.end() &&
"Count not get stub symbol");
108 LLVM_DEBUG({
dbgs() <<
" Using PLT stub " << *StubI->second <<
"\n"; });
109 return *StubI->second;
115 BuilderImplT &impl() {
return static_cast<BuilderImplT &
>(*this); }
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Target - Wrapper for Target specific information.
const char * getName() const
getName - Get the target name.
iterator_range< block_iterator > blocks()
const char * getEdgeKindName(Edge::Kind K) const
Per-object GOT and PLT Stub builder.
Symbol & getPLTStub(Symbol &Target)
Symbol & getGOTEntry(Symbol &Target)
PerGraphGOTAndPLTStubsBuilder(LinkGraph &G)
static Error asPass(LinkGraph &G)
This is an optimization pass for GlobalISel generic memory operations.
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.