Skip to content

ICE: void llvm::Value::replaceAllUsesWith(llvm::Value*): Assertion `!contains(New, this) && "this->replaceAllUsesWith(expr(this)) is NOT valid!"' failed. #36474

Closed
@bluss

Description

@bluss

This is a recently introduced ICE that appears with -Copt-level=3

using rustc 1.13.0-nightly (5531c31 2016-09-12)

rustc: /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/llvm/lib/IR/Value.cpp:373: void llvm::Value::replaceAllUsesWith(llvm::Value*): Assertion `!contains(New, this) && "this->replaceAllUsesWith(expr(this)) is NOT valid!"' failed.

Shrunk test case below (original is in ndarray tests/dimension.rs). Use rustc -Copt-level=3 to reproduce.

fn main() {
    remove_axis(&3, 0);
}

trait Dimension {
    fn slice(&self) -> &[usize];
}

impl Dimension for () {
    fn slice(&self) -> &[usize] { &[] }
}

impl Dimension for usize {
    fn slice(&self) -> &[usize] {
        unsafe {
            ::std::slice::from_raw_parts(self, 1)
        }
    }
}

fn remove_axis(value: &usize, axis: usize) -> () {
    let tup = ();
    let mut it = tup.slice().iter();
    for (i, _) in value.slice().iter().enumerate() {
        if i == axis {
            continue;
        }
        it.next();
    }
}

(Edits: Reduced test case further)

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions