-
Notifications
You must be signed in to change notification settings - Fork 525
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 reference for asm-goto #1693
Conversation
@Amanieu: What do you think? |
@rustbot author |
We reviewed this in the lang call today. Everyone read through it. It looked right. Nobody had any notes. |
In reading this more carefully (especially the lines not changed), I find myself wanting to double check that we're being precise enough now by what we mean by "the So when we say, e.g., that...
...or...
...or...
...or even...
...do we mean for these to apply to the |
GCC manual says "Also note that an asm goto statement is always implicitly considered volatile.", although AFAIU it's possible to represent a asm-goto in LLVM without the It's not clear what exactly is pure for an asm goto block, since the control flow change is also one of its output. We probably should just forbid pure + label from being used together -- however note that since
These would just mean the assembly themselves. |
How about replacing " |
Sounds about right, assuming that's correct in each use, which of course should be carefully checked. Everywhere that the word "block" is used should be reviewed during this rename. |
This comment has been minimized.
This comment has been minimized.
cc990ed
to
040fc58
Compare
The asm-goto-with-outputs is still unstable, so in the reference it's still mentioned as forbidden by a check rule.
The latter now only means the entire block, while the former means the assembly code specified within the block (thus excluding `label` blocks).
Co-authored-by: Alice Ryhl <aliceryhl@google.com>
@joshtriplett Indicated they could give a review over the chapter to make sure everything still fits together. |
I reviewed the entire chapter, and wrote nbdd0121#1 as a PR to this PR branch, since there were changes in areas outside the context of the patch, which github doesn't allow suggestions in. I added some more disambiguations in cases of possible ambiguity between the entire asm! block (including label blocks) and the assembly code within it. The second commit, which I've kept separate, attempts to clarify an interaction between noreturn and label blocks; however, for that commit I could use some confirmation on accuracy. The phrasing as previously written said that "A noreturn asm block behaves just like a function which doesn't return", but that isn't accurate in the presence of label blocks, since the asm block can return, from the label blocks. I changed it to apply to "A noreturn asm block with no label blocks". However, this assumes there are not more semantic connotations of noreturn here that do apply to asm blocks with label blocks. With the first commit applied, and either the second commit (if accurate) or something like it (if another phrasing would be more accurate) applied, the chapter looks fully consistent to me. |
Update more cases where the phrasing could potentially have been interpreted as affecting a `label` block.
Let's make some clarifications of substance and editorial tweaks to the changes for `asm_goto`. We add an example, we change various wording to be more clear -- in particular, we significantly revise the section on `noreturn` to unify the statement of the rules -- and we replace remaining uses of "asm code" with "assembly code" to match our verbiage elsewhere. The main clarification of substance is that for requirements that must be upheld when falling through the assembly, such as he requirement to restore the stack pointer, we must also note that the requirement must be satisfied before jumping to any `label` blocks.
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.
Looks good to me. Ready to go.
…rcote Stabilize `asm_goto` feature gate Stabilize `asm_goto` feature (tracked by rust-lang#119364). The issue will remain open and be updated to track `asm_goto_with_outputs`. Reference PR: rust-lang/reference#1693 # Stabilization Report This feature adds a `label <block>` operand type to `asm!`. `<block>` must be a block expression with type unit or never. The address of the block is substituted and the assembly may jump to the block. When block completes the `asm!` block returns and continues execution. The block starts a new safety context and unsafe operations within must have additional `unsafe`s; the effect of `unsafe` that surrounds `asm!` block is cancelled. See rust-lang#119364 (comment) and rust-lang#131544. It's currently forbidden to use `asm_goto` with output operands; that is still unstable under `asm_goto_with_outputs`. Example: ```rust unsafe { asm!( "jmp {}", label { println!("Jumped from asm!"); } ); } ``` Tests: - tests/ui/asm/x86_64/goto.rs - tests/ui/asm/x86_64/goto-block-safe.stderr - tests/ui/asm/x86_64/bad-options.rs - tests/codegen/asm/goto.rs
Rollup merge of rust-lang#133870 - nbdd0121:asm, r=traviscross,nnethercote Stabilize `asm_goto` feature gate Stabilize `asm_goto` feature (tracked by rust-lang#119364). The issue will remain open and be updated to track `asm_goto_with_outputs`. Reference PR: rust-lang/reference#1693 # Stabilization Report This feature adds a `label <block>` operand type to `asm!`. `<block>` must be a block expression with type unit or never. The address of the block is substituted and the assembly may jump to the block. When block completes the `asm!` block returns and continues execution. The block starts a new safety context and unsafe operations within must have additional `unsafe`s; the effect of `unsafe` that surrounds `asm!` block is cancelled. See rust-lang#119364 (comment) and rust-lang#131544. It's currently forbidden to use `asm_goto` with output operands; that is still unstable under `asm_goto_with_outputs`. Example: ```rust unsafe { asm!( "jmp {}", label { println!("Jumped from asm!"); } ); } ``` Tests: - tests/ui/asm/x86_64/goto.rs - tests/ui/asm/x86_64/goto-block-safe.stderr - tests/ui/asm/x86_64/bad-options.rs - tests/codegen/asm/goto.rs
Stabilize `asm_goto` feature gate Stabilize `asm_goto` feature (tracked by #119364). The issue will remain open and be updated to track `asm_goto_with_outputs`. Reference PR: rust-lang/reference#1693 # Stabilization Report This feature adds a `label <block>` operand type to `asm!`. `<block>` must be a block expression with type unit or never. The address of the block is substituted and the assembly may jump to the block. When block completes the `asm!` block returns and continues execution. The block starts a new safety context and unsafe operations within must have additional `unsafe`s; the effect of `unsafe` that surrounds `asm!` block is cancelled. See rust-lang/rust#119364 (comment) and rust-lang/rust#131544. It's currently forbidden to use `asm_goto` with output operands; that is still unstable under `asm_goto_with_outputs`. Example: ```rust unsafe { asm!( "jmp {}", label { println!("Jumped from asm!"); } ); } ``` Tests: - tests/ui/asm/x86_64/goto.rs - tests/ui/asm/x86_64/goto-block-safe.stderr - tests/ui/asm/x86_64/bad-options.rs - tests/codegen/asm/goto.rs
Update books ## rust-lang/book 23 commits in 81a976a237f84b8392c4ce1bd5fd076eb757a2eb..45f05367360f033f89235eacbbb54e8d73ce6b70 2025-03-21 23:23:52 UTC to 2025-03-13 14:14:37 UTC - Ch. 21: call out Chrome multiple-connections issue (rust-lang/book#4297) - Ch. 16: refactor 16-6 to using listing component (rust-lang/book#4295) - Ch. 01: Show how to work offline (rust-lang/book#4294) - Ch. 07: Clarify sentences about `pub use` (rust-lang/book#4293) - Ch. 02: Consistent ordering of `use` statements (rust-lang/book#4292) - Anchors on listings (rust-lang/book#4271) - Ch. 17: another tweak to how we phrase things about sections (rust-lang/book#4288) - Ch. 20: correct listing number (rust-lang/book#4287) - Ch. 10.3: clarify language detail (rust-lang/book#4284) - Ch. 17: minor typos and link reference (rust-lang/book#4286) - Ch. 9: correctly demonstrate privacy with module (rust-lang/book#4282) - Ch. 18: correct discussion of delegation in `Post` methods (rust-lang/book#4281) - Ch. 20: tell folks to see the Reference for more ABI info (rust-lang/book#4165) - Ch 10.1 minor clarifications (rust-lang/book#4256) - Clarified the misunderstanding b/w crates, module, items (rust-lang/book#4232) - Ferris: always show, even when it’s small (rust-lang/book#4280) - Ch. 17: mention `use std::pin::{Pin, pin};` on introduction (rust-lang/book#4279) - Persist printing error, NOT ErrorKind (rust-lang/book#4259) - Typo: "2" should be "2 seconds" (rust-lang/book#4263) - Ch. 17: fix tiny example consistency issue (rust-lang/book#4270) - Bump ring from 0.17.8 to 0.17.13 in /listings/ch17-async-await/listing-17-02 (rust-lang/book#4261) - Bump ring from 0.17.8 to 0.17.14 in /packages/trpl (rust-lang/book#4273) - 2024 Print Edition: updates to Word docs and more fixes to Markdown text (rust-lang/book#4272) ## rust-lang/reference 5 commits in dda31c85f2ef2e5d2f0f2f643c9231690a30a626..e95ebdfee02514d93f79ec92ae310a804e87f01f 2025-03-24 15:56:46 UTC to 2025-03-18 02:25:06 UTC - Fix diagnostic attribute typo (rust-lang/reference#1767) - Mention that “every address” ≠ “every pointer” (rust-lang/reference#1761) - Rework range pattern rules (rust-lang/reference#1756) - Use warning block in behavior-considered-undefined (rust-lang/reference#1759) - Add reference for asm-goto (rust-lang/reference#1693)
Rollup merge of rust-lang#138894 - rustbot:docs-update, r=ehuss Update books ## rust-lang/book 23 commits in 81a976a237f84b8392c4ce1bd5fd076eb757a2eb..45f05367360f033f89235eacbbb54e8d73ce6b70 2025-03-21 23:23:52 UTC to 2025-03-13 14:14:37 UTC - Ch. 21: call out Chrome multiple-connections issue (rust-lang/book#4297) - Ch. 16: refactor 16-6 to using listing component (rust-lang/book#4295) - Ch. 01: Show how to work offline (rust-lang/book#4294) - Ch. 07: Clarify sentences about `pub use` (rust-lang/book#4293) - Ch. 02: Consistent ordering of `use` statements (rust-lang/book#4292) - Anchors on listings (rust-lang/book#4271) - Ch. 17: another tweak to how we phrase things about sections (rust-lang/book#4288) - Ch. 20: correct listing number (rust-lang/book#4287) - Ch. 10.3: clarify language detail (rust-lang/book#4284) - Ch. 17: minor typos and link reference (rust-lang/book#4286) - Ch. 9: correctly demonstrate privacy with module (rust-lang/book#4282) - Ch. 18: correct discussion of delegation in `Post` methods (rust-lang/book#4281) - Ch. 20: tell folks to see the Reference for more ABI info (rust-lang/book#4165) - Ch 10.1 minor clarifications (rust-lang/book#4256) - Clarified the misunderstanding b/w crates, module, items (rust-lang/book#4232) - Ferris: always show, even when it’s small (rust-lang/book#4280) - Ch. 17: mention `use std::pin::{Pin, pin};` on introduction (rust-lang/book#4279) - Persist printing error, NOT ErrorKind (rust-lang/book#4259) - Typo: "2" should be "2 seconds" (rust-lang/book#4263) - Ch. 17: fix tiny example consistency issue (rust-lang/book#4270) - Bump ring from 0.17.8 to 0.17.13 in /listings/ch17-async-await/listing-17-02 (rust-lang/book#4261) - Bump ring from 0.17.8 to 0.17.14 in /packages/trpl (rust-lang/book#4273) - 2024 Print Edition: updates to Word docs and more fixes to Markdown text (rust-lang/book#4272) ## rust-lang/reference 5 commits in dda31c85f2ef2e5d2f0f2f643c9231690a30a626..e95ebdfee02514d93f79ec92ae310a804e87f01f 2025-03-24 15:56:46 UTC to 2025-03-18 02:25:06 UTC - Fix diagnostic attribute typo (rust-lang/reference#1767) - Mention that “every address” ≠ “every pointer” (rust-lang/reference#1761) - Rework range pattern rules (rust-lang/reference#1756) - Use warning block in behavior-considered-undefined (rust-lang/reference#1759) - Add reference for asm-goto (rust-lang/reference#1693)
The asm-goto-with-outputs is still unstable, so in the reference it's still mentioned as forbidden by a check rule.
Stabilization PR: rust-lang/rust#133870