Initialize inactive reverse tape values#2852
Open
minansys wants to merge 2 commits into
Open
Conversation
a116f6a to
63a1af7
Compare
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.
Fixes #2834 and #2629.\n\nRoot cause:\n- #2834: augmented reverse tapes were assembled by sparse stores into the returned tape aggregate. When a guarding branch was not taken, SROA exposed the unstored fields as undef-fed PHIs, then those values were packed into the tape. The tape backing slot now gets a defined zero/null baseline before path-local tape stores.\n- #2629: manual LCSSA values synthesized for blocks where the primal instruction is inactive used undef. Enzyme postopt could propagate that through noundef math and infer an invalid guard assumption. Those inactive LCSSA entries now use the type's safe zero/null value.\n\nTests:\n- llvm-lit -v /home/minxu/code/enzyme/build/enzyme2-llvmorg-19.1.7/test/Enzyme/ReverseMode/inactive-tape-values.ll\n- llvm-lit -v /home/minxu/code/enzyme/build/enzyme2-llvmorg-19.1.7/test/Integration/ReverseMode/nested_guard_inactive_lcssa.c\n- manual #2834 opt pipeline with LLVM 19.1.7: no remaining i1/ptr/double PHIs with undef in the generated output\n- manual #2629 direct Clang plugin repros at -O0/-O1 for minimized C and original C++ repro: gradients are {1} and {1,1,1}\n