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

@omasanori

Description

@omasanori

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions