Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2401d21

Browse files
committedApr 19, 2025
changes after code review
also maybe make links work?
1 parent f64c8ca commit 2401d21

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed
 

‎src/attributes/codegen.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,11 @@ No function prologue or epilogue are generated for the attributed function: the
6464
of the `naked_asm!` invocation make up the full body of a naked function.
6565

6666
r[attributes.codegen.naked.call-stack]
67-
The caller must set up the call stack according to the specified calling convention before
68-
executing a naked function, even in contexts where setting up the call stack would ordinarily
69-
be unnecessary, such as when the function is inlined.
67+
The asm code will have a valid call stack and register state on entry as per the signature and calling convention of the function.
7068

71-
An implementation can fulfill this requirement by guaranteeing that naked functions
72-
are never inlined. However, implementations are not currently required to guarantee that
73-
naked functions are never inlined.
74-
75-
In the future it may become a requirement for implementations to guarantee that
76-
naked functions are never inlined; users must not rely on any observable behavior
77-
that may result from inlining. according to the specified calling convention before
78-
executing a naked function,
69+
r[attributes.codegen.naked.no-duplication]
70+
The asm code may not be duplicated by the compiler.
71+
This property is important for naked functions that define symbols in the assembly code.
7972

8073
r[attributes.codegen.naked.unsafe-function]
8174
A naked function that makes use of registers in a way that does not conform
@@ -92,7 +85,7 @@ r[attributes.codegen.naked.track_caller]
9285
A naked function cannot be attributed by the [`track_caller`](#the-track_caller-attribute) attribute.
9386

9487
r[attributes.codegen.naked.testing]
95-
A naked function cannot be attributed by [the testing attributes](../testing.md).
88+
A naked function cannot be attributed by [the testing attributes](attributes/testing.md).
9689

9790
r[attributes.codegen.no_builtins]
9891
## The `no_builtins` attribute

‎src/inline-assembly.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ unsafe { core::arch::asm!("/* {} */", in(reg) 0); }
8282

8383
r[asm.scope.naked_asm]
8484
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).
85+
The `naked_asm!` macro is only allowed in [naked functions](attributes/codegen.md#the-naked-attribute).
8686

8787
r[asm.scope.global_asm]
8888
With the `global_asm!` macro, the assembly code is emitted in a global scope, outside a function.
@@ -1216,7 +1216,7 @@ unsafe { core::arch::asm!("mov {:e}, 1", out(reg) z, options(noreturn)); }
12161216
```
12171217

12181218
r[asm.options.naked_asm-restriction]
1219-
`global_asm!` only supports the `att_syntax` and `raw` options.
1219+
`naked_asm!` only supports the `att_syntax` and `raw` options.
12201220
The remaining options are not meaningful because the inline assembly defines the whole function body.
12211221

12221222
r[asm.options.global_asm-restriction]
@@ -1387,7 +1387,7 @@ r[asm.naked-rules.reg-not-input]
13871387
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).
13881388

13891389
r[asm.naked-rules.reg-not-output]
1390-
- Any callee-saved registers must have the same value upon exiting the asm block as they had on entry, otherwise behavior is undefined.
1390+
- Any callee-saved registers must have the same value upon return as they had on entry, otherwise behavior is undefined.
13911391
- Caller-saved registes may be used freely, even if they are not used for the return value.
13921392

13931393
r[asm.naked-rules.unwind]
@@ -1396,6 +1396,7 @@ r[asm.naked-rules.unwind]
13961396

13971397
r[asm.naked-rules.noreturn]
13981398
- Behavior is undefined if execution falls through to the end of the asm block.
1399+
- the assembly code is expected to contain a return instruction or to diverge
13991400

14001401
r[asm.naked-rules.mem-same-as-ffi]
14011402
- The set of memory locations that assembly code is allowed to read and write are the same as those allowed for an FFI function.
@@ -1408,10 +1409,6 @@ r[asm.naked-rules.black-box]
14081409
- Runtime code patching is allowed, via target-specific mechanisms.
14091410
- However there is no guarantee that each `naked_asm!` directly corresponds to a single instance of instructions in the object file: the compiler is free to duplicate or deduplicate `naked_asm!` blocks.
14101411

1411-
r[asm.naked-rules.not-exactly-once]
1412-
- You cannot assume that an `naked_asm!` block will appear exactly once in the output binary.
1413-
The compiler is allowed to instantiate multiple copies of the `naked_asm!` block, for example when the function containing it is inlined in multiple places.
1414-
14151412
r[asm.validity]
14161413
### Correctness and Validity
14171414

0 commit comments

Comments
 (0)
Please sign in to comment.