Skip to content

Commit 2435b17

Browse files
committed
changes after code review
also maybe make links work?
1 parent 906273c commit 2435b17

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

src/attributes/codegen.md

+5-12
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,11 @@ No function prologue or epilogue are generated for the attributed function: the
6868
of the `naked_asm!` invocation make up the full body of a naked function.
6969

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

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

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

9891
r[attributes.codegen.naked.testing]
99-
A naked function cannot be attributed by [the testing attributes](../testing.md).
92+
A naked function cannot be attributed by [the testing attributes](attributes/testing.md).
10093

10194
## The `no_builtins` attribute
10295

src/inline-assembly.md

+4-13
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Note that in some cases the compiler may choose to emit the assembly code as a s
8080

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

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

592592
r[asm.options.naked_asm-restriction]
593-
`global_asm!` only supports the `att_syntax` and `raw` options.
593+
`naked_asm!` only supports the `att_syntax` and `raw` options.
594594
The remaining options are not meaningful because the inline assembly defines the whole function body.
595595

596596
r[asm.options.global_asm-restriction]
@@ -721,7 +721,7 @@ r[asm.naked-rules.reg-not-input]
721721
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).
722722

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

727727
r[asm.naked-rules.unwind]
@@ -730,22 +730,13 @@ r[asm.naked-rules.unwind]
730730

731731
r[asm.naked-rules.noreturn]
732732
- Behavior is undefined if execution falls through to the end of the asm block.
733+
- the assembly code is expected to contain a return instruction or to diverge
733734

734735
r[asm.naked-rules.mem-same-as-ffi]
735736
- The set of memory locations that assembly code is allowed to read and write are the same as those allowed for an FFI function.
736737
- Refer to the unsafe code guidelines for the exact rules.
737738
- These rules do not apply to memory which is private to the asm code, such as stack space allocated within the asm block.
738739

739-
r[asm.naked-rules.black-box]
740-
- The compiler cannot assume that the instructions in the asm are the ones that will actually end up executed.
741-
- This effectively means that the compiler must treat the `naked_asm!` as a black box and only take the interface specification into account, not the instructions themselves.
742-
- Runtime code patching is allowed, via target-specific mechanisms.
743-
- 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.
744-
745-
r[asm.naked-rules.not-exactly-once]
746-
- You cannot assume that an `naked_asm!` block will appear exactly once in the output binary.
747-
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.
748-
749740
### Correctness and Validity
750741

751742
r[asm.validity]

0 commit comments

Comments
 (0)