Skip to content

Commit 3a652a2

Browse files
committed
changes after code review
also maybe make links work?
1 parent e989e49 commit 3a652a2

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

src/attributes/codegen.md

+5-12
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

+4-7
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.
@@ -1186,7 +1186,7 @@ unsafe { core::arch::asm!("mov {:e}, 1", out(reg) z, options(noreturn)); }
11861186
```
11871187

11881188
r[asm.options.naked_asm-restriction]
1189-
`global_asm!` only supports the `att_syntax` and `raw` options.
1189+
`naked_asm!` only supports the `att_syntax` and `raw` options.
11901190
The remaining options are not meaningful because the inline assembly defines the whole function body.
11911191

11921192
r[asm.options.global_asm-restriction]
@@ -1356,7 +1356,7 @@ r[asm.naked-rules.reg-not-input]
13561356
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).
13571357

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

13621362
r[asm.naked-rules.unwind]
@@ -1365,6 +1365,7 @@ r[asm.naked-rules.unwind]
13651365

13661366
r[asm.naked-rules.noreturn]
13671367
- Behavior is undefined if execution falls through to the end of the asm block.
1368+
- the assembly code is expected to contain a return instruction or to diverge
13681369

13691370
r[asm.naked-rules.mem-same-as-ffi]
13701371
- The set of memory locations that assembly code is allowed to read and write are the same as those allowed for an FFI function.
@@ -1377,10 +1378,6 @@ r[asm.naked-rules.black-box]
13771378
- Runtime code patching is allowed, via target-specific mechanisms.
13781379
- 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.
13791380

1380-
r[asm.naked-rules.not-exactly-once]
1381-
- You cannot assume that an `naked_asm!` block will appear exactly once in the output binary.
1382-
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.
1383-
13841381
r[asm.validity]
13851382
### Correctness and Validity
13861383

0 commit comments

Comments
 (0)