Skip to content

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

Closed
@saethlin

Description

@saethlin

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.

Metadata

Metadata

Assignees

Labels

A-mir-optArea: MIR optimizationsC-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions