-
Notifications
You must be signed in to change notification settings - Fork 13.4k
clarify MIR uninit vs LLVM undef/poison #113892
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
Conversation
r? @wesleywiser (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
@@ -5,7 +5,13 @@ use rustc_target::abi; | |||
pub trait ConstMethods<'tcx>: BackendTypes { | |||
// Constant constructors | |||
fn const_null(&self, t: Self::Type) -> Self::Value; | |||
/// Generate an uninitialized value (matching uninitialized memory in MIR). | |||
/// Whether memory is initialized or not is tracked byte-for-byte. |
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.
I don't know whether it matters, but I think it might be bit-for-bit in LLVM? The way I understand langref, (undef << 1) & 1
in LLVM is definitely 0
, though in Rust I think we'd still treat it as uninit
.
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.
Not sure if that's true for all backends though. Ultimately what matters is MIR semantics; it is then the backend's responsibility to find an appropriate translation.
@bors r+ rollup |
☀️ Test successful - checks-actions |
Finished benchmarking commit (d908a5b): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 658.525s -> 658.594s (0.01%) |
In this LLVM discussion I learned that mapping our uninitialized memory in MIR to poison in LLVM would be quite problematic due to the lack of a byte type. I am not sure where to write down this insight but this seems like a reasonable start.