Preserve types on reverse cache reloads - #3156
Merged
Merged
Conversation
Attach the original TypeTree to values restored from reverse caches so nested differentiation can classify cached integer loop indices. Assisted-by: OpenAI Codex
Assisted-by: OpenAI Codex
wsmoses
approved these changes
Aug 20, 2026
vimarsh6739
enabled auto-merge
August 20, 2026 17:03
Member
|
Ah claude came up with a similar fix in #3202 |
wsmoses
disabled auto-merge
September 10, 2026 16:06
vchuravy
added a commit
that referenced
this pull request
Sep 10, 2026
#3156 records the original TypeTree as `!enzyme_type` on values restored from reverse caches, but attaches whatever `TR.query` returns without checking it against the reload's register size. `TypeAnalyzer::considerTBAA` does check, and treats a violation as fatal: if ((size_t)pair.first[0] >= RegSize) { llvm::errs() << " bad enzyme_type " << TT.str() << ...; llvm::report_fatal_error("Canonicalization failed"); } So a tree with an offset past the register size does not degrade the analysis, it aborts the next type analysis run over the generated function -- which is exactly the nested-differentiation case (forward-over-reverse) the metadata was added to serve. Apply the same range check before setting the metadata and drop the tree when it does not hold. Dropping only returns that reload to the pre-#3156 behaviour of an untyped load, which is the conservative direction. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RD6pJCuKKB1n9L8k2orUua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverse cache reloads created by
lookupMdropped the original TypeTree. Preserve it asenzyme_typemetadata so nested differentiation can classify cached integer loop indices.Adds a focused check to
bsearch2.ll. Tracks EnzymeAD/Enzyme.jl#3472.