-
Notifications
You must be signed in to change notification settings - Fork 5
volatile_{load,store} with statics. Heap allocations. And transmuting wrappers.
#989
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
Open
dkcumming
wants to merge
5
commits into
master
Choose a base branch
from
dc/volatile-constants
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f02709a
Added failing tests for `volatile_{load,store}` with statics
dkcumming ca057a1
Added failing test for box heap allocation
dkcumming a3b7060
Added failing tests for up- and down-cast of transparent wrappers
dkcumming 96f410e
Added rules for transparent wrapper transmute casts
dkcumming 2c1ec68
Changed failing transmute transparent wrapper tests to passing
dkcumming File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
kmir/src/tests/integration/data/prove-rs/box_heap_alloc-fail.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| fn main() { | ||
| let a = Box::new(42i32); | ||
| assert!(*a == 42); | ||
| } |
15 changes: 15 additions & 0 deletions
15
kmir/src/tests/integration/data/prove-rs/show/box_heap_alloc-fail.main.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
|
|
||
| ┌─ 1 (root, init) | ||
| │ #execTerminator ( terminator ( ... kind: terminatorKindCall ( ... func: operandC | ||
| │ span: 0 | ||
| │ | ||
| │ (199 steps) | ||
| └─ 3 (stuck, leaf) | ||
| #execIntrinsic ( IntrinsicFunction ( symbol ( "volatile_load" ) ) , operandConst | ||
| span: 32 | ||
|
|
||
|
|
||
| ┌─ 2 (root, leaf, target, terminal) | ||
| │ #EndProgram ~> .K | ||
|
|
||
|
|
16 changes: 16 additions & 0 deletions
16
kmir/src/tests/integration/data/prove-rs/show/volatile_load_static-fail.main.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
|
|
||
| ┌─ 1 (root, init) | ||
| │ #execTerminator ( terminator ( ... kind: terminatorKindCall ( ... func: operandC | ||
| │ span: 0 | ||
| │ | ||
| │ (17 steps) | ||
| └─ 3 (stuck, leaf) | ||
| #traverseProjection ( toLocal ( 3 ) , thunk ( #decodeConstant ( constantKindAllo | ||
| function: main | ||
| span: 53 | ||
|
|
||
|
|
||
| ┌─ 2 (root, leaf, target, terminal) | ||
| │ #EndProgram ~> .K | ||
|
|
||
|
|
16 changes: 16 additions & 0 deletions
16
kmir/src/tests/integration/data/prove-rs/show/volatile_store_static-fail.main.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
|
|
||
| ┌─ 1 (root, init) | ||
| │ #execTerminator ( terminator ( ... kind: terminatorKindCall ( ... func: operandC | ||
| │ span: 0 | ||
| │ | ||
| │ (17 steps) | ||
| └─ 3 (stuck, leaf) | ||
| #traverseProjection ( toLocal ( 4 ) , thunk ( #decodeConstant ( constantKindAllo | ||
| function: main | ||
| span: 57 | ||
|
|
||
|
|
||
| ┌─ 2 (root, leaf, target, terminal) | ||
| │ #EndProgram ~> .K | ||
|
|
||
|
|
7 changes: 7 additions & 0 deletions
7
kmir/src/tests/integration/data/prove-rs/transmute_transparent_wrapper_down.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| struct Wrapper(u64); | ||
|
|
||
| fn main() { | ||
| let wrapped = Wrapper(42); | ||
| let val: u64 = unsafe { core::mem::transmute::<Wrapper, u64>(wrapped) }; | ||
| assert!(val == 42); | ||
| } |
7 changes: 7 additions & 0 deletions
7
kmir/src/tests/integration/data/prove-rs/transmute_transparent_wrapper_up.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| struct Wrapper(u64); | ||
|
|
||
| fn main() { | ||
| let val: u64 = 42; | ||
| let wrapped: Wrapper = unsafe { core::mem::transmute::<u64, Wrapper>(val) }; | ||
| assert!(wrapped.0 == 42); | ||
| } |
11 changes: 11 additions & 0 deletions
11
kmir/src/tests/integration/data/prove-rs/volatile_load_static-fail.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #![feature(core_intrinsics)] | ||
| static A: i32 = 5555; | ||
|
|
||
| fn main() { | ||
| let val: i32; | ||
| unsafe { | ||
| val = std::intrinsics::volatile_load(&A as *const i32); | ||
| } | ||
|
|
||
| assert!(val == 5555); | ||
| } |
12 changes: 12 additions & 0 deletions
12
kmir/src/tests/integration/data/prove-rs/volatile_store_static-fail.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #![feature(core_intrinsics)] | ||
| static mut A: i32 = 5555; | ||
|
|
||
| fn main() { | ||
| unsafe { | ||
| std::intrinsics::volatile_store(&mut A as *mut i32, 7777); | ||
| } | ||
|
|
||
| unsafe { | ||
| assert!(A == 7777); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
LGTM! And I trust you that you've already saw the red and added these to make it green. I'd like to give you approval to let you continue.
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.
But would you mind to draft an issue about refactoring these casting things? It looks quite the same but we have to deal with them one by one.