Skip to content

[ICE]: rustc nightly SIGSEGV in llvm::LiveRange::join with -C opt-level=2 #161336

Description

@466774321-code

Code

pub static mut LIMIT: u16 = 16;
pub static mut TOTAL: u64 = 64;
pub static mut IS_GE: bool = false;
pub static mut IS_NE: bool = false;
pub static mut RUN: bool = false;

pub unsafe fn repro(x: u16) {
    if RUN {
        IS_GE = (x as i16) >= (LIMIT as i16);
        IS_NE = LIMIT != x;
        TOTAL = x as u64 + 630_600_177;
        panic!();
    }
}

Command used:

rustc +nightly --crate-type=lib -C opt-level=2 repro.rs

Meta

rustc --version --verbose:

rustc 1.100.0-nightly (8fa1c96cf 2026-08-17)
binary: rustc
commit-hash: 8fa1c96cfd489e4c27654c144ae871ce2c4db6c6
commit-date: 2026-08-17
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.0

Error output

error: rustc interrupted by SIGSEGV, printing backtrace

Backtrace:

librustc_driver-fb6ae9a3e0ae9f81.so
libc.so.6
libLLVM.so.23.1-rust-1.100.0-nightly
llvm::LiveRange::join(...)
libLLVM.so.23.1-rust-1.100.0-nightly
llvm::FPPassManager::runOnFunction(...)
llvm::FPPassManager::runOnModule(...)
llvm::legacy::PassManagerImpl::run(...)
librustc_driver-fb6ae9a3e0ae9f81.so
libc.so.6

Running with machine instruction verification:

rustc +nightly --crate-type=lib -C opt-level=2 \
  -Cllvm-args=-verify-machineinstrs repro.rs

produces:

# After Peephole Optimizations

*** Bad machine code: Virtual register defs don't dominate all uses. ***
- v. register: %9
rustc-LLVM ERROR: Found 1 machine code errors.

Disabling the peephole optimizer allows the code to compile:

rustc +nightly --crate-type=lib -C opt-level=2 \
  -Cllvm-args=-disable-peephole repro.rs

After finding this bug, I searched for related issues and found llvm/llvm-project#208746, which may have the same underlying cause.

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}T-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