Skip to content

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

Closed
@androm3da

Description

@androm3da

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inline-assemblyArea: Inline assembly (`asm!(…)`)E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions