[Mlir-commits] [mlir] [MLIR][LLVM] Support Recursive DITypes (PR #80251)

Tobias Gysi llvmlistbot at llvm.org
Wed Feb 28 11:13:23 PST 2024


================
@@ -133,15 +130,26 @@ DebugTranslation::translateImpl(DICompositeTypeAttr attr) {
     isDistinct = true;
   }
 
-  return 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),
-      /*RuntimeLang=*/0, /*VTableHolder=*/nullptr);
+  llvm::DICompositeType *placeholder =
+      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()),
+          /*Elements=*/nullptr, /*RuntimeLang=*/0, /*VTableHolder=*/nullptr);
----------------
gysit wrote:

I just fixed a problem similar to this today https://github.com/llvm/llvm-project/pull/83257. I wonder if this is problematic here as well and if it would make sense to use:
`  auto dummy = llvm::MDNode::getTemporary(ctx, std::nullopt);`
instead of nullptr here. As metadata nodes are uniqued it could be possible that the later replace step actually replaces the elements of multiple composite types nodes. Although it looks like composite types usually are distinct. I guess that solves the problem... still better safe than sorry.

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


More information about the Mlir-commits mailing list