-
Notifications
You must be signed in to change notification settings - Fork 214
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
Debug why Rsdp::search_for_on_bios
is optimized to ud2
#425
Comments
This only occurs when using rsdp At first glance, I thought this might be because the added iterator complexity slows down the inlining a bit: AFAICT rust-osdev/acpi@a0db984 doesn't fix anything that LLVM should care about. It prevents some out-of-bounds accesses, but for memory that's not managed by LLVM, so LLVM shouldn't be able to optimize out the accesses. Even if LLVM felt that optimizing out the later out-of-bounds accesses was legal, the rsdp could still be in the first address slot and LLVM should never allow that to be optimized out. In conclusion, even though rust-osdev/acpi@a0db984 fixes this bug, I'm not yet convinced that this didn't just happen by accident. |
We should retry to reproduce this with the latest nightlies. There was another LLVM update in rust-lang/rust#121395, which fixed some miscompilations. |
I can still reproduce this on |
Shouldn't this raw pointer dereference in |
Can you elaborate on why the compiler would be allowed to optimize out the non-volatile read? |
Yes, I'm not sure that constructing a slice using Optimising compilers, and particularly LLVM, try to reduce the number of unnecessary memory accesses to improve performance. They will often remove memory accesses that they consider to have no side-effects. Using |
I'd argue that side effects from the reads are irrelevant here. What matters are the values that are read. Unless LLVM can somehow statically determine the value at the addresses without doing the reads, I don't see why it would be allowed to optimize out the reads. AFAICT the memory accesses are necessary here because the values are not known until runtime. |
True, but LLVM 18 appears to be (mis)optimising this function away, including the memory accesses. I was wondering if that would fix it. |
See #420
We worked around the issue for now by preventing inlining of the
map_physical_region
function, but we should figure out the root cause of this.The text was updated successfully, but these errors were encountered: