Skip to content

Commit 23be8ef

Browse files
committed
changes after code review
also maybe make links work?
1 parent 1775156 commit 23be8ef

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

src/attributes/codegen.md

Lines changed: 5 additions & 12 deletions
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

Lines changed: 4 additions & 13 deletions
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.
@@ -588,7 +588,7 @@ r[asm.options.checks.noreturn]
588588
- It is a compile-time error to specify `noreturn` on an asm block with outputs.
589589

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

594594
r[asm.options.global_asm-restriction]
@@ -719,7 +719,7 @@ r[asm.naked-rules.reg-not-input]
719719
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).
720720

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

725725
r[asm.naked-rules.unwind]
@@ -728,22 +728,13 @@ r[asm.naked-rules.unwind]
728728

729729
r[asm.naked-rules.noreturn]
730730
- Behavior is undefined if execution falls through to the end of the asm block.
731+
- the assembly code is expected to contain a return instruction or to diverge
731732

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

737-
r[asm.naked-rules.black-box]
738-
- The compiler cannot assume that the instructions in the asm are the ones that will actually end up executed.
739-
- 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.
740-
- Runtime code patching is allowed, via target-specific mechanisms.
741-
- 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.
742-
743-
r[asm.naked-rules.not-exactly-once]
744-
- You cannot assume that an `naked_asm!` block will appear exactly once in the output binary.
745-
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.
746-
747738
### Correctness and Validity
748739

749740
r[asm.validity]

0 commit comments

Comments
 (0)