Skip to content

Fix ICE when ABI computation fails for unreachable/no-codegen instances#152306

Open
rynewang wants to merge 1 commit intorust-lang:mainfrom
rynewang:fix/ice-152204-abi-check-unreachable
Open

Fix ICE when ABI computation fails for unreachable/no-codegen instances#152306
rynewang wants to merge 1 commit intorust-lang:mainfrom
rynewang:fix/ice-152204-abi-check-unreachable

Conversation

@rynewang
Copy link

@rynewang rynewang commented Feb 7, 2026

Summary

Fix ICE when ABI computation fails for monomorphized instances that never reach codegen.

Problem

check_instance_abi in abi_check.rs uses delayed_bug for ABI computation failures, assuming codegen will report the actual error. However, if the instance is in unreachable code or compiled with -Zno-codegen, codegen never processes it and the error goes unreported, causing the delayed_bug to fire as an ICE.

Reproducer (#152204)

#![feature(portable_simd)]
fn main() {
    if false {
        let _ = core::simd::Simd::<u8, 256>::splat(0);
    }
}

Reproducer (#149156)

#![crate_type = "lib"]
struct Struct([u8; 0xffff_ffff_ffff_ffff]);
pub fn function(value: Struct) -> u8 { value.0[0] }
// compile with: rustc -Zno-codegen

Fix

Replace delayed_bug with emit_err in check_instance_abi to report the layout error directly rather than deferring to codegen. FnAbiError already implements Diagnostic, so the existing error infrastructure handles all variants (SizeOverflow, InvalidSimd, etc.).

After this change:

#152204 emits: error: the SIMD type 'Simd<u8, 256>' has more elements than the limit 64
#149156 emits: error: values of the type '[u8; 18446744073709551615]' are too big for the target architecture
Includes regression test.

Fixes #152204
Fixes #149156

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 7, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 7, 2026

r? @JonathanBrouwer

rustbot has assigned @JonathanBrouwer.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 21 candidates
  • Random selection from 12 candidates

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rynewang rynewang force-pushed the fix/ice-152204-abi-check-unreachable branch from d3a17fa to 057b9bf Compare February 7, 2026 18:44
@rustbot

This comment has been minimized.

@Bryntet
Copy link
Contributor

Bryntet commented Feb 7, 2026

The comments in your files are overly verbose IMO

@rust-log-analyzer

This comment has been minimized.

@rynewang rynewang force-pushed the fix/ice-152204-abi-check-unreachable branch 2 times, most recently from 31d0744 to a508558 Compare February 7, 2026 20:01
@rynewang
Copy link
Author

rynewang commented Feb 7, 2026

Fixed the comments

@rust-log-analyzer

This comment has been minimized.

@rynewang rynewang force-pushed the fix/ice-152204-abi-check-unreachable branch from a508558 to 4e2469c Compare February 7, 2026 20:39
@workingjubilee
Copy link
Member

r? @workingjubilee

@rust-log-analyzer

This comment has been minimized.

@rynewang rynewang force-pushed the fix/ice-152204-abi-check-unreachable branch from 4e2469c to 8fb5312 Compare February 7, 2026 22:18
@rustbot

This comment has been minimized.

Replace delayed_bug with direct error emission in check_instance_abi,
since codegen may never process the instance (dead code or -Zno-codegen).
@rynewang rynewang force-pushed the fix/ice-152204-abi-check-unreachable branch from 8fb5312 to 84a3c4b Compare February 7, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE] when constructing Simd<u8, 256> in unreachable code ICE: -Zno-codegen: ABI computation failure should lead to compilation failure

6 participants