[clang] [compiler-rt] [flang] [llvm] [mlir] [DebugMetadata][DwarfDebug][CodeView] Support function-local static variables in lexical block scopes (6/7) (PR #187927)
Tobias Gysi via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 27 23:06:53 PDT 2026
gysit wrote:
Does the output still print or do you see a crash/problem? Can you provide the output here? Note that this self recursive attributes are hard to read and a workaround to represent such cyclic data structures in MLIR.
At first glance, it seems like breaking the cycle using DISubprogramAttr is good enough. It is expected that some attributes are traversed multiple times until one of the self recursive attributes is seen a second time. To make this somewhat efficient, there is cache that makes sure the second translation is just a lookup:
```
DINodeAttr DebugImporter::translate(llvm::DINode *node) {
if (!node)
return nullptr;
// Check for a cached instance.
auto cacheEntry = cache.lookupOrInit(node);
if (std::optional<DINodeAttr> result = cacheEntry.get())
return *result;
```
This will not work in case of the DIGlobalVariableExpression since it is not derived from DINodeAttr. However, I would still expect that things are functional (albeit not optimal). The uniquing seems to work in your example since the pointer for the DIGlobalVariableExpression objects are the same.
https://github.com/llvm/llvm-project/pull/187927
More information about the cfe-commits
mailing list