Skip to content

Commit

Permalink
Rollup merge of #90533 - Smittyvb:patch-1, r=joshtriplett
Browse files Browse the repository at this point in the history
Add note about x86 instruction prefixes in asm! to unstable book

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. AFAICT x86 is the only instruction set with instruction prefixes.
  • Loading branch information
JohnTitor authored Nov 5, 2021
2 parents 282d696 + 773cc4f commit dbaf2de
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/doc/unstable-book/src/library-features/asm.md
Original file line number Diff line number Diff line change
Expand Up @@ -885,5 +885,7 @@ The compiler performs some additional checks on options:
- You are responsible for switching any target-specific state (e.g. thread-local storage, stack bounds).
- The set of memory locations that you may access is the intersection of those allowed by the `asm!` blocks you entered and exited.
- 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.
- On x86, inline assembly must not end with an instruction prefix (such as `LOCK`) that would apply to instructions generated by the compiler.
- The compiler is currently unable to detect this due to the way inline assembly is compiled, but may catch and reject this in the future.

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

0 comments on commit dbaf2de

Please sign in to comment.