[Mlir-commits] [mlir] [mlir] Add support for recursive elements in DICompositeTypeAttr. (PR #74948)
Tobias Gysi
llvmlistbot at llvm.org
Mon Dec 11 02:40:19 PST 2023
================
@@ -133,15 +129,31 @@ DebugTranslation::translateImpl(DICompositeTypeAttr attr) {
isDistinct = true;
}
- return getDistinctOrUnique<llvm::DICompositeType>(
+ // Create the composite type metadata first with an empty set of elements.
+ llvm::DICompositeType *result = getDistinctOrUnique<llvm::DICompositeType>(
isDistinct, llvmCtx, attr.getTag(), getMDStringOrNull(attr.getName()),
translate(attr.getFile()), attr.getLine(), translate(attr.getScope()),
translate(attr.getBaseType()), attr.getSizeInBits(),
attr.getAlignInBits(),
/*OffsetInBits=*/0,
/*Flags=*/static_cast<llvm::DINode::DIFlags>(attr.getFlags()),
- llvm::MDNode::get(llvmCtx, elements),
+ llvm::MDNode::get(llvmCtx, {}),
/*RuntimeLang=*/0, /*VTableHolder=*/nullptr);
+
+ // Short-circuit the mapping for this attribute to prevent infinite recursion
+ // if this composite type is encountered while translating the elements.
+ attrToNode[attr] = result;
----------------
gysit wrote:
Makes sense. A test with mutual recursive composite types would be nice to test this.
https://github.com/llvm/llvm-project/pull/74948
More information about the Mlir-commits
mailing list