This is an archive of the discontinued LLVM Phabricator instance.

[ORC] Add lazy jit support for LoongArch64
ClosedPublic

Authored by wangleiat on Jan 5 2023, 5:12 PM.

Details

Summary

This patch adds resolver, indirection and trampoline stubs for
loongarch64, allowing lazy compilation to work.

It assumes hard float feature exists.

Depends on D141036

Diff Detail

Event Timeline

wangleiat created this revision.Jan 5 2023, 5:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2023, 5:12 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
wangleiat requested review of this revision.Jan 5 2023, 5:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2023, 5:12 PM
lhames accepted this revision.Jan 20 2023, 5:08 PM

LGTM. Thank you very much for your work on this!

Please try adding Loongarch as a supported architecture in llvm-project/llvm/test/ExecutionEngine/OrcLazy/lit.local.cfg and running the lazy-compilation regression tests from the built LLVM dir with ./bin/llvm-lit -v test/ExecutionEngine/OrcLazy. If they pass reliably then you could enable them in this patch (or a follow-up). If not then it may indicate areas for future work either in Loongarch support or in the LLVM JIT infrastructure itself.

This revision is now accepted and ready to land.Jan 20 2023, 5:08 PM

LGTM. Thank you very much for your work on this!

Please try adding Loongarch as a supported architecture in llvm-project/llvm/test/ExecutionEngine/OrcLazy/lit.local.cfg and running the lazy-compilation regression tests from the built LLVM dir with ./bin/llvm-lit -v test/ExecutionEngine/OrcLazy. If they pass reliably then you could enable them in this patch (or a follow-up). If not then it may indicate areas for future work either in Loongarch support or in the LLVM JIT infrastructure itself.

Thank you very much for your comments, I made the following modifications and running the lazy-compliation regression tests:

  1. Modify llvm-project/llvm/test/lit.cfg.py, and add floating-point features to the LoongArch backend (lli_args = ['-mattr=+d'], because the LoongArch backend does not add floating-point support by default, causing the frem.ll test to fail).
  2. Modify llvm-project/llvm/test/ExecutionEngine/lit.local.cfg to remove LoongArch from the unsupported list (because only modify OrcLazy/lit.local.cfg will not running the regression tests).
  3. Modify llvm-project/llvm/test/ExecutionEngine/OrcLazy/lit.local.cfg, and add loongarch64 to the supported list.

The test results are as follows:

[wanglei@localhost _build]$ ./bin/llvm-lit -v test/ExecutionEngine/OrcLazy                                                                                                                        
-- Testing: 23 tests, 23 workers --
UNSUPPORTED: LLVM :: ExecutionEngine/OrcLazy/minimal-throw-catch.ll (1 of 23)
UNSUPPORTED: LLVM :: ExecutionEngine/OrcLazy/debug-objects-elf-minimal.ll (2 of 23)
UNSUPPORTED: LLVM :: ExecutionEngine/OrcLazy/macho-universal-static-library-support.ll (3 of 23)
UNSUPPORTED: LLVM :: ExecutionEngine/OrcLazy/debug-descriptor-elf-minimal.ll (4 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/bad-object-file.ll (5 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/minimal.ll (6 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/global_aliases.ll (7 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/emulated-tls.ll (8 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/common-symbols.ll (9 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/private_linkage.ll (10 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/printargv.ll (11 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/single-function-call.ll (12 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/anonymous_globals.ll (13 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/weak-function.ll (14 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll (15 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/module-flags.ll (16 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/weak-non-materialization.ll (17 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/basic-object-file-loading.ll (18 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/basic-whole-module-partitions.ll (19 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/hidden-visibility.ll (20 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/static-initializers-in-objectfiles.ll (21 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/static-library-support.ll (22 of 23)
PASS: LLVM :: ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll (23 of 23)

Testing Time: 0.29s
  Unsupported:  4
  Passed     : 19

Due to the problem of not supporting floating-point features by default, I decided to turn on regression testing in subsequent patches.

This revision was landed with ongoing or failed builds.Jan 21 2023, 1:49 AM
This revision was automatically updated to reflect the committed changes.