LLVM: lib/ExecutionEngine/JITLink/x86.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
14
15#define DEBUG_TYPE "jitlink"
16
18
20 switch (K) {
22 return "Pointer32";
24 return "PCRel32";
26 return "Pointer16";
28 return "PCRel16";
30 return "Delta32";
32 return "Delta32FromGOT";
34 return "RequestGOTAndTransformToDelta32FromGOT";
36 return "BranchPCRel32";
38 return "BranchPCRel32ToPtrJumpStub";
40 return "BranchPCRel32ToPtrJumpStubBypassable";
41 }
42
44}
45
47
49 static_cast<char>(0xFFu), 0x25, 0x00, 0x00, 0x00, 0x00};
50
52 LLVM_DEBUG(dbgs() << "Optimizing GOT entries and stubs:\n");
53
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");
62
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");
68
69 auto &GOTTarget = GOTBlock.edges().begin()->getTarget();
72
73 int64_t Displacement = TargetAddr - EdgeAddr + 4;
76 E.setTarget(GOTTarget);
78 dbgs() << " Replaced stub branch with direct branch:\n ";
80 dbgs() << "\n";
81 });
82 }
83 }
84 }
85
87}
88
89}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-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.
Definition x86.cpp:46
LLVM_ABI const char * getEdgeKindName(Edge::Kind K)
Returns a string name for the given x86 edge.
Definition x86.cpp:19
LLVM_ABI Error optimizeGOTAndStubAccesses(LinkGraph &G)
Optimize the GOT and Stub relocations if the edge target address is in range.
Definition x86.cpp:51
constexpr uint32_t PointerSize
x86 pointer size.
LLVM_ABI const char PointerJumpStubContent[6]
x86 pointer jump stub content.
Definition x86.cpp:48
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)
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.