Skip to content

Instruction does not dominate all uses LLVM error in a pattern match with a ref pattern and dereference of a box #15892

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

Closed
omasanori opened this issue Jul 22, 2014 · 5 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@omasanori
Copy link
Contributor

The functions below are OK:

fn foo1(x: Option<Box<int>>) -> Option<int> {
    let res = match x {
        Some(ref v) => v.clone(),
        None => return None
    };
    Some(*res)
}
fn foo2(x: Option<Box<int>>) -> Option<int> {
    let res = match x {
        Some(ref v) => Some(*v.clone()),
        None => return None
    };
    return res;
}

but:

fn foo3(x: Option<Box<int>>) -> Option<int> {
    let res = match x {
        Some(ref v) => *v.clone(),
        None => return None
    };
    Some(res)
}

produces a LLVM ERROR. The message is:

Instruction does not dominate all uses!
%8 = load i64** %2
%12 = bitcast i64* %8 to i8*
LLVM ERROR: Broken function found, compilation aborted!

I'm sorry if it isn't a minimum example of this issue.

@omasanori omasanori changed the title Instruction does not dominate all uses error with a pattern match with a ref pattern and redeferencing a box Instruction does not dominate all uses error with a pattern match, ref patterns and dereferencing a box Jul 22, 2014
@omasanori omasanori changed the title Instruction does not dominate all uses error with a pattern match, ref patterns and dereferencing a box Instruction does not dominate all uses LLVM error in a pattern match with a ref pattern and dereferencing a box Jul 22, 2014
@omasanori omasanori changed the title Instruction does not dominate all uses LLVM error in a pattern match with a ref pattern and dereferencing a box Instruction does not dominate all uses LLVM error in a pattern match with a ref pattern and dereference of a box Jul 22, 2014
@nixpulvis
Copy link

On a related note (I think)

This works:

  fn tail(&self) -> LinkedList {
    match *self {
      Cons(_, ref l) => {
        *l.clone()
      },
      _ => fail!("called `tail` on Empty"),
    }
  }

But this doesn't with the same LLVM error.

  fn tail(&self) -> LinkedList {
    match *self {
      Cons(_, ref l) => *l.clone(),
      _ => fail!("called `tail` on Empty"),
    }
  }
Instruction does not dominate all uses!
  %12 = load %"enum.data::list::LinkedList<[]>"** %2
  %23 = bitcast %"enum.data::list::LinkedList<[]>"* %12 to i8*
LLVM ERROR: Broken function found, compilation aborted!

@ghost
Copy link

ghost commented Aug 13, 2014

cc @luqmana

@ghost
Copy link

ghost commented Sep 21, 2014

It's very subtle.

The following ICEs:

#[deriving(Clone)]
enum LinkedList { Cons(Box<uint>), Nil }

impl LinkedList {
    fn tail(self) -> uint {
        match self {
          Nil => 1u,
          Cons(l) => *l.clone()
        }
    }
}

fn main() { }

But this is okay:

#[deriving(Clone)]
enum LinkedList { Cons(Box<uint>), Nil }

impl LinkedList {
    fn tail(self) -> uint {
        match self {
          Nil => 1u,
          Cons(l) => (*l.clone()) // Notice the extra parens.
        }
    }
}

fn main() { }

@ghost
Copy link

ghost commented Sep 21, 2014

Seems specific to Box that still has special treatment in cleanup.

@steveklabnik
Copy link
Member

#18845 is a dup that has a smaller test case, so I'm giving this a close in favor of that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants