[flang-commits] [clang] [compiler-rt] [flang] [llvm] [mlir] [DebugMetadata][DwarfDebug][CodeView] Support function-local static variables in lexical block scopes (6/7) (PR #187927)

Vladislav Dzhidzhoev via flang-commits flang-commits at lists.llvm.org
Tue Jun 30 04:42:33 PDT 2026


dzhidzhoev wrote:

> > @chbessonova did some investigation, and it turns out that the same issue also affects DILocalVariables, which already live in retainedNodes.
> > See https://gist.github.com/chbessonova/67fc7460ee6a148dd0f9734a25b37564. When
> > bin/mlir-translate -import-llvm -mlir-print-debuginfo dilocalvariable-duplication.ll
> > is run on it, the output contains duplicate #di_local_variables.
> > Would it make more sense to create a separate issue for the duplication problem involving DILocalVariables/DIGlobalVariables living in retainedNodes, and to keep the fix for that separate from this PR?
> 
> Yes I think it is ok to separate this out.

Thank you! I have created an issue https://github.com/llvm/llvm-project/issues/206713.
As a workaround, DebugImporter will not import DIGlobalVariableExpressions via retainedNodes. They will be imported only as llvm::GlobalVariable attachments. This way, duplicate di_global_variable_expression attributes should not show up in MLIR. When MLIR is translated back into LLVM IR, local DIGlobalVariableExpressions will be still attached to corresponding DISubprogram retainedNodes (this logic is already in this PR).

https://github.com/llvm/llvm-project/pull/187927


More information about the flang-commits mailing list