Repository navigation
[MemDep] Backport: Stop traversal if invariant.group load operand is a constant - #73
Merged
vchuravy merged 1 commit intoDec 4, 2026
Conversation
…llvm#223456) When traversing a load with attached invariant.group metadata, MemDep analysis can start looking outside the function that the GVN pass is being run on. This happens if the load operand is a constant expression referencing a global object (e.g. a vtable pointer). The DominatorTree then crashes with an assertion when analyzing two instructions from different functions. This issue causes a crash in clang when the `-fstrict-vtable-pointers` option is used, see https://godbolt.org/z/sbKMa5K1d (cherry picked from commit 11f5331) [Backport to julia-release/20.x: the cherry-pick applied with no conflicts.] Co-Authored-By: Claude <noreply@anthropic.com>
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.
Backport of llvm#223456 (11f5331), cherry-picked with
-x. The cherry-pick applied with no conflicts.MemoryDependenceResults::getInvariantGroupPointerDependencywalks the users of the pointer operand of a load that has!invariant.group. On this branch it stops only when the pointer is aGlobalValue. For any other constant, the walk reaches instructions in other functions of the module. The upstream fix changesisa<GlobalValue>toisa<Constant>.This is the cause of EnzymeAD/Enzyme.jl#4153 on Julia 1.13. Enzyme puts
!invariant.groupon loads in the reverse pass, and the address of a Julia object is a constantinttoptrexpression. When two functions load through the same constant, GVN replaces the load with a load from the other function. The verifier then reports "Referring to an instruction in another function!", or ADCE crashes.Testing, on a Release+Assertions X86-only build of this branch (
opt,FileCheck,llvm-as,llvm-dis):llvm-lit llvm/test/Transforms/GVN llvm/test/Transforms/NewGVN llvm/test/Analysis/MemoryDependenceAnalysis: 392 tests, 374 passed, 18 expectedly failed, 0 failed.llvm/test/Transforms/GVN/strict-vtable.llfails without the source change and passes with it.opt -passes=gvnon the two-function IR from the Enzyme.jl issue keeps both loads.🤖 Generated with Claude Code