Skip to content

autodiff: Normalize typetree struct field types - #160701

Open
Dnreikronos wants to merge 2 commits into
rust-lang:mainfrom
Dnreikronos:autodiff/typetree_normalize_array_const
Open

autodiff: Normalize typetree struct field types#160701
Dnreikronos wants to merge 2 commits into
rust-lang:mainfrom
Dnreikronos:autodiff/typetree_normalize_array_const

Conversation

@Dnreikronos

@Dnreikronos Dnreikronos commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #160635

-Zautodiff=Enable was ICEing on structs with fields like *mut [f32; N]. FieldDef::ty returns Unnormalized, and we were just calling skip_norm_wip, so recursion hit struct_tail_for_codegen with an unevaluated anon const length. Same root cause also quietly emptied TypeTrees for plain [T; N] fields, fyi.

Now we normalize with TypingEnv::fully_monomorphized before walking struct fields. Imo that's the right call here: we're already post-mono in codegen, and it lines up with the Unnormalized WIP migration instead of spreading more skip_norm_wip around. Btw I added a run-make regression covering both faces of the bug.

Idk if Enzyme will still choke on murkier shadow-pointer cases irl, but at least rustc stops panicking. Ltm if the FileCheck strings look too layout-locked for other targets and I can loosen them asap.

FieldDef::ty returns Unnormalized, so skipping normalization left
anon-const array lengths unevaluated. That ICEd in
struct_tail_for_codegen and emptied TypeTrees for plain [T; N] fields.
Normalize with TypingEnv::fully_monomorphized before recursing.
Cover both the ICE path through *mut [T; N] struct fields and the
silent empty-TypeTree case for plain [T; N] fields.
@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs 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 Aug 7, 2026
@rustbot

rustbot commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

r? @davidtwco

rustbot has assigned @davidtwco.
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 75 candidates
  • Random selection from 20 candidates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs 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]: autodiff fails compiling gemm-f32 microkernel

3 participants