Skip to content

Commit 2542a2e

Browse files
committed
changes after code review
also maybe make links work?
1 parent f26c33a commit 2542a2e

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
@@ -66,18 +66,11 @@ No function prologue or epilogue are generated for the attributed function: the
6666
of the `naked_asm!` invocation make up the full body of a naked function.
6767

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

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

8275
r[attributes.codegen.naked.unsafe-function]
8376
A naked function that makes use of registers in a way that does not conform
@@ -94,7 +87,7 @@ r[attributes.codegen.naked.track_caller]
9487
A naked function cannot be attributed by the [`track_caller`](#the-track_caller-attribute) attribute.
9588

9689
r[attributes.codegen.naked.testing]
97-
A naked function cannot be attributed by [the testing attributes](../testing.md).
90+
A naked function cannot be attributed by [the testing attributes](attributes/testing.md).
9891

9992
r[attributes.codegen.no_builtins]
10093
## 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)