-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
runtime/jit-rt: revive and migrates the whole thing to OrcJIT v2 #4774
base: master
Are you sure you want to change the base?
Conversation
#include "llvm/IR/LegacyPassManager.h" | ||
#include "llvm/IR/Module.h" | ||
#include "llvm/IR/Verifier.h" | ||
//===-- optimizer.cpp -----------------------------------------------------===// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is copied almost verbatim from gen/optimizer.cpp
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can use a single file for both projects then, with a little predefine if needed.
Hehe, looks like one's motivated, nice! - In case you haven't seem them, there are quite a few lit-tests for this feature: https://github.com/ldc-developers/ldc/tree/master/tests/dynamiccompile. No idea if anything can still be salvaged from #3184, Ivan's WIP from 5 (!) years ago by now. |
I see. I did not know there was another pull request doing the same thing from 5 years ago. Now that I see they made very similar changes before, I realize I duplicated a fair amount of changes (but this seems like a form of cross-validation? Two independent implementations look very similar). |
Now, 100% of those LIT tests are passing (with LLVM 18). |
2c90767
to
bd2c4b5
Compare
Very nice progress! - I've pushed 2 commits to reduce the remaining failures on aarch64. |
465a543
to
8cbe0d1
Compare
@@ -28,7 +28,7 @@ void main(string[] args) | |||
settings.optLevel = 3; | |||
settings.dumpHandler = (DumpStage stage, in char[] str) | |||
{ | |||
if (DumpStage.FinalAsm == stage) | |||
if (DumpStage.FinalAsm == stage || DumpStage.OptimizedModule == stage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this doesn't just output the optimized IR now too in case the test fails, but also makes the indexOf
substring searches now also search in the IR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this doesn't just output the optimized IR now too in case the test fails, but also makes the
indexOf
substring searches now also search in the IR.
Yes, LLVM on arm64 uses very clever optimizations, and the constants do not appear in the assembly (because LLVM loads the constant into the register using bit shifts).
In my Windows VM, the tests don't hang as they do for CI (with a pushed Win32 fix wrt.
Looks like there's some trouble with the Edit: We do use |
I have tried to debug this problem on a Windows 11 installation with Visual Studio 2022 (Community Edition). |
60fedcc
to
36bd753
Compare
On Ubuntu 20.04 aarch64:
But it's still broken on macOS aarch64 unfortunately |
... currently only supports LLVM 18+ Co-Authored-By: Ivan <[email protected]>
To avoid Apple linker errors on arm64 wrt. misaligned pointers. AFAICT, there's no need to pack the struct, just use natural alignment. Bump the LDC_DYNAMIC_COMPILE_API_VERSION accordingly.
... LLVM can be very clever about loading values into registers on aarch64
Fix 'unresolved external symbol ___chkstk' by NOT letting LLVM add an implicit extra leading underscore - the final mangle is `__chkstk` on both 32/64-bit Windows.
It seems like I may have discovered several bugs in LLVM that are exclusive to Windows. I have currently worked around them because I am not entirely sure if they are "bugs" or "intended behaviors". |
... also adds a batched lookup function
... there seems to be some LLVM behavior issues on Windows, where looking up a symbol on the second time will crash either LLVM itself or corrupts the symbol address obtained from LLVM
... JITLink does not work very well for the code patterns generated by LDC
297af71
to
6662b46
Compare
f2266e0
to
b0606f7
Compare
This pull request migrates the dynamic compile system to LLVM OrcJIT v2 (the newer "v2" version from post-LLVM 16 with opaque pointers, not the older "v2" version from the LLVM 12 ~ 15 era).
The implementation is currently in very rough shape, and I am not entirely sure what I am doing. However, the "Hello World" example in the documentation has started to work now.