[Mlir-commits] [mlir] [MLIR][LLVM] Support Recursive DITypes (PR #80251)
Billy Zhu
llvmlistbot at llvm.org
Wed Feb 28 16:04:03 PST 2024
================
@@ -200,22 +208,66 @@ DebugTranslation::translateImpl(DIGlobalVariableAttr attr) {
attr.getIsDefined(), nullptr, nullptr, attr.getAlignInBits(), nullptr);
}
+llvm::DIType *DebugTranslation::translateImpl(DIRecursiveTypeAttr attr) {
+ if (attr.isRecSelf()) {
+ auto *iter = recursiveTypeMap.find(attr.getId());
+ assert(iter != recursiveTypeMap.end() && "unbound DI recursive self type");
+ return iter->second;
+ }
+
+ size_t recursiveStackSize = recursiveTypeMap.size();
+ auto setRecursivePlaceholderFn = [&](llvm::DIType *node) {
+ auto [iter, inserted] = recursiveTypeMap.try_emplace(attr.getId(), node);
+ assert(inserted && "illegal reuse of recursive id");
+ };
+
+ llvm::DIType *node =
+ TypeSwitch<DITypeAttr, llvm::DIType *>(attr.getBaseType())
+ .Case<DICompositeTypeAttr>([&](auto attr) {
+ return translateImpl(attr, setRecursivePlaceholderFn);
----------------
zyx-billy wrote:
haha yeah I was debating between these two. I don't have a strong preference (went with this one to avoid having two correlated functions, but I also don't like the callback...), we can go with the two-step approach.
https://github.com/llvm/llvm-project/pull/80251
More information about the Mlir-commits
mailing list