-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline assembly fails to compile after allowing inlining on the enclosing function for i686-pc-windows-msvc #106781
Comments
@rustbot +A-inline-assembly I am fairly certain that the compiler is allowed to make that compile, since it seems to be saving and restoring the registers that it needs to preserve. We can't guarantee that it will be able to do this however. speculation: The change in behavior due to inlining is likely a result of the compiler now having to allocate different registers (and running out) because of the surrounding context, without understanding that it could still preserve them? |
I came across this: #84658, so I thought the compiler was designed to reject it. If I understand you correctly, the compiler only rejects using reserved register if we explicitly ask for |
Correct. From the Reference:
We can never allow you to require LLVM to use a reserved register, since its reserved, but if LLVM gives it up willingly for som general purpose use, that is perfectly fine. |
I still think there's something strange going on with the fact that it stops compiling, but the fact that LLVM chooses a reserved register for a |
Gotcha, will change the title to a more appropriate one. |
Consider the following code:
which uses 7 registers. If we try to compile this on
i686-pc-windows-msvc
, in principle there are 7 general registers, but Rust Reference mentions thatebp
andesi
would be reserved, so I expect a compilation error.We can put this in a
lib.rs
, and inmain.rs
we put:Instead, when compiling in release mode using
cargo build --release --target i686-pc-windows-msvc
, it compiles.cargo asm --lib --target i686-pc-windows-msvc
reveals that the compiler does allocateesi
andebp
.cargo asm output
However, if we change
#[inline(never)]
to#[inline]
, the compiler correctly displays:I would expect a compilation error in both cases, and a guarantee that neither
esi
norebp
gets allocated.I haven't tried on
x86_64
target yet simply because the number of general registers is a lot. I could try it later today.Meta
Tried on both stable and nightly
rustc --version --verbose
:No backtrace available.
The text was updated successfully, but these errors were encountered: