Skip to content

rustc fails with: LLVM ERROR: Broken function found, compilation aborted! #25497

Closed
@niconiconico9

Description

@niconiconico9

Rust compiler (rustc 1.1.0-nightly (e539424 2015-05-14) (built 2015-05-14) fails to compile this source:

#![feature(box_patterns)]

mod test {
    #[derive(Debug)]
    #[derive(Clone)]
    pub enum Expression {
        Var(String),
        Const(i64),
        Add(Box<Expression>, Box<Expression>),
        Mul(Box<Expression>, Box<Expression>)
    }

    pub use self::Expression::*;

    fn simplify1(exp: &Expression) -> Expression {
        match *exp {
            Add(box Const(0), ref n) | Add(ref n, box Const(0)) => *n.clone(),
            Mul(box Const(1), ref n) | Mul(ref n, box Const(1)) => *n.clone(),
            Mul(box Const(0), _) | Mul(_, box Const(0)) => Const(0),
            Add(box Const(n), box Const(m)) => Const(n + m),
            Mul(box Const(n), box Const(m)) => Const(n * m),
            _ => exp.clone()
        }
    }

    pub fn simplify(exp: &Expression) -> Expression {
        match *exp {
            Add(ref n, ref m) => simplify1(&(Add(Box::new(simplify1(n)), Box::new(simplify1(m))))),
            Mul(ref n, ref m) => simplify1(&(Add(Box::new(simplify1(n)), Box::new(simplify1(m))))),
            _ => exp.clone()
        }
    }
}
fn main() {
    use test::*;
    let e = Add(Box::new(Const(1)), Box::new(Const(29)));
    let e1 = simplify(&e);
    println!("{:?}", e1);
}

With the error:

Instruction does not dominate all uses!
  %10 = load %"test::Expression"** %2, align 8, !nonnull !0
  %96 = bitcast %"test::Expression"* %10 to i8*
Instruction does not dominate all uses!
  %91 = load %"test::Expression"** %3, align 8, !nonnull !0
  %99 = bitcast %"test::Expression"* %91 to i8*
Instruction does not dominate all uses!
  %10 = load %"test::Expression"** %2, align 8, !nonnull !0
  %100 = bitcast %"test::Expression"* %10 to i8*
Instruction does not dominate all uses!
  %91 = load %"test::Expression"** %3, align 8, !nonnull !0
  %102 = bitcast %"test::Expression"* %91 to i8*
Instruction does not dominate all uses!
  %10 = load %"test::Expression"** %2, align 8, !nonnull !0
  %103 = bitcast %"test::Expression"* %10 to i8*
LLVM ERROR: Broken function found, compilation aborted!

I can reproduce this ICE also on play.rust-lang.org

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-codegenArea: Code generation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions