-
Notifications
You must be signed in to change notification settings - Fork 254
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
add pointer-to-pointer test cases #585
base: master
Are you sure you want to change the base?
Conversation
n[10]: addr.store n[0] => _ @ bb4[2]: fn ptrptr1_bidir; (*(*_2)) = const 1_i32; | ||
n[11]: copy n[0] => _59 @ bb35[6]: fn main_0; _59 = _45; | ||
n[12]: copy n[11] => _2 @ bb0[0]: fn ptrptr1_bidir; _58 = ptrptr1_bidir(const false, move _59, move _60); | ||
n[13]: addr.store n[0] => _ @ bb4[2]: fn ptrptr1_bidir; (*(*_2)) = const 1_i32; |
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.
n[0]
is not the correct source
here - you can tell because n[0]
has dest: _45
, but _45
doesn't appear in this statement. The source
should instead be n[12]
(which has dest: _2
).
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.
should this be any different than here?
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.
Both places have both problems (wrong source
and AddrStore
where it should be AddrLoad
), as does the third (*(*x)) = y
in this function.
n[1]: copy n[0] => _50 @ bb32[28]: fn main_0; _50 = _45; | ||
n[2]: copy n[1] => _2 @ bb0[0]: fn ptrptr1_backward; _49 = ptrptr1_backward(const true, move _50, move _51); | ||
n[3]: copy n[2] => _4 @ bb1[1]: fn ptrptr1_backward; _4 = _2; | ||
n[4]: addr.store n[0] => _ @ bb4[2]: fn ptrptr1_backward; (*(*_4)) = const 1_i32; |
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.
This node should be a LoadAddr
instead of StoreAddr
. The statement (*(*_4)) = 1
is equivalent to the following:
p = *_4;
*p = 1;
This graph covers the object pointed to by _4
, so the LoadAddr
for the p = *_4
part should appear here. (The StoreAddr
for *p = 1
should go in a different graph.)
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.
thanks, linking #578 which will fix this once addressed
@@ -959,6 +959,50 @@ g { | |||
} | |||
nodes_that_need_write = [75, 74, 73, 66, 65, 64, 63, 62, 61, 54, 53, 52, 45, 44, 43, 33, 32, 31, 27, 26, 25, 15, 14, 13, 6, 5, 4, 0] | |||
|
|||
g { | |||
n[0]: &_43 _ => _44 @ bb32[9]: fn main_0; _44 = &raw mut _43; | |||
} |
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.
Since _44
is address-taken, this graph should look like AddrOfLocal(_43) -> StoreValue
, and there should be a corresponding StoreAddr
in the graph below that starts with AddrOfLocal(_44)
.
The p = *_4; *p = 1
code should also produce a LoadValue -> p -> StoreAddr
chain somewhere, possibly in this graph (since p
will concretely equal &_43
).
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.
Which statement would the StoreValue
result from? From my understanding it would need a store on the LHS, and a RHS that evaluates to the value _43
, but I don't see where that is. My guess is that it must be *p = 1
?
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.
It should come from the statement _44 = &raw mut _43
. Since _44
is address-taken, we treat this like
a = &mut _44;
*a = &raw mut _43;
Which produces the chains AddrOfLocal(_44) -> a -> StoreAddr
and AddrOfLocal(_43) -> StoreValue
.
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.
That makes sense, thank you
No description provided.