15#define DEBUG_TYPE "jitlink"
34 return "Delta32FromGOT";
36 return "RequestGOTAndTransformToDelta32FromGOT";
38 return "BranchPCRel32";
40 return "BranchPCRel32ToPtrJumpStub";
42 return "BranchPCRel32ToPtrJumpStubBypassable";
51 static_cast<char>(0xFFu), 0x25, 0x00, 0x00, 0x00, 0x00};
56 for (
auto *
B :
G.blocks())
57 for (
auto &
E :
B->edges()) {
59 auto &StubBlock =
E.getTarget().getBlock();
61 "Stub block should be stub sized");
62 assert(StubBlock.edges_size() == 1 &&
63 "Stub block should only have one outgoing edge");
65 auto &GOTBlock = StubBlock.edges().begin()->getTarget().getBlock();
66 assert(GOTBlock.getSize() ==
G.getPointerSize() &&
67 "GOT block should be pointer sized");
68 assert(GOTBlock.edges_size() == 1 &&
69 "GOT block should only have one outgoing edge");
71 auto &GOTTarget = GOTBlock.edges().begin()->getTarget();
75 int64_t Displacement = TargetAddr - EdgeAddr + 4;
76 if (isInt<32>(Displacement)) {
78 E.setTarget(GOTTarget);
80 dbgs() <<
" Replaced stub branch with direct branch:\n ";
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.
Represents an address in the executor process.
constexpr uint32_t PointerSize
i386 pointer size.
Error optimizeGOTAndStubAccesses(LinkGraph &G)
Optimize the GOT and Stub relocations if the edge target address is in range.
const char PointerJumpStubContent[6]
i386 pointer jump stub content.
@ BranchPCRel32ToPtrJumpStubBypassable
A relaxable version of BranchPCRel32ToPtrJumpStub.
@ Delta32FromGOT
A 32-bit GOT delta.
@ PCRel32
A 32-bit PC-relative relocation.
@ BranchPCRel32ToPtrJumpStub
A 32-bit PC-relative branch to a pointer jump stub.
@ PCRel16
A 16-bit PC-relative relocation.
@ RequestGOTAndTransformToDelta32FromGOT
A GOT entry offset within GOT getter/constructor, transformed to Delta32FromGOT pointing at the GOT e...
@ BranchPCRel32
A 32-bit PC-relative branch.
@ Pointer32
A plain 32-bit pointer value relocation.
@ Pointer16
A plain 16-bit pointer value relocation.
const char NullPointerContent[PointerSize]
i386 null pointer content.
const char * getEdgeKindName(Edge::Kind K)
Returns a string name for the given i386 edge.
const char * getGenericEdgeKindName(Edge::Kind K)
Returns the string name of the given generic edge kind, or "unknown" otherwise.
void printEdge(raw_ostream &OS, const Block &B, const Edge &E, StringRef EdgeKindName)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.