Skip to content

[Orc] Let LLJIT default to JITLink for ELF-based ARM targets #77313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2024

Conversation

weliveindetail
Copy link
Member

@weliveindetail weliveindetail commented Jan 8, 2024

Over the last weeks, I have landed a number of patches to JITLink's AArch32 backend to reach feature-parity with RuntimeDyld for ELF:

9577806b1e6c [JITLink][AArch32] Implement R_ARM_PREL31 and process .ARM.exidx sections (#79044)
e5ca202ef887 [JITLink][AArch32] Multi-stub support for armv7/thumbv7 (#78371)
2bb6d7b8a4d1 [clang-repl] Limit use of PLT offset flag to linkers that support it
565470ed2713 [JITLink][AArch32] Implement ELF relocation R_ARM_NONE
bfb09326be22 [JITLink][AArch32] Implement ELF relocation R_ARM_TARGET1
4821c90c24d5 [clang-repl] Fix PLT offset too large linker error on ARM (#78959)
c4fc563b8d41 [JITLink][AArch32] Add GOT builder and implement R_ARM_GOT_PREL relocations for ELF (#78753)
6a433d77b1f4 [llvm-jitlink] Allow optional stub-kind filter in stub_addr() expressions (#78369)
01ba627f431c [llvm-jitlink] Refactor GOT and stubs registration (NFC) (#78365)
9c607e77eae7 [JITLink][AArch32] Refactor StubsManager (NFC)

This allows us to run clang-repl on armv7 and use all the features we had with RuntimeDyld before. All existing tests for clang-repl are passing.

Copy link

github-actions bot commented Jan 15, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@weliveindetail
Copy link
Member Author

There is one more review open that aims to extend support to non-v7 targets: #79082

@weliveindetail weliveindetail marked this pull request as ready for review January 23, 2024 02:55
@weliveindetail weliveindetail changed the title [Draft] Basic JITLink AArch32 support for clang-repl [Orc] Let LLJIT default to JITLink for ELF-based ARM targets Jan 23, 2024
@vgvassilev
Copy link
Contributor

Pretty nice! This lgtm but I’d wait for Lang.

@weliveindetail
Copy link
Member Author

Double-checked on armv7 (32-bit Raspbian on RPi 3b) with all commits landed:

$ cat CMakeCache.txt | grep HOST_TRIPLE
LLVM_HOST_TRIPLE:STRING=arm-linux-gnueabihf

Tests run fine:

$ bin/llvm-lit --filter=Interpreter tools/clang/test
-- Testing: 22 of 18430 tests, 4 workers --
PASS: Clang :: Interpreter/execute-stmts.cpp (1 of 22)
PASS: Clang :: Interpreter/inline-virtual.cpp (2 of 22)
PASS: Clang :: Interpreter/execute.cpp (3 of 22)
PASS: Clang :: Interpreter/const.cpp (4 of 22)
PASS: Clang :: Interpreter/multiline.cpp (5 of 22)
PASS: Clang :: Interpreter/code-undo.cpp (6 of 22)
PASS: Clang :: Interpreter/global-dtor.cpp (7 of 22)
PASS: Clang :: Interpreter/lambda.cpp (8 of 22)
PASS: Clang :: Interpreter/execute-weak.cpp (9 of 22)
XFAIL: Clang :: Interpreter/simple-exception.cpp (10 of 22)
PASS: Clang :: Interpreter/disambiguate-decl-stmt.cpp (11 of 22)
PASS: Clang :: Interpreter/sanity.c (12 of 22)
UNSUPPORTED: Clang :: Interpreter/plugins.cpp (13 of 22)
UNSUPPORTED: Clang :: Interpreter/dynamic-library.cpp (14 of 22)
UNSUPPORTED: Clang :: Interpreter/CUDA/device-function-template.cu (15 of 22)
UNSUPPORTED: Clang :: Interpreter/CUDA/host-and-device.cu (16 of 22)
UNSUPPORTED: Clang :: Interpreter/CUDA/sanity.cu (17 of 22)
UNSUPPORTED: Clang :: Interpreter/CUDA/device-function.cu (18 of 22)
UNSUPPORTED: Clang :: Interpreter/CUDA/memory.cu (19 of 22)
PASS: Clang :: Interpreter/fail.cpp (20 of 22)
PASS: Clang :: Interpreter/stmt-serialization.cpp (21 of 22)
PASS: Clang :: Interpreter/incremental-mode.cpp (22 of 22)

Testing Time: 15.51s

Total Discovered Tests: 18430
  Excluded         : 18408 (99.88%)
  Unsupported      :     7 (0.04%)
  Passed           :    14 (0.08%)
  Expectedly Failed:     1 (0.01%)

1 warning(s) in tests

This is using JITLink::

$ cat ../clang/test/Interpreter/inline-virtual.cpp | bin/clang-repl -Xcc -fno-rtti --debug-only=jitlink 2>&1 | grep aarch32 | head -3
    Created Arm entry for __cxa_begin_catch in __llvm_jitlink_aarch32_STUBS_v7: 0x0 (block + 0x00000000): size: 0x0000000c, linkage: strong, scope: local, dead  -   <anonymous symbol>
    Using Arm entry 0x0 (block + 0x00000000): size: 0x0000000c, linkage: strong, scope: local, dead  -   <anonymous symbol> in __llvm_jitlink_aarch32_STUBS_v7
    Created Arm entry for _ZSt9terminatev in __llvm_jitlink_aarch32_STUBS_v7: 0x0 (block + 0x00000000): size: 0x0000000c, linkage: strong, scope: local, dead  -   <anonymous symbol>

@weliveindetail
Copy link
Member Author

Test working as well with armv6 target:

$ bin/llvm-lit --filter=Interpreter tools/clang/test
-- Testing: 22 of 18430 tests, 4 workers --
PASS: Clang :: Interpreter/lambda.cpp (1 of 22)
PASS: Clang :: Interpreter/execute-stmts.cpp (2 of 22)
PASS: Clang :: Interpreter/execute.cpp (3 of 22)
PASS: Clang :: Interpreter/const.cpp (4 of 22)
PASS: Clang :: Interpreter/fail.cpp (5 of 22)
PASS: Clang :: Interpreter/execute-weak.cpp (6 of 22)
PASS: Clang :: Interpreter/code-undo.cpp (7 of 22)
XFAIL: Clang :: Interpreter/simple-exception.cpp (8 of 22)
PASS: Clang :: Interpreter/global-dtor.cpp (9 of 22)
PASS: Clang :: Interpreter/inline-virtual.cpp (10 of 22)
PASS: Clang :: Interpreter/disambiguate-decl-stmt.cpp (11 of 22)
PASS: Clang :: Interpreter/stmt-serialization.cpp (12 of 22)
UNSUPPORTED: Clang :: Interpreter/dynamic-library.cpp (13 of 22)
UNSUPPORTED: Clang :: Interpreter/plugins.cpp (14 of 22)
UNSUPPORTED: Clang :: Interpreter/CUDA/device-function.cu (15 of 22)
UNSUPPORTED: Clang :: Interpreter/CUDA/memory.cu (16 of 22)
UNSUPPORTED: Clang :: Interpreter/CUDA/device-function-template.cu (17 of 22)
UNSUPPORTED: Clang :: Interpreter/CUDA/sanity.cu (18 of 22)
UNSUPPORTED: Clang :: Interpreter/CUDA/host-and-device.cu (19 of 22)
PASS: Clang :: Interpreter/multiline.cpp (20 of 22)
PASS: Clang :: Interpreter/incremental-mode.cpp (21 of 22)
PASS: Clang :: Interpreter/sanity.c (22 of 22)

Testing Time: 22.43s

Total Discovered Tests: 18430
  Excluded         : 18408 (99.88%)
  Unsupported      :     7 (0.04%)
  Passed           :    14 (0.08%)
  Expectedly Failed:     1 (0.01%)

1 warning(s) in tests

This is using the pre-v7 config:

$ cat ../clang/test/Interpreter/inline-virtual.cpp | bin/clang-repl -Xcc -fno-rtti --debug-only=jitlink 2>&1 | grep aarch32 | head -3
    Created __llvm_jitlink_aarch32_STUBS_prev7 entry for __cxa_begin_catch: 0x0 (block + 0x00000000): size: 0x00000008, linkage: strong, scope: local, dead  -   <anonymous symbol>
    Using __llvm_jitlink_aarch32_STUBS_prev7 entry 0x0 (block + 0x00000000): size: 0x00000008, linkage: strong, scope: local, dead  -   <anonymous symbol>
    Created __llvm_jitlink_aarch32_STUBS_prev7 entry for _ZSt9terminatev: 0x0 (block + 0x00000000): size: 0x00000008, linkage: strong, scope: local, dead  -   <anonymous symbol>

Copy link
Contributor

@lhames lhames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This is a really impressive result for the JITLink ELF/AArch32 backend -- thanks for all of your hard work on it @weliveindetail and @eymay!

@weliveindetail weliveindetail merged commit e4f0829 into llvm:main Jan 23, 2024
@weliveindetail
Copy link
Member Author

Thanks for all the help with the reviews. I will keep an eye on the build bots and follow up with any potential issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants