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

DataflowConstProp trips LLVM assertion "Invalid constexpr bitcast!" #118047

Closed
saethlin opened this issue Nov 18, 2023 · 2 comments · Fixed by #118791
Closed

DataflowConstProp trips LLVM assertion "Invalid constexpr bitcast!" #118047

saethlin opened this issue Nov 18, 2023 · 2 comments · Fixed by #118791
Assignees
Labels
A-mir-opt Area: MIR optimizations C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@saethlin
Copy link
Member

saethlin commented Nov 18, 2023

Reduced from core:

pub struct State {
    inner: bool
}

pub fn make() -> State {
    State {
        inner: true,
    }
}
rustc +master-stage1 -Zmir-opt-level=0 -Zmir-enable-passes=+DataflowConstProp --crate-type=lib

Compilation should crash with this error:

rustc: /checkout/src/llvm-project/llvm/lib/IR/Constants.cpp:2216: static Constant *llvm::ConstantExpr::getBitCast(Constant *, Type *, bool): Assertion `CastInst::castIsValid(Instruction::BitCast, C, DstTy) && "Invalid constantexpr bitcast!"' failed.
error: could not compile `core` (lib)

Because we are trying to generate an LLVM bitcast from i1 to i8.

The MIR dump looks like this:

fn make() -> State {
    let mut _0: State;

    bb0: {
        _0 = const State {{ inner: true }};
        return;
    }
}

alloc3 (size: 1, align: 1) {
    01.
}

I haven't been able to figure out how to produce this MIR without DataflowConstProp.

@saethlin saethlin added the C-bug Category: This is a bug. label Nov 18, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 18, 2023
@saethlin saethlin added I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 18, 2023
@saethlin

This comment was marked as outdated.

@saethlin saethlin changed the title Extreme MIR inlining + DataflowConstProp + debuginfo=2 trips LLVM assertion "Invalid constexpr bitcast!" DataflowConstProp trips LLVM assertion "Invalid constexpr bitcast!" Nov 28, 2023
@saethlin saethlin removed the A-mir-opt-inlining Area: MIR inlining label Nov 28, 2023
@saethlin
Copy link
Member Author

saethlin commented Nov 28, 2023

@tmiasko You asked about this crash before when I had a messy reproducer. Pinging you now because it's a lot smaller. Still not elegant though. it is now

@saethlin saethlin self-assigned this Dec 10, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 10, 2023
Use immediate_backend_type when reading from a const alloc

Fixes rust-lang#118047

r? `@nikic`
@bors bors closed this as completed in 7e452c1 Dec 10, 2023
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Dec 12, 2023
Use immediate_backend_type when reading from a const alloc

Fixes rust-lang/rust#118047

r? `@nikic`
lnicola pushed a commit to lnicola/rust-analyzer that referenced this issue Apr 7, 2024
Use immediate_backend_type when reading from a const alloc

Fixes rust-lang/rust#118047

r? `@nikic`
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 27, 2024
Use immediate_backend_type when reading from a const alloc

Fixes rust-lang/rust#118047

r? `@nikic`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations C-bug Category: This is a bug. I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants