Skip to content

Commit fdb6bda

Browse files
authored
Add note about x86 instruction prefixes in asm!
Since rustc doesn't do the assembly parsing itself, it is unable to detect when inline assembly ends with an instruction prefix, which doesn't make sense since it would apply to instructions from the compiler. This fixes #82314 by mentioning that x86 instruction prefixes must not be used in inline assembly.
1 parent 3831aaa commit fdb6bda

File tree

1 file changed

+2
-0
lines changed
  • src/doc/unstable-book/src/library-features

1 file changed

+2
-0
lines changed

src/doc/unstable-book/src/library-features/asm.md

+2
Original file line numberDiff line numberDiff line change
@@ -885,5 +885,7 @@ The compiler performs some additional checks on options:
885885
- You are responsible for switching any target-specific state (e.g. thread-local storage, stack bounds).
886886
- The set of memory locations that you may access is the intersection of those allowed by the `asm!` blocks you entered and exited.
887887
- You cannot assume that an `asm!` block will appear exactly once in the output binary. The compiler is allowed to instantiate multiple copies of the `asm!` block, for example when the function containing it is inlined in multiple places.
888+
- On x86, inline assembly must not end with an instruction prefix (such as `LOCK`) that would apply to instructions generated by the compiler.
889+
- The compiler is currently unable to detect this due to the way inline assembly is compiled.
888890

889891
> **Note**: As a general rule, the flags covered by `preserves_flags` are those which are *not* preserved when performing a function call.

0 commit comments

Comments
 (0)