llvm lint: "unreachable immediately preceded by instruction without side effects"

9960342
Opened by Matthias Krüger at 2024-01-16 19:51:19

reduced from https://github.com/alexcrichton/rustc-demangle/

pub fn demangle(inner: &str) {
    inner.chars().peekable().by_ref().take(0).count();
}
$ RUSTFLAGS="-C passes=lint"  cargo build 

   Compiling rustc-demangle v0.1.5 (file:///tmp/rustc-demangle)
Unusual: unreachable immediately preceded by instruction without side effects
  unreachable, !dbg !33
    Finished dev [unoptimized + debuginfo] target(s) in 0.31 secs

//cc #7463

  1. @matthiaskrgr is this still relevant? I was not able to reproduce this with recent nightly.

    Ivan Stanković at 2023-10-24 14:21:02

  2. I can still reproduce this, compiling the example given above with rustc +nightly -Cpasses=lint -g t.rs --crate-type=lib --emit=llvm-ir gives me:

    Unusual: unreachable immediately preceded by instruction without side effects
      unreachable, !dbg !30
    

    Though I can't find that line in the actual LLVM IR output, even with -Cno-prepopulate-passes.

    Mark Rousskov at 2024-01-16 19:51:19