[Triton] Fix LLVMDILocalVariable pass crash with LLVM_EXTRACT_DI_LOCAL_VARIABLES#10042
Open
byoshimi-gmail wants to merge 3 commits intotriton-lang:mainfrom
Open
[Triton] Fix LLVMDILocalVariable pass crash with LLVM_EXTRACT_DI_LOCAL_VARIABLES#10042byoshimi-gmail wants to merge 3 commits intotriton-lang:mainfrom
byoshimi-gmail wants to merge 3 commits intotriton-lang:mainfrom
Conversation
…L_VARIABLES Summary: Fix multiple bugs in the LLVMDILocalVariable pass that caused crashes when running with LLVM_EXTRACT_DI_LOCAL_VARIABLES=1. Root cause: The MLIR DIRecursiveTypeAttrInterface uses isRecSelf=true as a placeholder and isRecSelf=false as its resolver. During MLIR-to-LLVM IR translation, the resolver recursiveNodeMap entry is temporary (popped after translation). Any isRecSelf=true references encountered outside the resolver translation scope trigger an assertion. The add_di_scope pass creates a DISubprogramAttr with isRecSelf=true and embeds it in function locations and DILexicalBlockFileAttr scopes in operation locations. The LLVMDILocalVariable pass was supposed to resolve these but had several issues. Fixes: 1. Added null/scope guard for diSubprogramAttr to skip module-level ops that appear before or between functions in the walk. 2. Fixed getDISubprogramAttr(Operation op) to take Operation *op. 3. Restructured fuseFuncArgVariables to create two sets of DILocalVariableAttr: one with isRecSelf=true scope for retainedNodes (correct recursive pattern), and separate ones with the resolved isRecSelf=false scope for DbgValueOps (avoids unresolvable refs). 4. Added fixLexicalBlockScopes to walk operations and replace DILexicalBlockFileAttr scopes that reference the old isRecSelf=true subprogram with the resolved version. 5. Value-initialized diSubprogramAttr to avoid undefined behavior. Test Plan: TRITON_ALWAYS_COMPILE=1 LLVM_EXTRACT_DI_LOCAL_VARIABLES=1 \ python3 python/tutorials/02-fused-softmax.py
plotfi
reviewed
Apr 16, 2026
| // DISubprogramAttr construction | ||
| LLVM::DISubprogramAttr getDISubprogramAttr(Operation op) { | ||
| auto funcOp = op.getParentOfType<LLVM::LLVMFuncOp>(); | ||
| LLVM::DISubprogramAttr getDISubprogramAttr(Operation *op) { |
Contributor
There was a problem hiding this comment.
Use Operation &op to avoid needing to dereference.
Contributor
|
LGTM but @Mogball should take a look as well, as he has experience with debug info and reviewed @Youngzt998's previous work. |
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.
Summary:
Fix multiple bugs in the LLVMDILocalVariable pass that caused crashes when running with LLVM_EXTRACT_DI_LOCAL_VARIABLES=1.
Root cause: The MLIR DIRecursiveTypeAttrInterface uses isRecSelf=true as a placeholder and isRecSelf=false as its resolver. During MLIR-to-LLVM IR translation, the resolver recursiveNodeMap entry is temporary (popped after translation). Any isRecSelf=true references encountered outside the resolver translation scope trigger an assertion.
The add_di_scope pass creates a DISubprogramAttr with isRecSelf=true and embeds it in function locations and DILexicalBlockFileAttr scopes in operation locations. The LLVMDILocalVariable pass was supposed to resolve these but had several issues.
Fixes:
Test Plan:
TRITON_ALWAYS_COMPILE=1 LLVM_EXTRACT_DI_LOCAL_VARIABLES=1
python3 python/tutorials/02-fused-softmax.py
New contributor declaration
I am not making a trivial change, such as fixing a typo in a comment.
I have written a PR description following these
rules.
I have run
pre-commit run --from-ref origin/main --to-ref HEAD.Select one of the following.
/testforlittests/unittestfor C++ tests/python/testfor end-to-end testsFILL THIS IN.Select one of the following.
littests.littests I have added follow these best practices,including the "tests should be minimal" section. (Usually running Python code
and using the instructions it generates is not minimal.)