Skip to content

Commit aca530a

Browse files
committed
Clarify rules on callee/caller saved registers
For naked functions, let's break out the rules for callee and caller saved registers and name the rule identifiers more clearly. For the caller saved registers, let's drop the caveat about "even if they are not used for the return value", as it doesn't really add anything to the rule.
1 parent ac16cab commit aca530a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: src/inline-assembly.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1390,9 +1390,11 @@ r[asm.naked-rules.reg-not-input]
13901390
- Any registers not used for function inputs according to the calling convention and function signature will contain an undefined value on entry to the `naked_asm!` block.
13911391
- An "undefined value" in the context of inline assembly means that the register can (non-deterministically) have any one of the possible values allowed by the architecture. 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).
13921392

1393-
r[asm.naked-rules.reg-not-output]
1394-
- Any callee-saved registers must have the same value upon return as they had on entry.
1395-
- Caller-saved registers may be used freely, even if they are not used for the return value.
1393+
r[asm.naked-rules.callee-saved-registers]
1394+
- All callee-saved registers must have the same value upon return as they had on entry.
1395+
1396+
r[asm.naked-rules.caller-saved-registers]
1397+
- Caller-saved registers may be used freely.
13961398

13971399
r[asm.naked-rules.noreturn]
13981400
- Behavior is undefined if execution falls through past the end of the assembly code.

0 commit comments

Comments
 (0)