-
Notifications
You must be signed in to change notification settings - Fork 997
LLVM 15 #3189
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
LLVM 15 #3189
Conversation
870c36a to
66585b7
Compare
|
Ready for review. There seems to be an issue with MacOS which I'll need to fix but This will switch to LLVM 15 by default when using I verified that even with these rather extensive changes, LLVM 14 builds produce the same binaries as before (tested using the drivers repo smoke tests - the only exceptions were AVR and Xtensa that currently unintentionally embed the TinyGo version in the binaries). @QuLogic I think this is relevant for you. |
7e110f1 to
721414f
Compare
d6a3866 to
2a4d195
Compare
|
Thanks for the heads-up. I tried backporting to 0.25.0, but that crashed in |
|
@QuLogic unfortunately this PR isn't ready yet, I hit a difficult bug that I need to fix before this PR becomes usable (hence why I've marked it as a draft). Most code works, I think it's only wasm that fails. But I wouldn't suggest using this patch in Fedora because TinyGo is very often used for wasm. |
|
Seems like there's still a SIGSEGV in |
|
Yeah, I also found it with some more testing. I hope I've now fixed all memory corruption bugs - at least, it doesn't complain anymore in my last tests with AddressSanitizer enabled. |
|
Nevermind, |
|
Next try. That last bug was particularly gnarly but should be fixed with #3230 (also included in this PR). |
|
Good work; it works for me backported to 0.26.0 so far. |
|
Interestingly, it appears that the Itsybitsy-M4 I2C tests are failing with this PR. I retried several times which all failed. Other recent PRs are all passing, and |
|
I can reproduce this issue locally on the ItsyBitsy M4 (after I pulled that little board out of a project...). So I'm afraid that's yet another bug to fix... |
|
For some reason, waiting for the |
|
Update: I haven't figured out the root cause here, but I did find that when I connect the MPU6050 directly to a 3.3V output the 2nd test that was failing will pass. Perhaps the underlying issue is a power issue? After all, these pins can supply only 2mA with the default configuration (see table 54-15 in the datasheet). This could be fixed with a MOSFET, for example. No idea why the LLVM 15 update would cause it to fail though. |
|
There has to be some explanation related to software, but it is certainly not obvious what it would be. Perhaps you can bring out your debugger to see if you can notice anything interesting. |
|
I modified the TinyHCI test a little bit to show the error message coming from powerpin.High()
time.Sleep(100 * time.Millisecond)
- accel.Configure()
+ err := accel.Configure()
+ if err != nil {
+ printtestresult(err.Error())
+ return
+ }
time.Sleep(100 * time.Millisecond)
if !accel.Connected() {This results in the following test result in the dev branch (with LLVM 14!): Most test fail and that is to be expected because I only have the mpu6050 connected, but the important part here is |
|
With some more testing, I found:
This one line fix is the following: // turn on power and should be connected now
powerpin.High()
time.Sleep(100 * time.Millisecond)
+ machine.I2C0.Configure(machine.I2CConfig{})
So my best theory now is that the samd51I2C peripheral gets confused when the mpu6050 powers up but in practice it just barely worked (and we didn't see a rather important error message). Now with LLVM 15, some timing has changed making it more likely that this bug presents itself in practice. The I2C peripheral can be un-confused (reset) by reconfiguring it. The full patch is the following: @@ -268,8 +269,13 @@ func i2cConnection() {
// turn on power and should be connected now
powerpin.High()
time.Sleep(100 * time.Millisecond)
+ machine.I2C0.Configure(machine.I2CConfig{})
- accel.Configure()
+ err := accel.Configure()
+ if err != nil {
+ printtestresult(err.Error())
+ return
+ }
time.Sleep(100 * time.Millisecond)
if !accel.Connected() { |
|
Update PR for TinyHCIL tinygo-org/tinyhci#7 Running that branch, the ItsyBitsy-M4 tests now pass. |
|
Awesome! This has been the most difficult LLVM update, by far. Hopefully nothing else breaks with this update. |
|
I had to make one last change to get |
|
I found that the equivalent of |
This is necessary for opaque pointer support (in LLVM 15).
This uses LLVMBuildCall2 in the background, which is the replacement for the deprecated LLVMBuildCall function.
This is needed for LLVM 15.
This is necessary for LLVM 15.
A number of llvm.Const* functions (in particular extractvalue and insertvalue) were removed in LLVM 15, so we have to use a builder instead. This builder will create the same constant values, it simply uses a different API.
Previously it was a pointer type, which won't work with opaque pointers. Instead, use the global initializer type instead.
This is needed for opaque pointers, which are enabled by default in LLVM 15.
There was a bug in the wasm ABI lowering pass (found using AddressSanitizer on LLVM 15) that resulted in a rather subtle memory corruption. This commit fixes this issues.
This flag is necessary in LLVM 15 because it appears that LLVM 15 has changed the default target ABI from lp64 to lp64d. This results in a linker failure. Setting the "target-abi" forces the RISC-V backend to use the intended target ABI.
These instructions sometimes pop up in LLVM 15, but they never occured in LLVM 14. Implementing them is relatively straightforward: simply generalize the code that already exists for llvm.ICmp interpreting.
This commit switches to LLVM 15 everywhere by default, while still keeping LLVM 14 support.
|
Rebased to fix merge conflict after #3230 was merged. |
|
Anyway, this is about as ready as it gets. I can perhaps move some commits into separate PRs but other than that it's simply just a massive PR, not much I can do about it. |
deadprogram
left a comment
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.
That took me a long time to read thru those changes. If they had not been broken up into separate commits I could not have probably even gotten thru it all!
As you said, it is a giant bunch of commits, but thank you for keeping them so organized.
As far as I am concerned, let's merge and then debug if/when needed.
Work in progress branch. This LLVM version introduces a ton of changes that we somehow have to deal with. I'm splitting it up in many separate commits so that we can more easily bisect and track regressions.