This is an archive of the discontinued LLVM Phabricator instance.

[JITLink] Update ELF_x86_64 's edge kind to generic edge kind
ClosedPublic

Authored by StephenFan on Aug 12 2021, 8:32 AM.

Details

Summary

This patch uses a switch statement to map the ELF_x86_64's edge kind to generic edge kind, and merge the ELF_x86_64 's applyFixup function to the x86_64 's applyFixup function. Some edge kinds were not have corresponding generic edge kinds, so I added three generic edge kinds asa follows:

  1. RequestGOTAndTransformToDelta64, which is similar to RequestGOTAndTransformToDelta32.
  1. GOTDelta64. This generic kind is similar to Delta64, except the GOTDelta64 computes the delta relative to GOTSymbol
  1. RequestGOTAndTransformToGOTDelta64. This edge kind was used to deal with ELF_x86_64's GOT64 edge kind, it request the fixGOTEdge function to change the target to GOT entry, and set the edge kind to generic edge kind GOTDelta64.

These added generic edge kinds may named haphazardly, or can't express its meaning well.

Diff Detail

Event Timeline

StephenFan created this revision.Aug 12 2021, 8:32 AM
StephenFan requested review of this revision.Aug 12 2021, 8:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2021, 8:32 AM
StephenFan added inline comments.Aug 12 2021, 8:39 AM
llvm/include/llvm/ExecutionEngine/JITLink/ELF_x86_64.h
24

These edge kinds was not used, and can't find the corresponding tests, so I deleted these. If it is not suitable to delete these, please tell me and I will revert it/

lhames accepted this revision.Aug 12 2021, 4:54 PM

Thanks very much Stephen! Having this uniform architecture support in place for the x86-64 backend is a big step forward for JITLink. E.g. once this lands we can unify optimizeELF_x86_64_GOTAndStubs and optimizeMachO_x86_64_GOTAndStubs into a pure optimize_x86_64_GOTAndStubs function. :)

Could you change GOTDelta64 to Delta64FromGOT. The name is clunkier, but it makes it clear which way the delta goes.

Otherwise this looks good to me -- please land whenever you're ready.

llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
375–376

getELFX86RelocationKindName should be replaced with x86_64::getEdgeKindName here, since graph edges will now use the generic kinds.

This revision is now accepted and ready to land.Aug 12 2021, 4:54 PM
  1. Replace GOTDelta64 to Delta64FromGOT
  2. Make LinkGraph use a generic edge kind name getter function

LGTM. Thanks Stephen!