Hi guys, I am learning the Rust language and the compiler recently. I knew a bit about LLVM, so I usually generate the IR for the test code I wrote. One thing I don't understand is that, why some types are lowered to i128 or i64 in LLVM IR. For example:
use std::sync::RwLock;
fn main() {
let v = RwLock::new(0);
*v.write().unwrap() = 7777;
println!("{}", *v.read().unwrap());
}
The return type of function RwLock::new becomes i128 in LLVM IR. I know this is due to some optimizations. But I don't quite understand where is such optimization performed? I checked the MIR, the type is still RwLock there. And I don't remember LLVM opt will do such optimizations. Probably this happens in lowering stage from MIR to LLVM IR?
Any hints are appreciated!