From 0ca49063b448db63517aed8a0d7e0160624ccaa1 Mon Sep 17 00:00:00 2001 From: Lukas Markeffsky <@> Date: Fri, 30 Aug 2024 12:53:47 +0200 Subject: [PATCH] asm!: clarify that `nomem` / `readonly` can access "private" memory --- src/inline-assembly.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/inline-assembly.md b/src/inline-assembly.md index 9dd02e2fc..3ad16a600 100644 --- a/src/inline-assembly.md +++ b/src/inline-assembly.md @@ -505,12 +505,12 @@ r[asm.options.supported-options.pure] The `pure` option must be combined with either the `nomem` or `readonly` options, otherwise a compile-time error is emitted. r[asm.options.supported-options.nomem] -- `nomem`: The `asm!` blocks does not read or write to any memory. +- `nomem`: The `asm!` block does not read from or write to any memory accessible outside of the `asm!` block. This allows the compiler to cache the values of modified global variables in registers across the `asm!` block since it knows that they are not read or written to by the `asm!`. The compiler also assumes that this `asm!` block does not perform any kind of synchronization with other threads, e.g. via fences. r[asm.options.supported-options.readonly] -- `readonly`: The `asm!` block does not write to any memory. +- `readonly`: The `asm!` block does not write to any memory accessible outside of the `asm!` block. This allows the compiler to cache the values of unmodified global variables in registers across the `asm!` block since it knows that they are not written to by the `asm!`. The compiler also assumes that this `asm!` block does not perform any kind of synchronization with other threads, e.g. via fences.