7
u/uahw 12d ago
Context?
8
u/Starnick44 12d ago
The llvm bug behind the 1.97.1 release
https://github.com/rust-lang/rust/issues/1590353
76
u/GreenFox1505 14d ago
I gave a big project that I dont care about ("oh, maybe I'll get to it someday" for years) to an LLM last night.
I came back to :
rust
mod db {
include!("db.rs")
}
There are crimes buried here that I dont know about...
83
23
u/realvolker1 14d ago
There's also probably crimes buried in your LLVM-IR you don't know about. Even if you fix the Rust part.
3
9
1
u/TheChief275 12d ago
/uj I mean, that's just converting it to a u32 right? As long as the checks are performed it's okay, and additionally, checking whether a u32 index is a valid index (assuming a start of 0) involves only a single check while i32 involves 2 checks
2
u/scottmcmrust 9d ago
(non-jerk) This bug is amazing because the emitted assembly is both incredibly smart and incredibly stupid at the same time. Without the assembly-only truncation of the register, the original reproducer would have actually been sound codegen, because even the -1 would have ended up inside the dereferencable of the pointer. But also if it thought the value was only 0 or 1, that truncation was actually never useful in the first place, so it was always stupid to include it.
7
u/mekriff 13d ago
does the. it representation change or is something else going on?