Skip to content
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

CTFE core engine allocation & memory API improvemenets #85376

Merged
merged 4 commits into from
May 19, 2021

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented May 16, 2021

This is a first step towards rust-lang/miri#841.

  • make Allocation API offset-based (no more making up Pointers just to access an Allocation)
  • make Memory API higher-level (combine checking for access and getting access into one operation)

The Miri-side PR is at rust-lang/miri#1804.
r? @oli-obk

@rust-highfive
Copy link
Collaborator

Some changes occured to rustc_codegen_cranelift

cc @bjorn3

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 16, 2021
@@ -176,8 +176,7 @@ pub(crate) fn codegen_const_value<'tcx>(
std::iter::repeat(0).take(size.bytes_usize()).collect::<Vec<u8>>(),
align,
);
let ptr = Pointer::new(AllocId(!0), Size::ZERO); // The alloc id is never used
alloc.write_scalar(fx, ptr, x.into(), size).unwrap();
alloc.write_scalar(fx, alloc_range(Size::ZERO, size), x.into()).unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, no more dummy pointers!

@RalfJung
Copy link
Member Author

I am curious if this will have any perf impact... I did reduce the number of times we query the alloc_map a bit.
@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 16, 2021
@bors
Copy link
Contributor

bors commented May 16, 2021

⌛ Trying commit e968add0d2e7080e67498dc6f5903cd8dc0aa2de with merge de65837601ca2358d97f64015476026c73caadd6...

@rust-log-analyzer

This comment has been minimized.

@RalfJung
Copy link
Member Author

Re-try after pushing a fmt fix.
@bors try

@bors
Copy link
Contributor

bors commented May 16, 2021

⌛ Trying commit 3f3aeca70f8e1e6873b060149a2611d371c69bf3 with merge 70a1cef598f09b48d15858b4ea6894e1df0c3f40...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 16, 2021

☀️ Try build successful - checks-actions
Build commit: 70a1cef598f09b48d15858b4ea6894e1df0c3f40 (70a1cef598f09b48d15858b4ea6894e1df0c3f40)

@rust-timer
Copy link
Collaborator

Queued 70a1cef598f09b48d15858b4ea6894e1df0c3f40 with parent f8e1e92, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (70a1cef598f09b48d15858b4ea6894e1df0c3f40): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 16, 2021
@oli-obk
Copy link
Contributor

oli-obk commented May 16, 2021

so many different changes intermingled in one commit 😢 this is going to take me forever to review as right now I'm not able to be at a computer for long enough to untangle all of that.

@RalfJung
Copy link
Member Author

RalfJung commented May 17, 2021

I didn't really find a way to split this into separate commits that makes sense on their own (in the sense that they at least pass ./x.py check) -- but you should be able to mostly separately review the changes in librustc_middle and librustc_mir. I used to have those in separate commits but squashed them together as the individual commits wouldn't even build. It's really not "many different changes" but the two mentioned in the PR description -- which are deeply connected since after changing the Allocation API, using the old Memory API would have been grossly unsafe (in particular in terms of ensuring that we always call the access hooks).

Thinking about it, it might be possible to use the new memory API with the old allocation API (I didn't think of that since I made the changes bottom-up, i.e., allocation API first). But you should be getting basically the same effect by reviewing split-by-folders as I suggested.

@rust-log-analyzer

This comment has been minimized.

@RalfJung
Copy link
Member Author

The Miri-side PR is ready: rust-lang/miri#1804.

@RalfJung
Copy link
Member Author

Rebased.

@oli-obk
Copy link
Contributor

oli-obk commented May 18, 2021

thanks! this was much better to review, just a nit, then r=me

- make Allocation API offset-based (no more Pointer)
- make Memory API higher-level (combine checking for access and getting access into one operation)
@RalfJung
Copy link
Member Author

Wow, that was quick, thanks :)
@bors r=oli-obk

@bors
Copy link
Contributor

bors commented May 18, 2021

📌 Commit d5ccf68 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 18, 2021
@bors
Copy link
Contributor

bors commented May 19, 2021

⌛ Testing commit d5ccf68 with merge 3e827cc...

@bors
Copy link
Contributor

bors commented May 19, 2021

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 3e827cc to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 19, 2021
@bors bors merged commit 3e827cc into rust-lang:master May 19, 2021
@rustbot rustbot added this to the 1.54.0 milestone May 19, 2021
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #85376!

Tested on commit 3e827cc.
Direct link to PR: #85376

💔 miri on windows: test-pass → build-fail (cc @RalfJung @oli-obk @eddyb).
💔 miri on linux: test-pass → build-fail (cc @RalfJung @oli-obk @eddyb).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request May 19, 2021
Tested on commit rust-lang/rust@3e827cc.
Direct link to PR: <rust-lang/rust#85376>

💔 miri on windows: test-pass → build-fail (cc @RalfJung @oli-obk @eddyb).
💔 miri on linux: test-pass → build-fail (cc @RalfJung @oli-obk @eddyb).
@RalfJung RalfJung deleted the ptrless-allocs branch May 19, 2021 13:28
bors added a commit to rust-lang/miri that referenced this pull request May 19, 2021
update for Memory API changes

The Miri side of rust-lang/rust#85376.
bors added a commit to rust-lang/miri that referenced this pull request May 19, 2021
update for Memory API changes

The Miri side of rust-lang/rust#85376.
bors added a commit to rust-lang/miri that referenced this pull request May 19, 2021
update for Memory API changes

The Miri side of rust-lang/rust#85376.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 28, 2021
Miri: fix alignment check in array initialization

rust-lang#85376 introduced a regression in Miri, reported at rust-lang/miri#1919 and rust-lang/miri#1925. This PR fixes that. I will add tests to Miri once this lands.

r? `@oli-obk`
Fixes rust-lang/miri#1919
Fixes rust-lang/miri#1925
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants