Skip to content
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

compiler abort in LLVM code when using a newtype-wrapper as an argument #15402

Closed
TethysSvensson opened this issue Jul 4, 2014 · 9 comments
Closed
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way.

Comments

@TethysSvensson
Copy link
Contributor

The following program will cause an abort in llvm/lib/IR/InlineAsm.cpp:

#![feature(asm)]

pub struct Wrapper(uint);

fn main() {
    let mut value: Wrapper = Wrapper(7);
    unsafe {
        asm!("mov %eax, $0" : "+r"(value));
    }
}

The error message I get is:

rustc: /build/buildd/rust-nightly-201407030406~67776ba~utopic/src/llvm/lib/IR/InlineAsm.cpp:47: llvm::InlineAsm::InlineAsm(llvm::PointerType*, const string&, const string&, bool, bool, llvm::InlineAsm::AsmDialect): Assertion `Verify(getFunctionType(), constraints) && "Function type not legal for constraints!"' failed.
Aborted (core dumped)

I am using the rust nightly build version 20140703040667776bautopic.

@steveklabnik steveklabnik added the A-inline-assembly Area: Inline assembly (`asm!(…)`) label Jan 23, 2015
@richo
Copy link
Contributor

richo commented Apr 6, 2015

Just ran into this again, however for a lot of this year this worked, as I wrote some code that does this.

@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Apr 6, 2015
@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

This once again does not ICE:

#![feature(asm)]

pub struct Wrapper(u32);

fn main() {
    let mut value: Wrapper = Wrapper(7);
    unsafe {
        asm!("mov %eax, $0" : "+r"(value));
    }
}

@steveklabnik E-needstest?

@jooert
Copy link
Contributor

jooert commented May 11, 2015

With LLVM assertions enabled, this still fails with the same error message.

@jethrogb
Copy link
Contributor

The error depends on the exact asm invocation.

#![feature(asm)]

#[repr(packed)]
struct Bitfield<T>(T);

fn test()->(Bitfield<u32>,Bitfield<u32>) {
    let mut out=(Bitfield(0),Bitfield(0));
    unsafe{asm!("" : "={eax}"(out.0), "={ebx}"(out.1))};
    out
}

fn main() {
    test();
}

yields:

Unknown type!
UNREACHABLE executed at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/IR/ValueTypes.cpp:253!

While this

#![feature(asm)]

#[repr(packed)]
struct Bitfield<T>(T);

fn test()->(Bitfield<u32>,Bitfield<u32>) {
    let mut out=(Bitfield(0),Bitfield(0));
    unsafe{asm!("" : "={eax}"(out.0))};
    out
}

fn main() {
    test();
}

yields:

rustc: /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/IR/InlineAsm.cpp:47: llvm::InlineAsm::InlineAsm(llvm::PointerType*, const string&, const string&, bool, bool, llvm::InlineAsm::AsmDialect): Assertion `Verify(getFunctionType(), constraints) && "Function type not legal for constraints!"' failed.

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 21, 2017
@chordowl
Copy link
Contributor

Triage: still reproduces

rustc: /checkout/src/llvm/lib/IR/InlineAsm.cpp:46: llvm::InlineAsm::InlineAsm(llvm::FunctionType*, const string&, const string&, bool, bool, llvm::InlineAsm::AsmDialect): Assertion `Verify(getFunctionType(), constraints) && "Function type not legal for constraints!"' failed.
error: Could not compile `playground`.

@steveklabnik
Copy link
Member

This no longer ICEs!

@petrochenkov
Copy link
Contributor

Because LLVM assertions were disabled on nightly #45810

@petrochenkov petrochenkov reopened this Nov 19, 2017
@pnkfelix
Copy link
Member

pnkfelix commented Jun 3, 2019

ICE is dependent on feature(asm) (cc #29722), which is not on the 2019 roadmap. Marking as P-medium until we get an overall plan for asm in Rust. (Although the fact that this can cause rustc itself to segfault, presumably via a problem internal to LLVM, does lead me to wonder if I should up the priority to P-high anyway.)

@pnkfelix pnkfelix added the P-medium Medium priority label Jun 3, 2019
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 15, 2019
@Centril Centril added the requires-nightly This issue requires a nightly compiler in some way. label Oct 25, 2019
@Amanieu
Copy link
Member

Amanieu commented May 22, 2020

This issue does not apply to the new asm! (RFC 2850) which has stricter checks on the types that can be used as asm operands.

The legacy llvm_asm! is deprecated and is no longer maintained.

@Amanieu Amanieu closed this as completed May 22, 2020
fanninpm added a commit to fanninpm/glacier that referenced this issue Jan 27, 2021
The legacy `llvm_asm!` macro is deprecated and no longer maintained.

Issue: rust-lang/rust#15402
JohnTitor pushed a commit to rust-lang/glacier that referenced this issue Jan 27, 2021
The legacy `llvm_asm!` macro is deprecated and no longer maintained.

Issue: rust-lang/rust#15402
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!(…)`) C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

No branches or pull requests