Conversation
|
This PR changes Stable MIR cc @oli-obk, @celinval, @spastorino Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
There was a problem hiding this comment.
we can ignore this, this will always be empty except for miri
There was a problem hiding this comment.
keep this private. Instead add an iterator over u64 that allows getting the blocks out directly (and just produces the same value over and over in case it was lazy). If you need to box those iterators, that's fine.
There was a problem hiding this comment.
We can just store a Vec<u64> in SMIR, we don't need to use this optimization for now.
There was a problem hiding this comment.
keep this private.
if I make it private I would have to remove Stable implementation for it. Can't implement trait for private type. (can I?)
There was a problem hiding this comment.
you can't, but you can add a function returning the iterator I described to InitMask
There was a problem hiding this comment.
keep this private. Instead add an iterator over
u64that allows getting the blocks out directly (and just produces the same value over and over in case it was lazy). If you need to box those iterators, that's fine.
but don't we lose information if it's InitMaskBlocks::Lazy{true} or InitMaskBlocks::Lazy(false), how would someone know if it's lazy or not, since I can't match private value. Maybe something like this ? So people who use smir could identify it it's by checking repeating 0's or 1's
vec![1;10].iter() // lazy ?
vec![0;10].iter() // not lazy ?There was a problem hiding this comment.
Lazy is not information anyone cares about. It is just an internal representation detail. it's a optimization to avoid allocating a vec if all entries are true or all entries are false
There was a problem hiding this comment.
Ah I get it now, I didn't know it wasn't useful for smir
There was a problem hiding this comment.
This was all quite deliberately sealed away. Do we really have to make this public? :(
Not even the interpreter or codegen need that kind of access. I don't think anything can legitimately require it.
There was a problem hiding this comment.
We're gonna make it private before this PR lands. We're not exposing the internals, but adding helper methods that avoid having to expose them.
There was a problem hiding this comment.
You don't need to add any helper methods. The existing methods are sufficient for the interpreter, codegen, and MiniRust.
There was a problem hiding this comment.
Yes, but these do random access, we want to duplicate the information. Iterating over all bytes is... not great.
There was a problem hiding this comment.
No they don't. They build a full model of the allocation contents in MiniRust / LLVM. I really can't see how you would need more APIs than what is required to build a fully accurate model of Rust semantics aka MiniRust.
There was a problem hiding this comment.
Yea, I assumed that was too expensive for big allocations, but we can optimize when we see that being an issue
There was a problem hiding this comment.
Made them private, I think in future PR we should def get inspiration from MiniRust.
There was a problem hiding this comment.
This should be AllocId. How is that exposed to smir?
There was a problem hiding this comment.
Similar to how we have a table for DefIds, we should add something like it for AllocIds (instead of exposing the AllocIds internals). Since we don't actually need this in this PR yet, we can make Prov just be Opaque and stick a stringified version of the AllocId in it.
There was a problem hiding this comment.
This will not be very useful without doc comments explaining what this is all about.
There was a problem hiding this comment.
I added comments from rustc, I don't know specifics of what smir user would want to know from this. I think it should suffice for now? If not I would love to learn more and add more information/documentation.
There was a problem hiding this comment.
this is wrong, it's not zero sized, but repeating state for the length of the entire bytes buffer.
But, as Ralf mentioned, we can avoid this entirely by encoding bytes as Vec<Option<u8>> and using https://github.com/RalfJung/minirust/blob/196da9640a4cd608405ad40110d29930827a99a5/tooling/minimize/src/constant.rs#L132-L145 to generate that Vec. Then we don't need an init_mask field at all.
There was a problem hiding this comment.
| ptrs.push((size.bytes_usize(), opaque(&prov.0.get()))); | |
| ptrs.push((size.bytes_usize(), opaque(prov))); |
when we render it opaquely, just render the full thing instead of its internal information
There was a problem hiding this comment.
This and get_blocks is now dead code
There was a problem hiding this comment.
THis isn't needed anymore either
|
Please squash the commits after all comments have been addressed |
c2c3c54 to
fc63e74
Compare
There was a problem hiding this comment.
Looks like some spurious remainders, these are now just unnecessary changes.
|
@bors r+ rollup |
Add Allocation to SMIR As it's discussed [here ](https://rust-lang.zulipchat.com/#narrow/stream/320896-project-stable-mir/topic/Representing.20Constants.20in.20smir)this is an attempt to cover Constants for smir in a different way compared to rust-lang#114342 cc rust-lang/project-stable-mir#15 r? `@oli-obk`
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#114466 (Add Allocation to SMIR) - rust-lang#114505 (Add documentation to has_deref) - rust-lang#114519 (use offset_of! to calculate dirent64 field offsets) - rust-lang#114537 (Migrate GUI colors test to original CSS color format) - rust-lang#114539 (linkchecker: Remove unneeded FIXME about intra-doc links) Failed merges: - rust-lang#114485 (Add trait decls to SMIR) r? `@ghost` `@rustbot` modify labels: rollup
Convert Const to Allocation in smir Continuation of previous pr rust-lang#114466 cc rust-lang/project-stable-mir#15 r? `@oli-obk`
Convert Const to Allocation in smir Continuation of previous pr rust-lang/rust#114466 cc rust-lang/project-stable-mir#15 r? `@oli-obk`
Convert Const to Allocation in smir Continuation of previous pr rust-lang/rust#114466 cc rust-lang/project-stable-mir#15 r? `@oli-obk`
As it's discussed here this is an attempt to cover Constants for smir in a different way compared to #114342
cc rust-lang/project-stable-mir#15
r? @oli-obk