This is an archive of the discontinued LLVM Phabricator instance.

[JITLink] Add an initial implementation of JITLink for ELF/LoongArch
ClosedPublic

Authored by wangleiat on Jan 5 2023, 1:01 AM.

Details

Summary

This implementation supports basic relocation types and adds EHFrame,
Got/Plt handling passes.
This patch also enables JIT support for LoongArch64.

With this patch, I successfully run hello.ll and simple_throw.ll
(which is generated from test-suite/SingleSource/Regression/C++/EH/simple_throw.cpp)
using the lli command with options --jit-kind=orc --jit-linker=jitlink.

Note: hasJIT property of LoongArch32 remains false as there is no
validation environment.

Diff Detail

Event Timeline

wangleiat created this revision.Jan 5 2023, 1:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2023, 1:01 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
wangleiat requested review of this revision.Jan 5 2023, 1:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2023, 1:01 AM
wangleiat updated this revision to Diff 486500.Jan 5 2023, 1:45 AM

remove incorrect comment.

wangleiat updated this revision to Diff 486528.Jan 5 2023, 4:54 AM

remove ELF_loongarch32_ehframe.s test which is duplicate of ELF_loongarch64_ehframe.s.

lhames accepted this revision.Jan 16 2023, 10:28 PM

I can't speak to the architecture specific details as I don't know Loongarch, but if the tests are passing this looks excellent to me -- The layout and style fits very well with the existing backends.

Do you have commit access?

llvm/lib/ExecutionEngine/JITLink/ELF.cpp
93–94

Looks like the new backend will handle both loongarch32 and loongarch64. Are there any differences at the linker level?

This revision is now accepted and ready to land.Jan 16 2023, 10:28 PM

I can't speak to the architecture specific details as I don't know Loongarch, but if the tests are passing this looks excellent to me -- The layout and style fits very well with the existing backends.

Do you have commit access?

Yes, I have. Thank you very much for your comments.

llvm/lib/ExecutionEngine/JITLink/ELF.cpp
93–94

They are no different, loongarch32's relocation type is a subset of loongarch64.

The architecture-specific details LGTM, thanks! A couple of nits below.

llvm/include/llvm/ExecutionEngine/JITLink/loongarch.h
273

nit: $t8 for better readability

llvm/lib/Target/LoongArch/TargetInfo/LoongArchTargetInfo.cpp
24

Why not adjust this too?

wangleiat added inline comments.Jan 17 2023, 1:22 AM
llvm/include/llvm/ExecutionEngine/JITLink/loongarch.h
273

nit: $t8 for better readability

Thanks.

llvm/lib/Target/LoongArch/TargetInfo/LoongArchTargetInfo.cpp
24

Why not adjust this too?

Although both loongarch32 and loongarch64 are processed in the code, I don't have a real environment to verify loongarch32, so I conservatively set loongarch32 to false here.

wangleiat updated this revision to Diff 489733.EditedJan 17 2023, 1:25 AM

Address @xen0n's comments and rebase.

This revision was landed with ongoing or failed builds.Jan 17 2023, 10:30 PM
This revision was automatically updated to reflect the committed changes.