Skip to content

Commit 9a50ef2

Browse files
committed
changes after code review
also maybe make links work?
1 parent c98b9ba commit 9a50ef2

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

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

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

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

9790
r[attributes.codegen.naked.testing]
98-
A naked function cannot be attributed by [the testing attributes](../testing.md).
91+
A naked function cannot be attributed by [the testing attributes](attributes/testing.md).
9992

10093
r[attributes.codegen.no_builtins]
10194
## The `no_builtins` attribute

src/inline-assembly.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Note that in some cases the compiler may choose to emit the assembly code as a s
7878

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

8383
r[asm.scope.global_asm]
8484
With the `global_asm!` macro, the assembly code is emitted in a global scope, outside a function.
@@ -581,7 +581,7 @@ r[asm.options.checks.noreturn]
581581
- It is a compile-time error to specify `noreturn` on an asm block with outputs.
582582

583583
r[asm.options.naked_asm-restriction]
584-
`global_asm!` only supports the `att_syntax` and `raw` options.
584+
`naked_asm!` only supports the `att_syntax` and `raw` options.
585585
The remaining options are not meaningful because the inline assembly defines the whole function body.
586586

587587
r[asm.options.global_asm-restriction]
@@ -710,7 +710,7 @@ r[asm.naked-rules.reg-not-input]
710710
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).
711711

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

716716
r[asm.naked-rules.unwind]
@@ -719,6 +719,7 @@ r[asm.naked-rules.unwind]
719719

720720
r[asm.naked-rules.noreturn]
721721
- Behavior is undefined if execution falls through to the end of the asm block.
722+
- the assembly code is expected to contain a return instruction or to diverge
722723

723724
r[asm.naked-rules.mem-same-as-ffi]
724725
- The set of memory locations that assembly code is allowed to read and write are the same as those allowed for an FFI function.
@@ -731,10 +732,6 @@ r[asm.naked-rules.black-box]
731732
- Runtime code patching is allowed, via target-specific mechanisms.
732733
- 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.
733734

734-
r[asm.naked-rules.not-exactly-once]
735-
- You cannot assume that an `naked_asm!` block will appear exactly once in the output binary.
736-
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.
737-
738735
r[asm.validity]
739736
### Correctness and Validity
740737

0 commit comments

Comments
 (0)