-
Notifications
You must be signed in to change notification settings - Fork 58
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
Stacked Borrows: Raw pointers inhibit optimizations? #263
Comments
You are converting a pointer to an integer. This makes it valid for all integers converted to pointers to write to the same memory as the pointer. This means that it is completely valid for |
From https://sf.snu.ac.kr/llvmtwin/:
I strongly advice you to read the complete paper. |
Notably, I am not converting the pointer |
I think this could be #248. |
Ah yeah, you would be right (closed because of the duplication). |
On #181 when discussing whether or not provenance destroying operations can be elided, I brought this code up
For which the corresponding rust code would seem to rule out load-store elimination on
ptr.exclusive_access
While I was told that this code doesn't, replacing the first function with
This seems odd to me. The fact that
y
is created bydo_interesting_things
inhibits optimizations accross the black-boxdoes_something
, even thoughdoes_something
never recieves it, seems quite a bit off to me. In contrast, this is not permitted by C or C++, at all (if we replace the&mut
inptr
with eitherInteresting* restrict
in C, or an analogous compiler-specific extension in C++, to exclude aliasing access on entry todo_interesting_things
).In my head, pointers are pointers, reguardless of form (noting that references are pointers). It shouldn't be possible to use a pointer that was never recieved by a particular function to validate an operation in that function. This is particularily annoying because its clear through simple data-flow analysis that
y
never reachesdoes_something
, yet it's mere existance is what invalidates the reasoning thatptr.exclusive_access
is not modified.If this is the case, this is a serious concern of mine, the pointer model in lccc would not permit this, and it is desired that this be the case, but it is intended to permit a superset of operations that Stacked Borrows does (A superset, because some operations that are permitted by C and C++ aren't by stacked borrows presently, one such operation is actually discussed in #256).
The text was updated successfully, but these errors were encountered: