From ed33f7550cdf82690a953924ade76098bdb37a34 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 26 Dec 2023 17:46:45 +0100 Subject: [PATCH 1/2] pure asm blocks must terminate --- src/inline-assembly.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/inline-assembly.md b/src/inline-assembly.md index e905fcb26..ec57390da 100644 --- a/src/inline-assembly.md +++ b/src/inline-assembly.md @@ -413,6 +413,7 @@ The list of clobbered registers for each ABI is updated in rustc as architecture Flags are used to further influence the behavior of the inline assembly block. Currently the following options are defined: - `pure`: The `asm!` block has no side effects, and its outputs depend only on its direct inputs (i.e. the values themselves, not what they point to) or values read from memory (unless the `nomem` options is also set). + The `asm!` block must always terminate. This allows the compiler to execute the `asm!` block fewer times than specified in the program (e.g. by hoisting it out of a loop) or even eliminate it entirely if the outputs are not used. The `pure` option must be combined with either the `nomem` or `readonly` options, otherwise a compile-time error is emitted. - `nomem`: The `asm!` blocks does not read or write to any memory. From 8eda943339b7033205604386472d3e6e1dfa28ed Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 26 Dec 2023 18:28:15 +0100 Subject: [PATCH 2/2] adjust wording Co-authored-by: Amanieu d'Antras --- src/inline-assembly.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/inline-assembly.md b/src/inline-assembly.md index ec57390da..414a36b90 100644 --- a/src/inline-assembly.md +++ b/src/inline-assembly.md @@ -412,8 +412,7 @@ The list of clobbered registers for each ABI is updated in rustc as architecture Flags are used to further influence the behavior of the inline assembly block. Currently the following options are defined: -- `pure`: The `asm!` block has no side effects, and its outputs depend only on its direct inputs (i.e. the values themselves, not what they point to) or values read from memory (unless the `nomem` options is also set). - The `asm!` block must always terminate. +- `pure`: The `asm!` block has no side effects, must eventually return, and its outputs depend only on its direct inputs (i.e. the values themselves, not what they point to) or values read from memory (unless the `nomem` options is also set). This allows the compiler to execute the `asm!` block fewer times than specified in the program (e.g. by hoisting it out of a loop) or even eliminate it entirely if the outputs are not used. The `pure` option must be combined with either the `nomem` or `readonly` options, otherwise a compile-time error is emitted. - `nomem`: The `asm!` blocks does not read or write to any memory.