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

Custom MIR: Support cleanup blocks #117330

Merged
merged 1 commit into from Nov 14, 2023

Conversation

tmiasko
Copy link
Contributor

@tmiasko tmiasko commented Oct 28, 2023

Cleanup blocks are declared with bb (cleanup) = { ... }.

Call and Drop terminators take an additional argument describing the unwind action, which is one of the following:

  • UnwindContinue()
  • UnwindUnreachable()
  • UnwindTerminate(reason), where reason is ReasonAbi or ReasonInCleanup
  • UnwindCleanup(block)

Also support unwind resume and unwind terminate terminators:

  • UnwindResume()
  • UnwindTerminate(reason)

@rustbot
Copy link
Collaborator

rustbot commented Oct 28, 2023

r? @cjgillot

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 28, 2023
@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Oct 28, 2023

The Miri subtree was changed

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

library/core/src/intrinsics/mir.rs Outdated Show resolved Hide resolved
@@ -110,15 +110,15 @@
//! let popped;
//!
//! {
//! Call(_unused = Vec::push(v, value), pop)
//! Call(_unused = Vec::push(v, value), pop, Continue())
Copy link
Member

@RalfJung RalfJung Oct 29, 2023

Choose a reason for hiding this comment

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

It seems like most of the time we want Continue. So maybe with can have Call always use the default unwind action of Continue, and then have CallWithUnwind for when one wants something else? Or maybe some other way to have default values.

//! }
//!
//! pop = {
//! Call(popped = Vec::pop(v), drop)
//! Call(popped = Vec::pop(v), drop, Continue())
Copy link
Member

Choose a reason for hiding this comment

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

This makes me wonder if we should replace Call(popped = Vec::pop(v), drop) by Call(popped = Vec::pop(v), ReturnTo(drop)) or something like that... basically emulating named arguments. That's orthogonal to your PR though so I'd also be happy to do it as a follow-up if you prefer.

@tmiasko tmiasko force-pushed the custom-mir-cleanup-blocks branch 2 times, most recently from 1c827a9 to 73ff6c9 Compare October 30, 2023 09:23
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

library/backtrace Outdated Show resolved Hide resolved
compiler/rustc_mir_build/src/build/custom/parse.rs Outdated Show resolved Hide resolved
compiler/rustc_mir_build/src/build/custom/parse.rs Outdated Show resolved Hide resolved
library/core/src/intrinsics/mir.rs Show resolved Hide resolved
@cjgillot cjgillot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 4, 2023
@tmiasko tmiasko added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 9, 2023
@tmiasko tmiasko force-pushed the custom-mir-cleanup-blocks branch 2 times, most recently from e059888 to 3d89c80 Compare November 9, 2023 15:52
@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Nov 13, 2023

📌 Commit 3d89c80 has been approved by cjgillot

It is now in the queue for this repository.

@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 Nov 13, 2023
@bors
Copy link
Contributor

bors commented Nov 14, 2023

⌛ Testing commit 3d89c80 with merge 060f778...

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 14, 2023
…=cjgillot

Custom MIR: Support cleanup blocks

Cleanup blocks are declared with `bb (cleanup) = { ... }`.

`Call` and `Drop` terminators take an additional argument describing the unwind action, which is one of the following:

* `UnwindContinue()`
* `UnwindUnreachable()`
* `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup`
* `UnwindCleanup(block)`

Also support unwind resume and unwind terminate terminators:

* `UnwindResume()`
* `UnwindTerminate(reason)`
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Nov 14, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 14, 2023
Cleanup blocks are declared with `bb (cleanup) = { ... }`.

`Call` and `Drop` terminators take an additional argument describing the
unwind action, which is one of the following:

* `UnwindContinue()`
* `UnwindUnreachable()`
* `UnwindTerminate(reason)`, where reason is `ReasonAbi` or `ReasonInCleanup`
* `UnwindCleanup(block)`

Also support unwind resume and unwind terminate terminators:

* `UnwindResume()`
* `UnwindTerminate(reason)`
@tmiasko
Copy link
Contributor Author

tmiasko commented Nov 14, 2023

Cannot UnwindResume in a function that cannot unwind

Added needs-unwind to the test.

By the way, it seems quite suspect that MIR validity depends on the current panic strategy, since it means that code generation operates on invalid MIR when it originates from a crate with a different panic strategy.

@tmiasko
Copy link
Contributor Author

tmiasko commented Nov 14, 2023

@bors r=cjgillot

@bors
Copy link
Contributor

bors commented Nov 14, 2023

📌 Commit 78da577 has been approved by cjgillot

It is now in the queue for this repository.

@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 Nov 14, 2023
@bors
Copy link
Contributor

bors commented Nov 14, 2023

⌛ Testing commit 78da577 with merge 5526682...

@bors
Copy link
Contributor

bors commented Nov 14, 2023

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing 5526682 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 14, 2023
@bors bors merged commit 5526682 into rust-lang:master Nov 14, 2023
12 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Nov 14, 2023
@tmiasko tmiasko deleted the custom-mir-cleanup-blocks branch November 14, 2023 10:55
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5526682): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.6% [-0.6%, -0.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.6% [-0.6%, -0.6%] 1

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.2% [1.2%, 1.2%] 1
Regressions ❌
(secondary)
2.7% [2.0%, 4.0%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-3.9%, -2.4%] 3
All ❌✅ (primary) 1.2% [1.2%, 1.2%] 1

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.1% [2.0%, 4.2%] 5
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.1% [-2.3%, -1.9%] 3
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 672.988s -> 673.782s (0.12%)
Artifact size: 311.12 MiB -> 311.12 MiB (0.00%)

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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants