Skip to content

Commit d64c438

Browse files
committed
Make some editorial improvements
1 parent 27b569a commit d64c438

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/attributes/codegen.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,31 @@ r[attributes.codegen.naked.body]
5656
The [function body] must consist of exactly one [`naked_asm!`] macro invocation.
5757

5858
r[attributes.codegen.naked.prologue-epilogue]
59-
No function prologue or epilogue are generated for the attributed function: the contents of the `naked_asm!` invocation make up the full body of a naked function.
59+
No function prologue or epilogue is generated for the attributed function. The assembly code in the `naked_asm!` block constitutes the full body of a naked function.
6060

6161
r[attributes.codegen.naked.unsafe-attribute]
62-
The `naked` attribute is an [unsafe attribute]. Annotating a function with `#[unsafe(naked)]` comes with the safety obligation that the body respects the function's calling convention, and that the body either returns or diverges.
62+
The `naked` attribute is an [unsafe attribute]. Annotating a function with `#[unsafe(naked)]` comes with the safety obligation that the body must respect the function's calling convention, uphold its signature, and either return or diverge (i.e., not fall through past the end of the assembly code).
6363

6464
r[attributes.codegen.naked.call-stack]
65-
The assembly code will have a valid call stack and register state on entry as per the signature and calling convention of the function.
65+
The assembly code may assume that the call stack and register state are valid on entry as per the signature and calling convention of the function.
6666

6767
r[attributes.codegen.naked.no-duplication]
68-
The assembly code may not be duplicated by the compiler, except when monomorphizing polymorphic functions. This property is important for naked functions that define symbols in the assembly code.
68+
The assembly code may not be duplicated by the compiler except when monomorphizing polymorphic functions.
69+
70+
> [!NOTE]
71+
> Guaranteeing when the assembly code may or may not be duplicated is important for naked functions that define symbols.
6972
7073
r[attributes.codegen.naked.unused-variables]
7174
The [`unused_variables`] lint is suppressed within naked functions.
7275

7376
r[attributes.codegen.naked.inline]
74-
A naked function cannot be attributed by the [`inline`](#the-inline-attribute) attribute.
77+
The [`inline`](#the-inline-attribute) attribute cannot by applied to a naked function.
7578

7679
r[attributes.codegen.naked.track_caller]
77-
A naked function cannot be attributed by the [`track_caller`](#the-track_caller-attribute) attribute.
80+
The [`track_caller`](#the-track_caller-attribute) attribute cannot be applied to a naked function.
7881

7982
r[attributes.codegen.naked.testing]
80-
A naked function cannot be attributed by [the testing attributes](testing.md).
83+
The [testing attributes](testing.md) cannot be applied to a naked function.
8184

8285
r[attributes.codegen.no_builtins]
8386
## The `no_builtins` attribute

src/inline-assembly.md

+8-12
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ unsafe { core::arch::asm!("/* {} */", in(reg) 0); }
8181
```
8282

8383
r[asm.scope.naked_asm]
84-
With the `naked_asm!` macro, the assembly code is emitted in a function scope and constitutes the full assembly code of a function.
85-
The `naked_asm!` macro is only allowed in [naked functions](attributes/codegen.md#the-naked-attribute).
84+
With the `naked_asm!` macro, the assembly code is emitted in a function scope and constitutes the full assembly code of a function. The `naked_asm!` macro is only allowed in [naked functions](attributes/codegen.md#the-naked-attribute).
8685

8786
```rust
8887
# #[cfg(target_arch = "x86_64")] {
@@ -1225,12 +1224,10 @@ unsafe { core::arch::asm!("mov {:e}, 1", out(reg) z, options(noreturn)); }
12251224
```
12261225

12271226
r[asm.options.naked_asm-restriction]
1228-
`naked_asm!` only supports the `att_syntax` and `raw` options.
1229-
The remaining options are not meaningful because the inline assembly defines the whole function body.
1227+
`naked_asm!` only supports the `att_syntax` and `raw` options. The remaining options are not meaningful because the inline assembly defines the whole function body.
12301228

12311229
r[asm.options.global_asm-restriction]
1232-
`global_asm!` only supports the `att_syntax` and `raw` options.
1233-
The remaining options are not meaningful for global-scope inline assembly.
1230+
`global_asm!` only supports the `att_syntax` and `raw` options. The remaining options are not meaningful for global-scope inline assembly.
12341231

12351232
```rust,compile_fail
12361233
# fn main() {}
@@ -1391,16 +1388,15 @@ To avoid undefined behavior, these rules must be followed when using function-sc
13911388

13921389
r[asm.naked-rules.reg-not-input]
13931390
- Any registers not used for function inputs according to the calling convention and function signature will contain an undefined value on entry to the `naked_asm!` block.
1394-
- An "undefined value" in the context of inline assembly means that the register can (non-deterministically) have any one of the possible values allowed by the architecture.
1395-
Notably it is not the same as an LLVM `undef` which can have a different value every time you read it (since such a concept does not exist in assembly code).
1391+
- An "undefined value" in the context of inline assembly means that the register can (non-deterministically) have any one of the possible values allowed by the architecture. Notably it is not the same as an LLVM `undef` which can have a different value every time you read it (since such a concept does not exist in assembly code).
13961392

13971393
r[asm.naked-rules.reg-not-output]
1398-
- Any callee-saved registers must have the same value upon return as they had on entry, otherwise behavior is undefined.
1399-
- Caller-saved registes may be used freely, even if they are not used for the return value.
1394+
- Any callee-saved registers must have the same value upon return as they had on entry.
1395+
- Caller-saved registers may be used freely, even if they are not used for the return value.
14001396

14011397
r[asm.naked-rules.noreturn]
1402-
- Behavior is undefined if execution falls through to the end of the `naked_asm!` block.
1403-
- every path through the assembly code is expected to terminate with a return instruction or to diverge
1398+
- Behavior is undefined if execution falls through past the end of the assembly code.
1399+
- Every path through the assembly code is expected to terminate with a return instruction or to diverge.
14041400

14051401
r[asm.naked-rules.mem-same-as-ffi]
14061402
- The set of memory locations that assembly code is allowed to read and write are the same as those allowed for an FFI function.

0 commit comments

Comments
 (0)