-
Notifications
You must be signed in to change notification settings - Fork 100
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
Allocations cannot shrink? Or alive fails to model extern function calls? #934
Comments
The current LLVM memory model doesn't allow changing the size of objects in place. So, either C and C++ don't have object resizing. Or at least not to a point where we may need to model in the IR. The easiest way would be for Rust to hide the resizing in some function that returns a new pointer, so LLVM can think it's a new object. If that isn't viable (for some reason), then there's a ton of work to be done on LLVM. The Alive2 side is easy FWIW. |
Thanks! That's what we wanted to find out. Is this written down anywhere?
That doesn't work, since the entire point of this is to allow old pointers to still be used with the resized allocation. Otherwise we could just use |
I don't recall, but I don't think so. But I can guarantee you that optimizations follow that semantics. And Alive2 too, and these days it is kind of the oracle. |
What about the other question -- isn't the example an Alive bug since |
It's a bug, yes. |
During a Rust discussion, the following interesting example came up:
I am struggling to interpret this. As a transformation I would say this is definitely incorrect since
bar
could have initialized this memory, and then the tgt program can return a different value than the src program. Maybe that is some systematic Alive limitation that I am not understanding, but then it is hard to say what this actually says about the intended LLVM semantics.In particular, what if there was an operation that can shrink an allocation in-place? In Rust we are considering adding such an operation. Then even though loading at offset 0 is still fine after
bar
, loading from offset 39 might not be fine any more. Maybe the fact that Alive accepts this transformation is a sign that LLVM assumes that allocations can never shrink (which would be a bummer), or maybe this is just Alive not properly modeling all the thingsbar
could do -- we could use some help to interpret these results. :)The text was updated successfully, but these errors were encountered: