You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The [function body] must consist of exactly one [`naked_asm!`] macro invocation.
57
57
58
58
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.
60
60
61
61
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).
63
63
64
64
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.
66
66
67
67
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.
69
72
70
73
r[attributes.codegen.naked.unused-variables]
71
74
The [`unused_variables`] lint is suppressed within naked functions.
72
75
73
76
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.
75
78
76
79
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.
78
81
79
82
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.
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).
`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.
1230
1228
1231
1229
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.
1234
1231
1235
1232
```rust,compile_fail
1236
1233
# fn main() {}
@@ -1391,16 +1388,15 @@ To avoid undefined behavior, these rules must be followed when using function-sc
1391
1388
1392
1389
r[asm.naked-rules.reg-not-input]
1393
1390
- 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).
1396
1392
1397
1393
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.
1400
1396
1401
1397
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.
1404
1400
1405
1401
r[asm.naked-rules.mem-same-as-ffi]
1406
1402
- 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