15#define DEBUG_TYPE "jitlink"
32 return "Delta32FromGOT";
34 return "RequestGOTAndTransformToDelta32FromGOT";
36 return "BranchPCRel32";
38 return "BranchPCRel32ToPtrJumpStub";
40 return "BranchPCRel32ToPtrJumpStubBypassable";
49 static_cast<char>(0xFFu), 0x25, 0x00, 0x00, 0x00, 0x00};
54 for (
auto *
B :
G.blocks())
55 for (
auto &
E :
B->edges()) {
57 auto &StubBlock =
E.getTarget().getBlock();
59 "Stub block should be stub sized");
60 assert(StubBlock.edges_size() == 1 &&
61 "Stub block should only have one outgoing edge");
63 auto &GOTBlock = StubBlock.edges().begin()->getTarget().getBlock();
64 assert(GOTBlock.getSize() ==
G.getPointerSize() &&
65 "GOT block should be pointer sized");
66 assert(GOTBlock.edges_size() == 1 &&
67 "GOT block should only have one outgoing edge");
69 auto &GOTTarget = GOTBlock.edges().begin()->getTarget();
73 int64_t Displacement = TargetAddr - EdgeAddr + 4;
74 if (isInt<32>(Displacement)) {
76 E.setTarget(GOTTarget);
78 dbgs() <<
" Replaced stub branch with direct branch:\n ";
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Represents an address in the executor process.
@ BranchPCRel32ToPtrJumpStubBypassable
A relaxable version of BranchPCRel32ToPtrJumpStub.
@ RequestGOTAndTransformToDelta32FromGOT
A GOT entry offset within GOT getter/constructor, transformed to Delta32FromGOT pointing at the GOT e...
@ Pointer16
A plain 16-bit pointer value relocation.
@ BranchPCRel32
A 32-bit PC-relative branch.
@ PCRel32
A 32-bit PC-relative relocation.
@ PCRel16
A 16-bit PC-relative relocation.
@ BranchPCRel32ToPtrJumpStub
A 32-bit PC-relative branch to a pointer jump stub.
@ Pointer32
A plain 32-bit pointer value relocation.
@ Delta32FromGOT
A 32-bit GOT delta.
LLVM_ABI const char NullPointerContent[PointerSize]
x86 null pointer content.
LLVM_ABI const char * getEdgeKindName(Edge::Kind K)
Returns a string name for the given x86 edge.
LLVM_ABI Error optimizeGOTAndStubAccesses(LinkGraph &G)
Optimize the GOT and Stub relocations if the edge target address is in range.
constexpr uint32_t PointerSize
x86 pointer size.
LLVM_ABI const char PointerJumpStubContent[6]
x86 pointer jump stub content.
LLVM_ABI const char * getGenericEdgeKindName(Edge::Kind K)
Returns the string name of the given generic edge kind, or "unknown" otherwise.
LLVM_ABI void printEdge(raw_ostream &OS, const Block &B, const Edge &E, StringRef EdgeKindName)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.