forked from OSchip/llvm-project
[JITLink][x86-64] Rename *Relaxable edges to *REXRelaxable.
The existing relaxable edges all assume a REX prefix. ELF includes non-REX relaxations, so rename these edges to make room for the new kinds.
This commit is contained in:
parent
632135acae
commit
27ea3f1607
|
@ -221,7 +221,7 @@ enum EdgeKind_x86_64 : Edge::Kind {
|
|||
/// phase will result in an assert/unreachable during the fixup phase
|
||||
RequestGOTAndTransformToDelta64FromGOT,
|
||||
|
||||
/// A PC-relative reference to a GOT entry, relaxable if GOT entry target
|
||||
/// A PC-relative REX load of a GOT entry, relaxable if GOT entry target
|
||||
/// is in-range of the fixup.
|
||||
///
|
||||
/// If the GOT entry target is in-range of the fixup then the load from the
|
||||
|
@ -234,17 +234,18 @@ enum EdgeKind_x86_64 : Edge::Kind {
|
|||
/// - The result of the fixup expression must fit into an int32, otherwise
|
||||
/// an out-of-range error will be returned.
|
||||
///
|
||||
PCRel32GOTLoadRelaxable,
|
||||
PCRel32GOTLoadREXRelaxable,
|
||||
|
||||
/// A GOT entry getter/constructor, transformed to PCRel32ToGOTLoadRelaxable
|
||||
/// pointing at the GOT entry for the original target.
|
||||
/// A GOT entry getter/constructor, transformed to
|
||||
/// PCRel32ToGOTLoadREXRelaxable pointing at the GOT entry for the original
|
||||
/// target.
|
||||
///
|
||||
/// Indicates that this edge should be transformed into a
|
||||
/// PC32ToGOTLoadRelaxable targeting the GOT entry for the edge's current
|
||||
/// target, maintaining the same addend. A GOT entry for the target should be
|
||||
/// created if one does not already exist.
|
||||
/// Indicates that this edge should be lowered to a PC32ToGOTLoadREXRelaxable
|
||||
/// targeting the GOT entry for the edge's current target, maintaining the
|
||||
/// same addend. A GOT entry for the target should be created if one does not
|
||||
/// already exist.
|
||||
///
|
||||
/// Edges of this kind are usually handled by a GOT builder pass inserted by
|
||||
/// Edges of this kind are usually lowered by a GOT builder pass inserted by
|
||||
/// default.
|
||||
///
|
||||
/// Fixup expression:
|
||||
|
@ -254,12 +255,12 @@ enum EdgeKind_x86_64 : Edge::Kind {
|
|||
/// - *ASSERTION* Failure to handle edges of this kind prior to the fixup
|
||||
/// phase will result in an assert/unreachable during the fixup phase.
|
||||
///
|
||||
RequestGOTAndTransformToPCRel32GOTLoadRelaxable,
|
||||
RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable,
|
||||
|
||||
/// A PC-relative reference to a Thread Local Variable Pointer (TLVP) entry,
|
||||
/// A PC-relative REX load of a Thread Local Variable Pointer (TLVP) entry,
|
||||
/// relaxable if the TLVP entry target is in-range of the fixup.
|
||||
///
|
||||
/// If the TLVP entry target is in-range of the fixup then the load frmo the
|
||||
/// If the TLVP entry target is in-range of the fixup then the load from the
|
||||
/// TLVP may be replaced with a direct memory address calculation.
|
||||
///
|
||||
/// The target of this edge must be a thread local variable entry of the form
|
||||
|
@ -276,15 +277,15 @@ enum EdgeKind_x86_64 : Edge::Kind {
|
|||
/// - The target must be either external, or a TLV entry of the required
|
||||
/// form, otherwise a malformed TLV entry error will be returned.
|
||||
///
|
||||
PCRel32TLVPLoadRelaxable,
|
||||
PCRel32TLVPLoadREXRelaxable,
|
||||
|
||||
/// A TLVP entry getter/constructor, transformed to
|
||||
/// Delta32ToTLVPLoadRelaxable.
|
||||
/// Delta32ToTLVPLoadREXRelaxable.
|
||||
///
|
||||
/// Indicates that this edge should be transformed into a
|
||||
/// Delta32ToTLVPLoadRelaxable targeting the TLVP entry for the edge's current
|
||||
/// target. A TLVP entry for the target should be created if one does not
|
||||
/// already exist.
|
||||
/// Delta32ToTLVPLoadREXRelaxable targeting the TLVP entry for the edge's
|
||||
/// current target. A TLVP entry for the target should be created if one does
|
||||
/// not already exist.
|
||||
///
|
||||
/// Fixup expression:
|
||||
/// NONE
|
||||
|
@ -293,7 +294,7 @@ enum EdgeKind_x86_64 : Edge::Kind {
|
|||
/// - *ASSERTION* Failure to handle edges of this kind prior to the fixup
|
||||
/// phase will result in an assert/unreachable during the fixup phase.
|
||||
///
|
||||
RequestTLVPAndTransformToPCRel32TLVPLoadRelaxable
|
||||
RequestTLVPAndTransformToPCRel32TLVPLoadREXRelaxable
|
||||
};
|
||||
|
||||
/// Returns a string name for the given x86-64 edge. For debugging purposes
|
||||
|
@ -340,8 +341,8 @@ inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E,
|
|||
case BranchPCRel32:
|
||||
case BranchPCRel32ToPtrJumpStub:
|
||||
case BranchPCRel32ToPtrJumpStubBypassable:
|
||||
case PCRel32GOTLoadRelaxable:
|
||||
case PCRel32TLVPLoadRelaxable: {
|
||||
case PCRel32GOTLoadREXRelaxable:
|
||||
case PCRel32TLVPLoadREXRelaxable: {
|
||||
int64_t Value =
|
||||
E.getTarget().getAddress() - (FixupAddress + 4) + E.getAddend();
|
||||
if (LLVM_LIKELY(isInRangeForImmS32(Value)))
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
return E.getKind() == x86_64::RequestGOTAndTransformToDelta32 ||
|
||||
E.getKind() == x86_64::RequestGOTAndTransformToDelta64 ||
|
||||
E.getKind() ==
|
||||
x86_64::RequestGOTAndTransformToPCRel32GOTLoadRelaxable ||
|
||||
x86_64::RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable ||
|
||||
E.getKind() == x86_64::RequestGOTAndTransformToDelta64FromGOT;
|
||||
}
|
||||
|
||||
|
@ -71,8 +71,8 @@ public:
|
|||
// optimizeMachO_x86_64_GOTAndStubs pass below.
|
||||
// If it's a GOT64 leave it as is.
|
||||
switch (E.getKind()) {
|
||||
case x86_64::RequestGOTAndTransformToPCRel32GOTLoadRelaxable:
|
||||
E.setKind(x86_64::PCRel32GOTLoadRelaxable);
|
||||
case x86_64::RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable:
|
||||
E.setKind(x86_64::PCRel32GOTLoadREXRelaxable);
|
||||
break;
|
||||
case x86_64::RequestGOTAndTransformToDelta64:
|
||||
E.setKind(x86_64::Delta64);
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
void fixPLTEdge(Edge &E, Symbol &Stub) {
|
||||
assert(E.getKind() == x86_64::BranchPCRel32 && "Not a Branch32 edge?");
|
||||
|
||||
// Set the edge kind to Branch32ToPtrJumpStubRelaxable to enable it to be
|
||||
// Set the edge kind to Branch32ToPtrJumpStubBypassable to enable it to be
|
||||
// optimized when the target is in-range.
|
||||
E.setKind(x86_64::BranchPCRel32ToPtrJumpStubBypassable);
|
||||
E.setTarget(Stub);
|
||||
|
@ -154,7 +154,7 @@ static Error optimizeELF_x86_64_GOTAndStubs(LinkGraph &G) {
|
|||
|
||||
for (auto *B : G.blocks())
|
||||
for (auto &E : B->edges())
|
||||
if (E.getKind() == x86_64::PCRel32GOTLoadRelaxable) {
|
||||
if (E.getKind() == x86_64::PCRel32GOTLoadREXRelaxable) {
|
||||
// Replace GOT load with LEA only for MOVQ instructions.
|
||||
constexpr uint8_t MOVQRIPRel[] = {0x48, 0x8b};
|
||||
if (E.getOffset() < 3 ||
|
||||
|
@ -371,7 +371,7 @@ private:
|
|||
Kind = x86_64::Pointer64;
|
||||
break;
|
||||
case PCRel32GOTLoad: {
|
||||
Kind = x86_64::RequestGOTAndTransformToPCRel32GOTLoadRelaxable;
|
||||
Kind = x86_64::RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable;
|
||||
Addend = 0;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -300,7 +300,7 @@ private:
|
|||
else
|
||||
return TargetSymbolOrErr.takeError();
|
||||
Addend = *(const little32_t *)FixupContent;
|
||||
Kind = x86_64::RequestGOTAndTransformToPCRel32GOTLoadRelaxable;
|
||||
Kind = x86_64::RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable;
|
||||
if (FixupOffset < 3)
|
||||
return make_error<JITLinkError>("GOTLD at invalid offset " +
|
||||
formatv("{0}", FixupOffset));
|
||||
|
@ -319,7 +319,10 @@ private:
|
|||
else
|
||||
return TargetSymbolOrErr.takeError();
|
||||
Addend = *(const little32_t *)FixupContent;
|
||||
Kind = x86_64::RequestTLVPAndTransformToPCRel32TLVPLoadRelaxable;
|
||||
Kind = x86_64::RequestTLVPAndTransformToPCRel32TLVPLoadREXRelaxable;
|
||||
if (FixupOffset < 3)
|
||||
return make_error<JITLinkError>("TLV at invalid offset " +
|
||||
formatv("{0}", FixupOffset));
|
||||
break;
|
||||
case MachOPointer32:
|
||||
if (auto TargetSymbolOrErr = findSymbolByIndex(RI.r_symbolnum))
|
||||
|
@ -429,7 +432,7 @@ public:
|
|||
bool isGOTEdgeToFix(Edge &E) const {
|
||||
return E.getKind() == x86_64::RequestGOTAndTransformToDelta32 ||
|
||||
E.getKind() ==
|
||||
x86_64::RequestGOTAndTransformToPCRel32GOTLoadRelaxable;
|
||||
x86_64::RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable;
|
||||
}
|
||||
|
||||
Symbol &createGOTEntry(Symbol &Target) {
|
||||
|
@ -442,8 +445,8 @@ public:
|
|||
case x86_64::RequestGOTAndTransformToDelta32:
|
||||
E.setKind(x86_64::Delta32);
|
||||
break;
|
||||
case x86_64::RequestGOTAndTransformToPCRel32GOTLoadRelaxable:
|
||||
E.setKind(x86_64::PCRel32GOTLoadRelaxable);
|
||||
case x86_64::RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable:
|
||||
E.setKind(x86_64::PCRel32GOTLoadREXRelaxable);
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("Not a GOT transform edge");
|
||||
|
@ -500,7 +503,7 @@ static Error optimizeMachO_x86_64_GOTAndStubs(LinkGraph &G) {
|
|||
|
||||
for (auto *B : G.blocks())
|
||||
for (auto &E : B->edges())
|
||||
if (E.getKind() == x86_64::PCRel32GOTLoadRelaxable) {
|
||||
if (E.getKind() == x86_64::PCRel32GOTLoadREXRelaxable) {
|
||||
assert(E.getOffset() >= 3 && "GOT edge occurs too early in block");
|
||||
|
||||
// Optimize GOT references.
|
||||
|
|
|
@ -46,14 +46,14 @@ const char *getEdgeKindName(Edge::Kind K) {
|
|||
return "RequestGOTAndTransformToDelta64";
|
||||
case RequestGOTAndTransformToDelta64FromGOT:
|
||||
return "RequestGOTAndTransformToDelta64FromGOT";
|
||||
case PCRel32GOTLoadRelaxable:
|
||||
return "PCRel32GOTLoadRelaxable";
|
||||
case RequestGOTAndTransformToPCRel32GOTLoadRelaxable:
|
||||
return "RequestGOTAndTransformToPCRel32GOTLoadRelaxable";
|
||||
case PCRel32TLVPLoadRelaxable:
|
||||
return "PCRel32TLVPLoadRelaxable";
|
||||
case RequestTLVPAndTransformToPCRel32TLVPLoadRelaxable:
|
||||
return "RequestTLVPAndTransformToPCRel32TLVPLoadRelaxable";
|
||||
case PCRel32GOTLoadREXRelaxable:
|
||||
return "PCRel32GOTLoadREXRelaxable";
|
||||
case RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable:
|
||||
return "RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable";
|
||||
case PCRel32TLVPLoadREXRelaxable:
|
||||
return "PCRel32TLVPLoadREXRelaxable";
|
||||
case RequestTLVPAndTransformToPCRel32TLVPLoadREXRelaxable:
|
||||
return "RequestTLVPAndTransformToPCRel32TLVPLoadREXRelaxable";
|
||||
default:
|
||||
return getGenericEdgeKindName(static_cast<Edge::Kind>(K));
|
||||
}
|
||||
|
|
|
@ -950,9 +950,9 @@ Error MachOPlatform::MachOPlatformPlugin::fixTLVSectionsAndEdges(
|
|||
for (auto *B : G.blocks())
|
||||
for (auto &E : B->edges())
|
||||
if (E.getKind() ==
|
||||
jitlink::x86_64::RequestTLVPAndTransformToPCRel32TLVPLoadRelaxable)
|
||||
E.setKind(
|
||||
jitlink::x86_64::RequestGOTAndTransformToPCRel32GOTLoadRelaxable);
|
||||
jitlink::x86_64::RequestTLVPAndTransformToPCRel32TLVPLoadREXRelaxable)
|
||||
E.setKind(jitlink::x86_64::
|
||||
RequestGOTAndTransformToPCRel32GOTLoadREXRelaxable);
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue