Skip to content

ICE: Assertion `R == 0 && "Already initialized this value register!"' failed #24799

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

Closed
strega-nil opened this issue Apr 25, 2015 · 4 comments
Closed

Comments

@strega-nil
Copy link
Contributor

With the asm! templates.

You can see the code at https://github.com/GBGamer/os-dev/blob/master/kernel/low_level.rs

The specific assertion is:

rustc --emit=obj --target=i686-unknown-linux-gnu -C no-stack-check -C relocation-model=dynamic-no-pic --crate-type lib -L kernel/deps kernel/lib.rs -o kernel/lib.o
rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h:158: unsigned int llvm::FunctionLoweringInfo::InitializeRegForValue(const llvm::Value*): Assertion `R == 0 && "Already initialized this value register!"' failed.
make: *** [kernel/lib.o] Aborted (core dumped)
@strega-nil
Copy link
Contributor Author

If you're wondering why this assert is running, it's because I'm using intel syntax without specifying the intel syntax option.

Actually, no, I attempted to change it, and it didn't work...

@strega-nil
Copy link
Contributor Author

The smallest program that shows this behavior:

#![feature(asm)]

fn main() {
    let mut _test: u32;
    unsafe {
        asm!("mov $2, %eax" : "=a"(_test));
    }
}

@huonw
Copy link
Member

huonw commented Apr 25, 2015

Register constraints are written with {...name...}, and literals with double $$ (this design is definitely subpar and is part of the reason that asm! is unstable). The following compiles fine:

#![feature(asm)]

fn main() {
    let mut _test: u32;
    unsafe {
        asm!("mov $$2, %eax" : "={ax}"(_test));
    }
}

(It's not necessary to specify the exact width.)

Thanks for filing but this isn't a bug.

@huonw huonw closed this as completed Apr 25, 2015
@strega-nil
Copy link
Contributor Author

@huonw It is still a bug. There is an llvm assertion here. Even if this isn't correct, there should not be an llvm assertion.

If this is true, then it's a bug with the documentation, where it still shows this syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants