This is an archive of the discontinued LLVM Phabricator instance.

[JITLink] Add initial Aarch64 support
ClosedPublic

Authored by sgraenitz on Aug 31 2021, 4:57 AM.

Details

Summary

Set up basic infrastructure for 64-bit ARM architecture support in JITLink. It allows for loading a minimal object file and resolving a single relocation. Advanced features like GOT and PLT handling or relaxations were intentionally left out for the moment.

This patch follows the idea to keep implementations for ARM (32-bit) and Aaarch64 (64-bit) separate, because:

  • it might be easier to share code with the MachO "arm64" JITLink backend
  • LLVM has individual targets for ARM and Aaarch64 as well

Diff Detail

Event Timeline

sgraenitz created this revision.Aug 31 2021, 4:57 AM
sgraenitz requested review of this revision.Aug 31 2021, 4:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2021, 4:57 AM
sgraenitz edited the summary of this revision. (Show Details)Aug 31 2021, 5:09 AM
sgraenitz added reviewers: StephenFan, MaskRay.

This is an early draft and it will require polishing here and there. Please don't hesitate to propose improvements.

sgraenitz updated this revision to Diff 369688.Aug 31 2021, 6:12 AM

Basic polishing

lhames accepted this revision.Sep 1 2021, 4:48 PM

This looks great to me. Thank you very much Stefan!

This patch follows the idea to keep implementations for ARM (32-bit) and Aaarch64 (64-bit) separate, because:
it might be easier to share code with the MachO "arm64" JITLink backend
LLVM has individual targets for ARM and Aaarch64 as well

Yes -- This is the right approach. We'll want to unify the AArch64 edge set the same way that we did for x86-64.

llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
89–99

There is a lot of redundancy in these addRelocations functions. Do you think we could add a generic function (or functions) to the ELFLinkGraphBuilder so that clients can just write:

for_all_relas([](const Rela &R) {
  // Handle rela
});

?

I don't think this is something that we should do for this review, but it should be done either before or after it lands so that future backends don't keep copying this code.

This revision is now accepted and ready to land.Sep 1 2021, 4:48 PM
sgraenitz added inline comments.Sep 3 2021, 1:51 AM
llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp
89–99

Yes, I agree. Shouldn't be too much effort. I will post something soon.

This revision was landed with ongoing or failed builds.Sep 3 2021, 1:52 AM
This revision was automatically updated to reflect the committed changes.