Skip to content

assertion failure w/(invalid?) inline assembly #28604

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
androm3da opened this issue Sep 23, 2015 · 1 comment
Closed

assertion failure w/(invalid?) inline assembly #28604

androm3da opened this issue Sep 23, 2015 · 1 comment
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@androm3da
Copy link
Contributor

This example fails w/an assertion error:

http://is.gd/GsxTMy

rustc: /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h:169: unsigned int llvm::FunctionLoweringInfo::InitializeRegForValue(const llvm::Value*): Assertion `R == 0 && "Already initialized this value register!"' failed.
Aborted (core dumped)

Source:

#![feature(asm)]

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
fn get_timer() -> i32 {
    let tsc: i32;
    unsafe {
        asm!("nop": "=a"(tsc));
    }
    tsc
}

fn main() {
    println!("Val: {}", get_timer());
}

Correcting the "=a"(tsc) to be "=A"(tsc) makes the assertion error go away.

@steveklabnik steveklabnik added A-inline-assembly Area: Inline assembly (`asm!(…)`) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Sep 23, 2015
abhijeetbhagat added a commit to abhijeetbhagat/glacier that referenced this issue Nov 2, 2015
steveklabnik added a commit to rust-lang/glacier that referenced this issue Nov 4, 2015
@19h
Copy link

19h commented Jan 16, 2017

This code does not compile in the latest nightly, although the correct variant does. I'd consider this bug fixed.

@sfackler sfackler added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jan 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants