Skip to content

Preserve full shadow memtransfers#2872

Open
minansys wants to merge 1 commit into
EnzymeAD:mainfrom
minansys:mixu/fix-full-shadow-memcpy
Open

Preserve full shadow memtransfers#2872
minansys wants to merge 1 commit into
EnzymeAD:mainfrom
minansys:mixu/fix-full-shadow-memcpy

Conversation

@minansys

@minansys minansys commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

problem

Enzyme was zero-initializing a shadow copy of a struct and then copying only selected active slices from the source shadow. The reverse pass later needed pointer fields from the copied shadow object, but those fields stayed null. The fix preserves a full shadow memtransfer for nonzero memtransfers, so inactive pointer fields remain initialized while existing sliced updates can still run.

Summary

  • Preserve the full shadow memtransfer when Enzyme also emits sliced shadow updates, so inactive fields in copied aggregates remain initialized.
  • Add a reverse-mode IR regression test covering a copied aggregate with pointer and active scalar fields.

Test plan

  • Built LLVMEnzyme-19.so and ClangEnzyme-19.so against the Conan LLVM 19.1.7 package.
  • Ran the new standalone IR repro through opt; confirmed the full 32-byte shadow copy is absent without the fix and present with the fix.
  • Ran Cromwell TestAdjoint.UnitTestAdjointKW with the minimal fix; it passed.

#2629

Ensure reverse-mode shadow copies keep the full memtransfer when Enzyme also emits sliced shadow updates, so inactive pointer fields in copied aggregates remain initialized for later reverse use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant