Skip to content

[MLIR][LLVM] Add variant part debug info support#195321

Merged
gysit merged 3 commits into
llvm:mainfrom
jiel-nv:mlir-di-variant-part
May 4, 2026
Merged

[MLIR][LLVM] Add variant part debug info support#195321
gysit merged 3 commits into
llvm:mainfrom
jiel-nv:mlir-di-variant-part

Conversation

@jiel-nv

@jiel-nv jiel-nv commented May 1, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR extends the MLIR LLVM dialect debug-info attributes to represent DWARF variant parts, discriminators, and per-alternative discriminator values.

The change adds identifier and discriminator support to DICompositeTypeAttr, allowing MLIR to model DW_TAG_variant_part metadata that LLVM IR already supports. It also broadens DIDerivedTypeAttr's extraData field from DINodeAttr to a verified polymorphic Attribute, supporting both debug-info nodes and integer constants used by variant alternatives.

Details

  • Add identifier and discriminator fields to DICompositeTypeAttr, bytecode serialization, LLVM IR import/export, C API bindings, and Flang call sites.
  • Change DIDerivedTypeAttr.extraData to accept either DINodeAttr or IntegerAttr, with verifier coverage for invalid attribute kinds.
  • Preserve integer bit width when importing ConstantAsMetadata(ConstantInt) into MLIR.
  • Add parse/print, verifier, LLVM IR import/export, and C API test coverage for variant-part debug info.

@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmorg-github-actions llvmorg-github-actions Bot added mlir:llvm mlir flang Flang issues not falling into any other category flang:fir-hlfir labels May 1, 2026
@llvmorg-github-actions

llvmorg-github-actions Bot commented May 1, 2026

Copy link
Copy Markdown

@llvm/pr-subscribers-mlir-llvm

@llvm/pr-subscribers-flang-fir-hlfir

Author: jiel-nv

Changes

Summary

This PR extends the MLIR LLVM dialect debug-info attributes to represent DWARF variant parts, discriminators, and per-alternative discriminator values.

The change adds identifier and discriminator support to DICompositeTypeAttr, allowing MLIR to model DW_TAG_variant_part metadata that LLVM IR already supports. It also broadens DIDerivedTypeAttr's extraData field from DINodeAttr to a verified polymorphic Attribute, supporting both debug-info nodes and integer constants used by variant alternatives.

Details

  • Add identifier and discriminator fields to DICompositeTypeAttr, bytecode serialization, LLVM IR import/export, C API bindings, and Flang call sites.
  • Change DIDerivedTypeAttr.extraData to accept either DINodeAttr or IntegerAttr, with verifier coverage for invalid attribute kinds.
  • Preserve integer bit width when importing ConstantAsMetadata(ConstantInt) into MLIR.
  • Add parse/print, verifier, LLVM IR import/export, and C API test coverage for variant-part debug info.

Patch is 26.13 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/195321.diff

13 Files Affected:

  • (modified) flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp (+16-8)
  • (modified) mlir/include/mlir-c/Dialect/LLVM.h (+2-1)
  • (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td (+7-3)
  • (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMDialectBytecode.td (+3-1)
  • (modified) mlir/lib/CAPI/Dialect/LLVM.cpp (+5-2)
  • (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp (+19-2)
  • (modified) mlir/lib/Target/LLVMIR/DebugImporter.cpp (+17-3)
  • (modified) mlir/lib/Target/LLVMIR/DebugTranslation.cpp (+20-3)
  • (modified) mlir/test/CAPI/llvm.c (+6-1)
  • (modified) mlir/test/Dialect/LLVMIR/debuginfo.mlir (+33-2)
  • (modified) mlir/test/Dialect/LLVMIR/types-invalid.mlir (+7)
  • (modified) mlir/test/Target/LLVMIR/Import/debug-info.ll (+28)
  • (modified) mlir/test/Target/LLVMIR/llvmir-debug.mlir (+29)
diff --git a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
index da7a513315a4e..f6e18c5b27391 100644
--- a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
+++ b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
@@ -187,7 +187,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertBoxedSequenceType(
         /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
         mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0, /*alignInBits=*/0,
         dataLocation, rank, /*allocated=*/nullptr,
-        /*associated=*/nullptr, elements);
+        /*associated=*/nullptr, /*identifier=*/nullptr,
+        /*discriminator=*/nullptr, elements);
   }
 
   addOp(llvm::dwarf::DW_OP_push_object_address, {});
@@ -264,7 +265,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertBoxedSequenceType(
       context, llvm::dwarf::DW_TAG_array_type, /*name=*/nullptr,
       /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
       mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0, /*alignInBits=*/0,
-      dataLocation, /*rank=*/nullptr, allocated, associated, elements);
+      dataLocation, /*rank=*/nullptr, allocated, associated,
+      /*identifier=*/nullptr, /*discriminator=*/nullptr, elements);
 }
 
 std::pair<std::uint64_t, unsigned short>
@@ -398,7 +400,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType(
       mlir::StringAttr::get(context, ""), fileAttr, /*line=*/0, scope,
       /*baseType=*/nullptr, mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0,
       /*alignInBits=*/0, /*dataLocation=*/nullptr, /*rank=*/nullptr,
-      /*allocated=*/nullptr, /*associated=*/nullptr, elements);
+      /*allocated=*/nullptr, /*associated=*/nullptr, /*identifier=*/nullptr,
+      /*discriminator=*/nullptr, elements);
   DerivedTypeCache::ActiveLevels nestedRecursions =
       derivedTypeCache.startTranslating(Ty, placeHolder);
 
@@ -438,7 +441,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType(
           convertType(seqTy.getEleTy(), fileAttr, scope, declOp),
           mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0, /*alignInBits=*/0,
           /*dataLocation=*/nullptr, /*rank=*/nullptr,
-          /*allocated=*/nullptr, /*associated=*/nullptr, arrayElements);
+          /*allocated=*/nullptr, /*associated=*/nullptr,
+          /*identifier=*/nullptr, /*discriminator=*/nullptr, arrayElements);
     } else
       elemTy = convertType(fieldTy, fileAttr, scope, /*declOp=*/nullptr);
     offset = llvm::alignTo(offset, byteAlign);
@@ -459,7 +463,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType(
       mlir::StringAttr::get(context, sourceName.name), fileAttr, line, scope,
       /*baseType=*/nullptr, mlir::LLVM::DIFlags::Zero, offset * 8,
       /*alignInBits=*/0, /*dataLocation=*/nullptr, /*rank=*/nullptr,
-      /*allocated=*/nullptr, /*associated=*/nullptr, elements);
+      /*allocated=*/nullptr, /*associated=*/nullptr, /*identifier=*/nullptr,
+      /*discriminator=*/nullptr, elements);
 
   derivedTypeCache.finalize(Ty, finalAttr, std::move(nestedRecursions));
 
@@ -503,7 +508,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertTupleType(
       mlir::StringAttr::get(context, ""), fileAttr, /*line=*/0, scope,
       /*baseType=*/nullptr, mlir::LLVM::DIFlags::Zero, offset * 8,
       /*alignInBits=*/0, /*dataLocation=*/nullptr, /*rank=*/nullptr,
-      /*allocated=*/nullptr, /*associated=*/nullptr, elements);
+      /*allocated=*/nullptr, /*associated=*/nullptr, /*identifier=*/nullptr,
+      /*discriminator=*/nullptr, elements);
   derivedTypeCache.finalize(Ty, typeAttr, std::move(nestedRecursions));
   return typeAttr;
 }
@@ -565,7 +571,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertSequenceType(
       /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
       mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0, /*alignInBits=*/0,
       /*dataLocation=*/nullptr, /*rank=*/nullptr, /*allocated=*/nullptr,
-      /*associated=*/nullptr, elements);
+      /*associated=*/nullptr, /*identifier=*/nullptr,
+      /*discriminator=*/nullptr, elements);
 }
 
 mlir::LLVM::DITypeAttr DebugTypeGenerator::convertVectorType(
@@ -598,7 +605,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertVectorType(
       /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
       mlir::LLVM::DIFlags::Vector, sizeInBits, /*alignInBits=*/0,
       /*dataLocation=*/nullptr, /*rank=*/nullptr, /*allocated=*/nullptr,
-      /*associated=*/nullptr, elements);
+      /*associated=*/nullptr, /*identifier=*/nullptr,
+      /*discriminator=*/nullptr, elements);
 }
 
 mlir::LLVM::DITypeAttr DebugTypeGenerator::convertCharacterType(
diff --git a/mlir/include/mlir-c/Dialect/LLVM.h b/mlir/include/mlir-c/Dialect/LLVM.h
index 5170f01a2f621..09d3ad198a3b2 100644
--- a/mlir/include/mlir-c/Dialect/LLVM.h
+++ b/mlir/include/mlir-c/Dialect/LLVM.h
@@ -307,7 +307,8 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDICompositeTypeAttrGet(
     MlirAttribute baseType, int64_t flags, uint64_t sizeInBits,
     uint64_t alignInBits, intptr_t nElements, MlirAttribute const *elements,
     MlirAttribute dataLocation, MlirAttribute rank, MlirAttribute allocated,
-    MlirAttribute associated);
+    MlirAttribute associated, MlirAttribute identifier,
+    MlirAttribute discriminator);
 
 MLIR_CAPI_EXPORTED MlirStringRef mlirLLVMDICompositeTypeAttrGetName(void);
 
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
index 22face8b9d4b0..bb958213abd2d 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
@@ -494,6 +494,8 @@ def LLVM_DICompositeTypeAttr : LLVM_Attr<"DICompositeType", "di_composite_type",
     OptionalParameter<"DIExpressionAttr">:$rank,
     OptionalParameter<"DIExpressionAttr">:$allocated,
     OptionalParameter<"DIExpressionAttr">:$associated,
+    OptionalParameter<"StringAttr">:$identifier,
+    OptionalParameter<"DIDerivedTypeAttr">:$discriminator,
     OptionalArrayRefParameter<"DINodeAttr">:$elements
   );
   let builders = [
@@ -503,12 +505,13 @@ def LLVM_DICompositeTypeAttr : LLVM_Attr<"DICompositeType", "di_composite_type",
       "DIFlags":$flags, "uint64_t":$sizeInBits, "uint64_t":$alignInBits,
       "DIExpressionAttr":$dataLocation, "DIExpressionAttr":$rank,
       "DIExpressionAttr":$allocated, "DIExpressionAttr":$associated,
+      "StringAttr":$identifier, "DIDerivedTypeAttr":$discriminator,
       "ArrayRef<DINodeAttr>":$elements
     ), [{
-      return $_get($_ctxt, /*recId=*/nullptr, /*isRecSelf=*/nullptr,
+      return $_get($_ctxt, /*recId=*/nullptr, /*isRecSelf=*/false,
                    tag, name, file, line, scope, baseType, flags, sizeInBits,
                    alignInBits, dataLocation, rank, allocated,
-                   associated, elements);
+                   associated, identifier, discriminator, elements);
     }]>
   ];
   let assemblyFormat = "`<` struct(params) `>`";
@@ -547,9 +550,10 @@ def LLVM_DIDerivedTypeAttr : LLVM_Attr<"DIDerivedType", "di_derived_type",
     OptionalParameter<"uint64_t">:$offsetInBits,
     OptionalParameter<"std::optional<unsigned>">:$dwarfAddressSpace,
     OptionalParameter<"DIFlags", "DIFlags::Zero">:$flags,
-    OptionalParameter<"DINodeAttr">:$extraData
+    OptionalParameter<"::mlir::Attribute">:$extraData
   );
   let assemblyFormat = "`<` struct(params) `>`";
+  let genVerifyDecl = 1;
 
   // Generate mnemonic alias for the attribute.
   let genMnemonicAlias = 1;
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialectBytecode.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialectBytecode.td
index 05b88b428102c..a5040d5104ab9 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialectBytecode.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialectBytecode.td
@@ -189,6 +189,8 @@ def DICompositeTypeAttr : DialectAttribute<(attr
   OptionalAttribute<"DIExpressionAttr">:$rank,
   OptionalAttribute<"DIExpressionAttr">:$allocated,
   OptionalAttribute<"DIExpressionAttr">:$associated,
+  OptionalAttribute<"StringAttr">:$identifier,
+  OptionalAttribute<"DIDerivedTypeAttr">:$discriminator,
   OptionalArrayRef<"DINodeAttr">:$elements
 )>;
 
@@ -209,7 +211,7 @@ def DIDerivedTypeAttr : DialectAttribute<(attr
   OptionalInt<"unsigned">:$dwarfAddressSpace,
   EnumClassFlag<"DIFlags", "getFlags()">:$_rawflags,
   LocalVar<"DIFlags", "(DIFlags)_rawflags">:$flags,
-  OptionalAttribute<"DINodeAttr">:$extraData
+  OptionalAttribute<"Attribute">:$extraData
 )>;
 
 //===----------------------------------------------------------------------===//
diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp
index f690af2cdb8a1..6b8cac201d8bf 100644
--- a/mlir/lib/CAPI/Dialect/LLVM.cpp
+++ b/mlir/lib/CAPI/Dialect/LLVM.cpp
@@ -253,7 +253,8 @@ MlirAttribute mlirLLVMDICompositeTypeAttrGet(
     MlirAttribute baseType, int64_t flags, uint64_t sizeInBits,
     uint64_t alignInBits, intptr_t nElements, MlirAttribute const *elements,
     MlirAttribute dataLocation, MlirAttribute rank, MlirAttribute allocated,
-    MlirAttribute associated) {
+    MlirAttribute associated, MlirAttribute identifier,
+    MlirAttribute discriminator) {
   SmallVector<Attribute> elementsStorage;
   elementsStorage.reserve(nElements);
 
@@ -266,6 +267,8 @@ MlirAttribute mlirLLVMDICompositeTypeAttrGet(
       cast<DIExpressionAttr>(unwrap(rank)),
       cast<DIExpressionAttr>(unwrap(allocated)),
       cast<DIExpressionAttr>(unwrap(associated)),
+      cast<StringAttr>(unwrap(identifier)),
+      cast<DIDerivedTypeAttr>(unwrap(discriminator)),
       llvm::map_to_vector(unwrapList(nElements, elements, elementsStorage),
                           llvm::CastTo<DINodeAttr>)));
 }
@@ -286,7 +289,7 @@ MlirAttribute mlirLLVMDIDerivedTypeAttrGet(
       unwrap(ctx), tag, cast<StringAttr>(unwrap(name)),
       cast<DIFileAttr>(unwrap(file)), line, cast<DIScopeAttr>(unwrap(scope)),
       cast<DITypeAttr>(unwrap(baseType)), sizeInBits, alignInBits, offsetInBits,
-      addressSpace, DIFlags(flags), cast<DINodeAttr>(unwrap(extraData))));
+      addressSpace, DIFlags(flags), unwrap(extraData)));
 }
 
 MlirStringRef mlirLLVMDIDerivedTypeAttrGetName(void) {
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
index 674a406cb368b..00d2bba3f3d36 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
@@ -204,6 +204,23 @@ bool DITypeAttr::classof(Attribute attr) {
       attr);
 }
 
+//===----------------------------------------------------------------------===//
+// DIDerivedTypeAttr
+//===----------------------------------------------------------------------===//
+
+LogicalResult
+DIDerivedTypeAttr::verify(function_ref<InFlightDiagnostic()> emitError,
+                          unsigned tag, StringAttr name, DIFileAttr file,
+                          uint32_t line, DIScopeAttr scope, DITypeAttr baseType,
+                          uint64_t sizeInBits, uint32_t alignInBits,
+                          uint64_t offsetInBits,
+                          std::optional<unsigned> dwarfAddressSpace,
+                          DIFlags flags, Attribute extraData) {
+  if (extraData && !llvm::isa<DINodeAttr, IntegerAttr>(extraData))
+    return emitError() << "extraData must be a DINodeAttr or an IntegerAttr";
+  return success();
+}
+
 //===----------------------------------------------------------------------===//
 // TBAANodeAttr
 //===----------------------------------------------------------------------===//
@@ -320,14 +337,14 @@ DICompositeTypeAttr::withRecId(DistinctAttr recId) {
       getContext(), recId, getIsRecSelf(), getTag(), getName(), getFile(),
       getLine(), getScope(), getBaseType(), getFlags(), getSizeInBits(),
       getAlignInBits(), getDataLocation(), getRank(), getAllocated(),
-      getAssociated(), getElements());
+      getAssociated(), getIdentifier(), getDiscriminator(), getElements());
 }
 
 DIRecursiveTypeAttrInterface
 DICompositeTypeAttr::getRecSelf(DistinctAttr recId) {
   return DICompositeTypeAttr::get(recId.getContext(), recId, /*isRecSelf=*/true,
                                   0, {}, {}, 0, {}, {}, DIFlags(), 0, 0, {}, {},
-                                  {}, {}, {});
+                                  {}, {}, {}, {}, {});
 }
 
 //===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Target/LLVMIR/DebugImporter.cpp b/mlir/lib/Target/LLVMIR/DebugImporter.cpp
index ab37c21fdacf8..b3cbe481f5983 100644
--- a/mlir/lib/Target/LLVMIR/DebugImporter.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugImporter.cpp
@@ -101,7 +101,9 @@ DICompositeTypeAttr DebugImporter::translateImpl(llvm::DICompositeType *node) {
       node->getAlignInBits(), translateExpression(node->getDataLocationExp()),
       translateExpression(node->getRankExp()),
       translateExpression(node->getAllocatedExp()),
-      translateExpression(node->getAssociatedExp()), elements);
+      translateExpression(node->getAssociatedExp()),
+      getStringAttrOrNull(node->getRawIdentifier()),
+      translate(node->getDiscriminator()), elements);
 }
 
 DIDerivedTypeAttr DebugImporter::translateImpl(llvm::DIDerivedType *node) {
@@ -109,8 +111,20 @@ DIDerivedTypeAttr DebugImporter::translateImpl(llvm::DIDerivedType *node) {
   DITypeAttr baseType = translate(node->getBaseType());
   if (node->getBaseType() && !baseType)
     return nullptr;
-  DINodeAttr extraData =
-      translate(dyn_cast_or_null<llvm::DINode>(node->getExtraData()));
+  llvm::Metadata *rawExtraData = node->getExtraData();
+  Attribute extraData;
+  if (auto *extraDataNode = dyn_cast_or_null<llvm::DINode>(rawExtraData)) {
+    extraData = translate(extraDataNode);
+  } else if (auto *constantAsMetadata =
+                 dyn_cast_or_null<llvm::ConstantAsMetadata>(rawExtraData)) {
+    if (auto *constantInt =
+            dyn_cast<llvm::ConstantInt>(constantAsMetadata->getValue())) {
+      const APInt &value = constantInt->getValue();
+      extraData =
+          IntegerAttr::get(IntegerType::get(context, value.getBitWidth()),
+                           value);
+    }
+  }
   return DIDerivedTypeAttr::get(
       context, node->getTag(), getStringAttrOrNull(node->getRawName()),
       translate(node->getFile()), node->getLine(), translate(node->getScope()),
diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
index db9bc874314bb..a69e7b5338caa 100644
--- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
@@ -10,8 +10,10 @@
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "llvm/ADT/SmallVectorExtras.h"
 #include "llvm/ADT/TypeSwitch.h"
+#include "llvm/IR/Constants.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 
@@ -225,8 +227,8 @@ DebugTranslation::translateImpl(DICompositeTypeAttr attr) {
       /*Flags=*/static_cast<llvm::DINode::DIFlags>(attr.getFlags()),
       getMDTupleOrNull(attr.getElements()),
       /*RuntimeLang=*/0, /*EnumKind*/ std::nullopt, /*VTableHolder=*/nullptr,
-      /*TemplateParams=*/nullptr, /*Identifier=*/nullptr,
-      /*Discriminator=*/nullptr,
+      /*TemplateParams=*/nullptr, getMDStringOrNull(attr.getIdentifier()),
+      translate(attr.getDiscriminator()),
       getExpressionAttrOrNull(attr.getDataLocation()),
       getExpressionAttrOrNull(attr.getAssociated()),
       getExpressionAttrOrNull(attr.getAllocated()),
@@ -234,6 +236,21 @@ DebugTranslation::translateImpl(DICompositeTypeAttr attr) {
 }
 
 llvm::DIDerivedType *DebugTranslation::translateImpl(DIDerivedTypeAttr attr) {
+  llvm::Metadata *extraData = nullptr;
+  if (Attribute extraDataAttr = attr.getExtraData()) {
+    extraData =
+        llvm::TypeSwitch<Attribute, llvm::Metadata *>(extraDataAttr)
+            .Case([&](DINodeAttr nodeAttr) { return translate(nodeAttr); })
+            .Case([&](IntegerAttr intAttr) {
+              return llvm::ConstantAsMetadata::get(
+                  llvm::ConstantInt::get(llvmCtx, intAttr.getValue()));
+            })
+            .Default([](Attribute) -> llvm::Metadata * {
+              llvm_unreachable(
+                  "verifier guarantees DINodeAttr or IntegerAttr");
+            });
+  }
+
   return llvm::DIDerivedType::get(
       llvmCtx, attr.getTag(), getMDStringOrNull(attr.getName()),
       translate(attr.getFile()), attr.getLine(), translate(attr.getScope()),
@@ -241,7 +258,7 @@ llvm::DIDerivedType *DebugTranslation::translateImpl(DIDerivedTypeAttr attr) {
       attr.getAlignInBits(), attr.getOffsetInBits(),
       attr.getDwarfAddressSpace(), /*PtrAuthData=*/std::nullopt,
       /*Flags=*/static_cast<llvm::DINode::DIFlags>(attr.getFlags()),
-      translate(attr.getExtraData()));
+      extraData);
 }
 
 llvm::DIStringType *DebugTranslation::translateImpl(DIStringTypeAttr attr) {
diff --git a/mlir/test/CAPI/llvm.c b/mlir/test/CAPI/llvm.c
index fe48ec5568168..caa29379e9fd6 100644
--- a/mlir/test/CAPI/llvm.c
+++ b/mlir/test/CAPI/llvm.c
@@ -378,10 +378,15 @@ static void testDebugInfoAttributes(MlirContext ctx) {
   // CHECK: #llvm.di_composite_type<recId = {{.*}}, isRecSelf = true>
   mlirAttributeDump(mlirLLVMDICompositeTypeAttrGetRecSelf(recId1));
 
+  MlirAttribute discriminator = mlirLLVMDIDerivedTypeAttrGet(
+      ctx, /*DW_TAG_member=*/0x0d, bar, file, 1, compile_unit, di_type, 8, 0,
+      0, MLIR_CAPI_DWARF_ADDRESS_SPACE_NULL, 0, mlirAttributeGetNull());
+
   // CHECK: #llvm.di_composite_type<{{.*}}>
   mlirAttributeDump(mlirLLVMDICompositeTypeAttrGet(
       ctx, recId1, false, 0, foo, file, 1, compile_unit, di_type, 0, 64, 8, 1,
-      &di_type, expression, expression, expression, expression));
+      &di_type, expression, expression, expression, expression, bar,
+      discriminator));
 }
 
 int main(void) {
diff --git a/mlir/test/Dialect/LLVMIR/debuginfo.mlir b/mlir/test/Dialect/LLVMIR/debuginfo.mlir
index e9793c15a5272..21bcbcffbace7 100644
--- a/mlir/test/Dialect/LLVMIR/debuginfo.mlir
+++ b/mlir/test/Dialect/LLVMIR/debuginfo.mlir
@@ -29,6 +29,12 @@
   sizeInBits = 32, encoding = DW_ATE_signed
 >
 
+// CHECK-DAG: #[[FLOAT1:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "float1", sizeInBits = 32, encoding = DW_ATE_float>
+#float1 = #llvm.di_basic_type<
+  tag = DW_TAG_base_type, name = "float1",
+  sizeInBits = 32, encoding = DW_ATE_float
+>
+
 // CHECK-DAG: #[[PTR0:.*]] = #llvm.di_derived_type<tag = DW_TAG_pointer_type, baseType = #[[INT0]], sizeInBits = 64, alignInBits = 32, offsetInBits = 4, extraData = #[[INT1]]>
 #ptr0 = #llvm.di_derived_type<
   tag = DW_TAG_pointer_type, baseType = #int0,
@@ -74,6 +80,31 @@
   elements = #llvm.di_subrange<count = 4>
 >
 
+// CHECK-DAG: #[[DISC:.*]] = #llvm.di_derived_type<tag = DW_TAG_member, name = "discriminator", baseType = #[[INT0]], flags = Artificial>
+#disc = #llvm.di_derived_type<
+  tag = DW_TAG_member, name = "discriminator", baseType = #int0,
+  flags = Artificial
+>
+
+// CHECK-DAG: #[[ELEM_INT:.*]] = #llvm.di_derived_type<tag = DW_TAG_member, name = "_int1", baseType = #[[INT1]], extraData = 1 : i8>
+#elemInt = #llvm.di_derived_type<
+  tag = DW_TAG_member, name = "_int1", baseType = #int1,
+  extraData = 1 : i8
+>
+
+// CHECK-DAG: #[[ELEM_FLOAT:.*]] = #llvm.di_derived_type<tag = DW_TAG_member, name = "_float1", baseType = #[[FLOAT1]], extraData = 2 : i8>
+#elemFloat = #llvm.di_derived_type<
+  tag = DW_TAG_member, name = "_float1", baseType = #float1,
+  extraData = 2 : i8
+>
+
+// CHECK-DAG: #[[VARIANT:.*]] = #llvm.di_composite_type<tag = DW_TAG_variant_part, name = "variant_part", identifier = "variant-id", discriminator = #[[DISC]], elements = #[[ELEM_INT]], #[[ELEM_FLOAT]]>
+#variant = #llvm.di_composite_type<
+  tag = DW_TAG_variant_part, name = "variant_part",
+  identifier = "variant-id", discriminator = #disc,
+  elements = #elemInt, #elemFloat
+>
+
 // CHECK-DAG: #[[TOPLEVEL:.*]] = #llvm.di_namespace<name = "toplevel", exportSymbols = true>
 #toplevel_namespace = #llvm.di_namespace<
   name = "toplevel", exportSymbols = true
@@ -104,9 +135,9 @@
  name = "expr_elements2", baseType = #int0, elements =
  #llvm.di_generic_subrange<count = #exp1, lowerBound = #exp2, stride = #exp3>>
 
-// CHECK-DAG: #[[SPTYPE0:.*]] = #llvm.di_subroutine_type<callingConvention = D...
[truncated]

@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-mlir

Author: jiel-nv

Changes

Summary

This PR extends the MLIR LLVM dialect debug-info attributes to represent DWARF variant parts, discriminators, and per-alternative discriminator values.

The change adds identifier and discriminator support to DICompositeTypeAttr, allowing MLIR to model DW_TAG_variant_part metadata that LLVM IR already supports. It also broadens DIDerivedTypeAttr's extraData field from DINodeAttr to a verified polymorphic Attribute, supporting both debug-info nodes and integer constants used by variant alternatives.

Details

  • Add identifier and discriminator fields to DICompositeTypeAttr, bytecode serialization, LLVM IR import/export, C API bindings, and Flang call sites.
  • Change DIDerivedTypeAttr.extraData to accept either DINodeAttr or IntegerAttr, with verifier coverage for invalid attribute kinds.
  • Preserve integer bit width when importing ConstantAsMetadata(ConstantInt) into MLIR.
  • Add parse/print, verifier, LLVM IR import/export, and C API test coverage for variant-part debug info.

Patch is 26.13 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/195321.diff

13 Files Affected:

  • (modified) flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp (+16-8)
  • (modified) mlir/include/mlir-c/Dialect/LLVM.h (+2-1)
  • (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td (+7-3)
  • (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMDialectBytecode.td (+3-1)
  • (modified) mlir/lib/CAPI/Dialect/LLVM.cpp (+5-2)
  • (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp (+19-2)
  • (modified) mlir/lib/Target/LLVMIR/DebugImporter.cpp (+17-3)
  • (modified) mlir/lib/Target/LLVMIR/DebugTranslation.cpp (+20-3)
  • (modified) mlir/test/CAPI/llvm.c (+6-1)
  • (modified) mlir/test/Dialect/LLVMIR/debuginfo.mlir (+33-2)
  • (modified) mlir/test/Dialect/LLVMIR/types-invalid.mlir (+7)
  • (modified) mlir/test/Target/LLVMIR/Import/debug-info.ll (+28)
  • (modified) mlir/test/Target/LLVMIR/llvmir-debug.mlir (+29)
diff --git a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
index da7a513315a4e..f6e18c5b27391 100644
--- a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
+++ b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
@@ -187,7 +187,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertBoxedSequenceType(
         /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
         mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0, /*alignInBits=*/0,
         dataLocation, rank, /*allocated=*/nullptr,
-        /*associated=*/nullptr, elements);
+        /*associated=*/nullptr, /*identifier=*/nullptr,
+        /*discriminator=*/nullptr, elements);
   }
 
   addOp(llvm::dwarf::DW_OP_push_object_address, {});
@@ -264,7 +265,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertBoxedSequenceType(
       context, llvm::dwarf::DW_TAG_array_type, /*name=*/nullptr,
       /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
       mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0, /*alignInBits=*/0,
-      dataLocation, /*rank=*/nullptr, allocated, associated, elements);
+      dataLocation, /*rank=*/nullptr, allocated, associated,
+      /*identifier=*/nullptr, /*discriminator=*/nullptr, elements);
 }
 
 std::pair<std::uint64_t, unsigned short>
@@ -398,7 +400,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType(
       mlir::StringAttr::get(context, ""), fileAttr, /*line=*/0, scope,
       /*baseType=*/nullptr, mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0,
       /*alignInBits=*/0, /*dataLocation=*/nullptr, /*rank=*/nullptr,
-      /*allocated=*/nullptr, /*associated=*/nullptr, elements);
+      /*allocated=*/nullptr, /*associated=*/nullptr, /*identifier=*/nullptr,
+      /*discriminator=*/nullptr, elements);
   DerivedTypeCache::ActiveLevels nestedRecursions =
       derivedTypeCache.startTranslating(Ty, placeHolder);
 
@@ -438,7 +441,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType(
           convertType(seqTy.getEleTy(), fileAttr, scope, declOp),
           mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0, /*alignInBits=*/0,
           /*dataLocation=*/nullptr, /*rank=*/nullptr,
-          /*allocated=*/nullptr, /*associated=*/nullptr, arrayElements);
+          /*allocated=*/nullptr, /*associated=*/nullptr,
+          /*identifier=*/nullptr, /*discriminator=*/nullptr, arrayElements);
     } else
       elemTy = convertType(fieldTy, fileAttr, scope, /*declOp=*/nullptr);
     offset = llvm::alignTo(offset, byteAlign);
@@ -459,7 +463,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType(
       mlir::StringAttr::get(context, sourceName.name), fileAttr, line, scope,
       /*baseType=*/nullptr, mlir::LLVM::DIFlags::Zero, offset * 8,
       /*alignInBits=*/0, /*dataLocation=*/nullptr, /*rank=*/nullptr,
-      /*allocated=*/nullptr, /*associated=*/nullptr, elements);
+      /*allocated=*/nullptr, /*associated=*/nullptr, /*identifier=*/nullptr,
+      /*discriminator=*/nullptr, elements);
 
   derivedTypeCache.finalize(Ty, finalAttr, std::move(nestedRecursions));
 
@@ -503,7 +508,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertTupleType(
       mlir::StringAttr::get(context, ""), fileAttr, /*line=*/0, scope,
       /*baseType=*/nullptr, mlir::LLVM::DIFlags::Zero, offset * 8,
       /*alignInBits=*/0, /*dataLocation=*/nullptr, /*rank=*/nullptr,
-      /*allocated=*/nullptr, /*associated=*/nullptr, elements);
+      /*allocated=*/nullptr, /*associated=*/nullptr, /*identifier=*/nullptr,
+      /*discriminator=*/nullptr, elements);
   derivedTypeCache.finalize(Ty, typeAttr, std::move(nestedRecursions));
   return typeAttr;
 }
@@ -565,7 +571,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertSequenceType(
       /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
       mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0, /*alignInBits=*/0,
       /*dataLocation=*/nullptr, /*rank=*/nullptr, /*allocated=*/nullptr,
-      /*associated=*/nullptr, elements);
+      /*associated=*/nullptr, /*identifier=*/nullptr,
+      /*discriminator=*/nullptr, elements);
 }
 
 mlir::LLVM::DITypeAttr DebugTypeGenerator::convertVectorType(
@@ -598,7 +605,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertVectorType(
       /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
       mlir::LLVM::DIFlags::Vector, sizeInBits, /*alignInBits=*/0,
       /*dataLocation=*/nullptr, /*rank=*/nullptr, /*allocated=*/nullptr,
-      /*associated=*/nullptr, elements);
+      /*associated=*/nullptr, /*identifier=*/nullptr,
+      /*discriminator=*/nullptr, elements);
 }
 
 mlir::LLVM::DITypeAttr DebugTypeGenerator::convertCharacterType(
diff --git a/mlir/include/mlir-c/Dialect/LLVM.h b/mlir/include/mlir-c/Dialect/LLVM.h
index 5170f01a2f621..09d3ad198a3b2 100644
--- a/mlir/include/mlir-c/Dialect/LLVM.h
+++ b/mlir/include/mlir-c/Dialect/LLVM.h
@@ -307,7 +307,8 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDICompositeTypeAttrGet(
     MlirAttribute baseType, int64_t flags, uint64_t sizeInBits,
     uint64_t alignInBits, intptr_t nElements, MlirAttribute const *elements,
     MlirAttribute dataLocation, MlirAttribute rank, MlirAttribute allocated,
-    MlirAttribute associated);
+    MlirAttribute associated, MlirAttribute identifier,
+    MlirAttribute discriminator);
 
 MLIR_CAPI_EXPORTED MlirStringRef mlirLLVMDICompositeTypeAttrGetName(void);
 
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
index 22face8b9d4b0..bb958213abd2d 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td
@@ -494,6 +494,8 @@ def LLVM_DICompositeTypeAttr : LLVM_Attr<"DICompositeType", "di_composite_type",
     OptionalParameter<"DIExpressionAttr">:$rank,
     OptionalParameter<"DIExpressionAttr">:$allocated,
     OptionalParameter<"DIExpressionAttr">:$associated,
+    OptionalParameter<"StringAttr">:$identifier,
+    OptionalParameter<"DIDerivedTypeAttr">:$discriminator,
     OptionalArrayRefParameter<"DINodeAttr">:$elements
   );
   let builders = [
@@ -503,12 +505,13 @@ def LLVM_DICompositeTypeAttr : LLVM_Attr<"DICompositeType", "di_composite_type",
       "DIFlags":$flags, "uint64_t":$sizeInBits, "uint64_t":$alignInBits,
       "DIExpressionAttr":$dataLocation, "DIExpressionAttr":$rank,
       "DIExpressionAttr":$allocated, "DIExpressionAttr":$associated,
+      "StringAttr":$identifier, "DIDerivedTypeAttr":$discriminator,
       "ArrayRef<DINodeAttr>":$elements
     ), [{
-      return $_get($_ctxt, /*recId=*/nullptr, /*isRecSelf=*/nullptr,
+      return $_get($_ctxt, /*recId=*/nullptr, /*isRecSelf=*/false,
                    tag, name, file, line, scope, baseType, flags, sizeInBits,
                    alignInBits, dataLocation, rank, allocated,
-                   associated, elements);
+                   associated, identifier, discriminator, elements);
     }]>
   ];
   let assemblyFormat = "`<` struct(params) `>`";
@@ -547,9 +550,10 @@ def LLVM_DIDerivedTypeAttr : LLVM_Attr<"DIDerivedType", "di_derived_type",
     OptionalParameter<"uint64_t">:$offsetInBits,
     OptionalParameter<"std::optional<unsigned>">:$dwarfAddressSpace,
     OptionalParameter<"DIFlags", "DIFlags::Zero">:$flags,
-    OptionalParameter<"DINodeAttr">:$extraData
+    OptionalParameter<"::mlir::Attribute">:$extraData
   );
   let assemblyFormat = "`<` struct(params) `>`";
+  let genVerifyDecl = 1;
 
   // Generate mnemonic alias for the attribute.
   let genMnemonicAlias = 1;
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialectBytecode.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialectBytecode.td
index 05b88b428102c..a5040d5104ab9 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialectBytecode.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialectBytecode.td
@@ -189,6 +189,8 @@ def DICompositeTypeAttr : DialectAttribute<(attr
   OptionalAttribute<"DIExpressionAttr">:$rank,
   OptionalAttribute<"DIExpressionAttr">:$allocated,
   OptionalAttribute<"DIExpressionAttr">:$associated,
+  OptionalAttribute<"StringAttr">:$identifier,
+  OptionalAttribute<"DIDerivedTypeAttr">:$discriminator,
   OptionalArrayRef<"DINodeAttr">:$elements
 )>;
 
@@ -209,7 +211,7 @@ def DIDerivedTypeAttr : DialectAttribute<(attr
   OptionalInt<"unsigned">:$dwarfAddressSpace,
   EnumClassFlag<"DIFlags", "getFlags()">:$_rawflags,
   LocalVar<"DIFlags", "(DIFlags)_rawflags">:$flags,
-  OptionalAttribute<"DINodeAttr">:$extraData
+  OptionalAttribute<"Attribute">:$extraData
 )>;
 
 //===----------------------------------------------------------------------===//
diff --git a/mlir/lib/CAPI/Dialect/LLVM.cpp b/mlir/lib/CAPI/Dialect/LLVM.cpp
index f690af2cdb8a1..6b8cac201d8bf 100644
--- a/mlir/lib/CAPI/Dialect/LLVM.cpp
+++ b/mlir/lib/CAPI/Dialect/LLVM.cpp
@@ -253,7 +253,8 @@ MlirAttribute mlirLLVMDICompositeTypeAttrGet(
     MlirAttribute baseType, int64_t flags, uint64_t sizeInBits,
     uint64_t alignInBits, intptr_t nElements, MlirAttribute const *elements,
     MlirAttribute dataLocation, MlirAttribute rank, MlirAttribute allocated,
-    MlirAttribute associated) {
+    MlirAttribute associated, MlirAttribute identifier,
+    MlirAttribute discriminator) {
   SmallVector<Attribute> elementsStorage;
   elementsStorage.reserve(nElements);
 
@@ -266,6 +267,8 @@ MlirAttribute mlirLLVMDICompositeTypeAttrGet(
       cast<DIExpressionAttr>(unwrap(rank)),
       cast<DIExpressionAttr>(unwrap(allocated)),
       cast<DIExpressionAttr>(unwrap(associated)),
+      cast<StringAttr>(unwrap(identifier)),
+      cast<DIDerivedTypeAttr>(unwrap(discriminator)),
       llvm::map_to_vector(unwrapList(nElements, elements, elementsStorage),
                           llvm::CastTo<DINodeAttr>)));
 }
@@ -286,7 +289,7 @@ MlirAttribute mlirLLVMDIDerivedTypeAttrGet(
       unwrap(ctx), tag, cast<StringAttr>(unwrap(name)),
       cast<DIFileAttr>(unwrap(file)), line, cast<DIScopeAttr>(unwrap(scope)),
       cast<DITypeAttr>(unwrap(baseType)), sizeInBits, alignInBits, offsetInBits,
-      addressSpace, DIFlags(flags), cast<DINodeAttr>(unwrap(extraData))));
+      addressSpace, DIFlags(flags), unwrap(extraData)));
 }
 
 MlirStringRef mlirLLVMDIDerivedTypeAttrGetName(void) {
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
index 674a406cb368b..00d2bba3f3d36 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp
@@ -204,6 +204,23 @@ bool DITypeAttr::classof(Attribute attr) {
       attr);
 }
 
+//===----------------------------------------------------------------------===//
+// DIDerivedTypeAttr
+//===----------------------------------------------------------------------===//
+
+LogicalResult
+DIDerivedTypeAttr::verify(function_ref<InFlightDiagnostic()> emitError,
+                          unsigned tag, StringAttr name, DIFileAttr file,
+                          uint32_t line, DIScopeAttr scope, DITypeAttr baseType,
+                          uint64_t sizeInBits, uint32_t alignInBits,
+                          uint64_t offsetInBits,
+                          std::optional<unsigned> dwarfAddressSpace,
+                          DIFlags flags, Attribute extraData) {
+  if (extraData && !llvm::isa<DINodeAttr, IntegerAttr>(extraData))
+    return emitError() << "extraData must be a DINodeAttr or an IntegerAttr";
+  return success();
+}
+
 //===----------------------------------------------------------------------===//
 // TBAANodeAttr
 //===----------------------------------------------------------------------===//
@@ -320,14 +337,14 @@ DICompositeTypeAttr::withRecId(DistinctAttr recId) {
       getContext(), recId, getIsRecSelf(), getTag(), getName(), getFile(),
       getLine(), getScope(), getBaseType(), getFlags(), getSizeInBits(),
       getAlignInBits(), getDataLocation(), getRank(), getAllocated(),
-      getAssociated(), getElements());
+      getAssociated(), getIdentifier(), getDiscriminator(), getElements());
 }
 
 DIRecursiveTypeAttrInterface
 DICompositeTypeAttr::getRecSelf(DistinctAttr recId) {
   return DICompositeTypeAttr::get(recId.getContext(), recId, /*isRecSelf=*/true,
                                   0, {}, {}, 0, {}, {}, DIFlags(), 0, 0, {}, {},
-                                  {}, {}, {});
+                                  {}, {}, {}, {}, {});
 }
 
 //===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Target/LLVMIR/DebugImporter.cpp b/mlir/lib/Target/LLVMIR/DebugImporter.cpp
index ab37c21fdacf8..b3cbe481f5983 100644
--- a/mlir/lib/Target/LLVMIR/DebugImporter.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugImporter.cpp
@@ -101,7 +101,9 @@ DICompositeTypeAttr DebugImporter::translateImpl(llvm::DICompositeType *node) {
       node->getAlignInBits(), translateExpression(node->getDataLocationExp()),
       translateExpression(node->getRankExp()),
       translateExpression(node->getAllocatedExp()),
-      translateExpression(node->getAssociatedExp()), elements);
+      translateExpression(node->getAssociatedExp()),
+      getStringAttrOrNull(node->getRawIdentifier()),
+      translate(node->getDiscriminator()), elements);
 }
 
 DIDerivedTypeAttr DebugImporter::translateImpl(llvm::DIDerivedType *node) {
@@ -109,8 +111,20 @@ DIDerivedTypeAttr DebugImporter::translateImpl(llvm::DIDerivedType *node) {
   DITypeAttr baseType = translate(node->getBaseType());
   if (node->getBaseType() && !baseType)
     return nullptr;
-  DINodeAttr extraData =
-      translate(dyn_cast_or_null<llvm::DINode>(node->getExtraData()));
+  llvm::Metadata *rawExtraData = node->getExtraData();
+  Attribute extraData;
+  if (auto *extraDataNode = dyn_cast_or_null<llvm::DINode>(rawExtraData)) {
+    extraData = translate(extraDataNode);
+  } else if (auto *constantAsMetadata =
+                 dyn_cast_or_null<llvm::ConstantAsMetadata>(rawExtraData)) {
+    if (auto *constantInt =
+            dyn_cast<llvm::ConstantInt>(constantAsMetadata->getValue())) {
+      const APInt &value = constantInt->getValue();
+      extraData =
+          IntegerAttr::get(IntegerType::get(context, value.getBitWidth()),
+                           value);
+    }
+  }
   return DIDerivedTypeAttr::get(
       context, node->getTag(), getStringAttrOrNull(node->getRawName()),
       translate(node->getFile()), node->getLine(), translate(node->getScope()),
diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
index db9bc874314bb..a69e7b5338caa 100644
--- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
@@ -10,8 +10,10 @@
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "llvm/ADT/SmallVectorExtras.h"
 #include "llvm/ADT/TypeSwitch.h"
+#include "llvm/IR/Constants.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 
@@ -225,8 +227,8 @@ DebugTranslation::translateImpl(DICompositeTypeAttr attr) {
       /*Flags=*/static_cast<llvm::DINode::DIFlags>(attr.getFlags()),
       getMDTupleOrNull(attr.getElements()),
       /*RuntimeLang=*/0, /*EnumKind*/ std::nullopt, /*VTableHolder=*/nullptr,
-      /*TemplateParams=*/nullptr, /*Identifier=*/nullptr,
-      /*Discriminator=*/nullptr,
+      /*TemplateParams=*/nullptr, getMDStringOrNull(attr.getIdentifier()),
+      translate(attr.getDiscriminator()),
       getExpressionAttrOrNull(attr.getDataLocation()),
       getExpressionAttrOrNull(attr.getAssociated()),
       getExpressionAttrOrNull(attr.getAllocated()),
@@ -234,6 +236,21 @@ DebugTranslation::translateImpl(DICompositeTypeAttr attr) {
 }
 
 llvm::DIDerivedType *DebugTranslation::translateImpl(DIDerivedTypeAttr attr) {
+  llvm::Metadata *extraData = nullptr;
+  if (Attribute extraDataAttr = attr.getExtraData()) {
+    extraData =
+        llvm::TypeSwitch<Attribute, llvm::Metadata *>(extraDataAttr)
+            .Case([&](DINodeAttr nodeAttr) { return translate(nodeAttr); })
+            .Case([&](IntegerAttr intAttr) {
+              return llvm::ConstantAsMetadata::get(
+                  llvm::ConstantInt::get(llvmCtx, intAttr.getValue()));
+            })
+            .Default([](Attribute) -> llvm::Metadata * {
+              llvm_unreachable(
+                  "verifier guarantees DINodeAttr or IntegerAttr");
+            });
+  }
+
   return llvm::DIDerivedType::get(
       llvmCtx, attr.getTag(), getMDStringOrNull(attr.getName()),
       translate(attr.getFile()), attr.getLine(), translate(attr.getScope()),
@@ -241,7 +258,7 @@ llvm::DIDerivedType *DebugTranslation::translateImpl(DIDerivedTypeAttr attr) {
       attr.getAlignInBits(), attr.getOffsetInBits(),
       attr.getDwarfAddressSpace(), /*PtrAuthData=*/std::nullopt,
       /*Flags=*/static_cast<llvm::DINode::DIFlags>(attr.getFlags()),
-      translate(attr.getExtraData()));
+      extraData);
 }
 
 llvm::DIStringType *DebugTranslation::translateImpl(DIStringTypeAttr attr) {
diff --git a/mlir/test/CAPI/llvm.c b/mlir/test/CAPI/llvm.c
index fe48ec5568168..caa29379e9fd6 100644
--- a/mlir/test/CAPI/llvm.c
+++ b/mlir/test/CAPI/llvm.c
@@ -378,10 +378,15 @@ static void testDebugInfoAttributes(MlirContext ctx) {
   // CHECK: #llvm.di_composite_type<recId = {{.*}}, isRecSelf = true>
   mlirAttributeDump(mlirLLVMDICompositeTypeAttrGetRecSelf(recId1));
 
+  MlirAttribute discriminator = mlirLLVMDIDerivedTypeAttrGet(
+      ctx, /*DW_TAG_member=*/0x0d, bar, file, 1, compile_unit, di_type, 8, 0,
+      0, MLIR_CAPI_DWARF_ADDRESS_SPACE_NULL, 0, mlirAttributeGetNull());
+
   // CHECK: #llvm.di_composite_type<{{.*}}>
   mlirAttributeDump(mlirLLVMDICompositeTypeAttrGet(
       ctx, recId1, false, 0, foo, file, 1, compile_unit, di_type, 0, 64, 8, 1,
-      &di_type, expression, expression, expression, expression));
+      &di_type, expression, expression, expression, expression, bar,
+      discriminator));
 }
 
 int main(void) {
diff --git a/mlir/test/Dialect/LLVMIR/debuginfo.mlir b/mlir/test/Dialect/LLVMIR/debuginfo.mlir
index e9793c15a5272..21bcbcffbace7 100644
--- a/mlir/test/Dialect/LLVMIR/debuginfo.mlir
+++ b/mlir/test/Dialect/LLVMIR/debuginfo.mlir
@@ -29,6 +29,12 @@
   sizeInBits = 32, encoding = DW_ATE_signed
 >
 
+// CHECK-DAG: #[[FLOAT1:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "float1", sizeInBits = 32, encoding = DW_ATE_float>
+#float1 = #llvm.di_basic_type<
+  tag = DW_TAG_base_type, name = "float1",
+  sizeInBits = 32, encoding = DW_ATE_float
+>
+
 // CHECK-DAG: #[[PTR0:.*]] = #llvm.di_derived_type<tag = DW_TAG_pointer_type, baseType = #[[INT0]], sizeInBits = 64, alignInBits = 32, offsetInBits = 4, extraData = #[[INT1]]>
 #ptr0 = #llvm.di_derived_type<
   tag = DW_TAG_pointer_type, baseType = #int0,
@@ -74,6 +80,31 @@
   elements = #llvm.di_subrange<count = 4>
 >
 
+// CHECK-DAG: #[[DISC:.*]] = #llvm.di_derived_type<tag = DW_TAG_member, name = "discriminator", baseType = #[[INT0]], flags = Artificial>
+#disc = #llvm.di_derived_type<
+  tag = DW_TAG_member, name = "discriminator", baseType = #int0,
+  flags = Artificial
+>
+
+// CHECK-DAG: #[[ELEM_INT:.*]] = #llvm.di_derived_type<tag = DW_TAG_member, name = "_int1", baseType = #[[INT1]], extraData = 1 : i8>
+#elemInt = #llvm.di_derived_type<
+  tag = DW_TAG_member, name = "_int1", baseType = #int1,
+  extraData = 1 : i8
+>
+
+// CHECK-DAG: #[[ELEM_FLOAT:.*]] = #llvm.di_derived_type<tag = DW_TAG_member, name = "_float1", baseType = #[[FLOAT1]], extraData = 2 : i8>
+#elemFloat = #llvm.di_derived_type<
+  tag = DW_TAG_member, name = "_float1", baseType = #float1,
+  extraData = 2 : i8
+>
+
+// CHECK-DAG: #[[VARIANT:.*]] = #llvm.di_composite_type<tag = DW_TAG_variant_part, name = "variant_part", identifier = "variant-id", discriminator = #[[DISC]], elements = #[[ELEM_INT]], #[[ELEM_FLOAT]]>
+#variant = #llvm.di_composite_type<
+  tag = DW_TAG_variant_part, name = "variant_part",
+  identifier = "variant-id", discriminator = #disc,
+  elements = #elemInt, #elemFloat
+>
+
 // CHECK-DAG: #[[TOPLEVEL:.*]] = #llvm.di_namespace<name = "toplevel", exportSymbols = true>
 #toplevel_namespace = #llvm.di_namespace<
   name = "toplevel", exportSymbols = true
@@ -104,9 +135,9 @@
  name = "expr_elements2", baseType = #int0, elements =
  #llvm.di_generic_subrange<count = #exp1, lowerBound = #exp2, stride = #exp3>>
 
-// CHECK-DAG: #[[SPTYPE0:.*]] = #llvm.di_subroutine_type<callingConvention = D...
[truncated]

@bzcheeseman bzcheeseman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me, but @gysit might have context I don't so please wait for their review as well.

@bzcheeseman
bzcheeseman requested a review from gysit May 1, 2026 19:06

@gysit gysit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

LGTM modulo nit.

Comment thread mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td Outdated
Co-authored-by: Tobias Gysi <tobias.gysi@nextsilicon.com>
@jiel-nv

jiel-nv commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

@bzcheeseman @gysit thank you for the review. Could you also approve the CI workflow? Thanks!

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

✅ With the latest revision this PR passed the C/C++ code formatter.

@jiel-nv

jiel-nv commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

Looks like the workflow needs approval again after the clang-format push @gysit

@jiel-nv

jiel-nv commented May 4, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Could someone help with merging/landing this at your convenience?

@gysit
gysit merged commit d7693e3 into llvm:main May 4, 2026
10 checks passed
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

@jiel-nv Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@llvm-ci

llvm-ci commented May 4, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder mlir-rocm-mi200 running on mi200-buildbot while building flang,mlir at step 7 "test-build-check-mlir-build-only-check-mlir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/177/builds/34071

Here is the relevant piece of the build log for the reference
Step 7 (test-build-check-mlir-build-only-check-mlir) failure: test (failure)
******************** TEST 'MLIR :: Target/LLVMIR/llvmir-debug.mlir' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/vol/worker/mi200-buildbot/mlir-rocm-mi200/build/bin/mlir-translate -mlir-to-llvmir --split-input-file /vol/worker/mi200-buildbot/mlir-rocm-mi200/llvm-project/mlir/test/Target/LLVMIR/llvmir-debug.mlir | /vol/worker/mi200-buildbot/mlir-rocm-mi200/build/bin/FileCheck /vol/worker/mi200-buildbot/mlir-rocm-mi200/llvm-project/mlir/test/Target/LLVMIR/llvmir-debug.mlir --check-prefixes=CHECK,RECORDS
# executed command: /vol/worker/mi200-buildbot/mlir-rocm-mi200/build/bin/mlir-translate -mlir-to-llvmir --split-input-file /vol/worker/mi200-buildbot/mlir-rocm-mi200/llvm-project/mlir/test/Target/LLVMIR/llvmir-debug.mlir
# .---command stderr------------
# | DISubprogram requires a non-null type
# | !3 = distinct !DISubprogram(name: "variant_part_emission", scope: !1, file: !1, spFlags: DISPFlagDefinition, unit: !0)
# `-----------------------------
# error: command failed with exit status: 1
# executed command: /vol/worker/mi200-buildbot/mlir-rocm-mi200/build/bin/FileCheck /vol/worker/mi200-buildbot/mlir-rocm-mi200/llvm-project/mlir/test/Target/LLVMIR/llvmir-debug.mlir --check-prefixes=CHECK,RECORDS
# .---command stderr------------
# | /vol/worker/mi200-buildbot/mlir-rocm-mi200/llvm-project/mlir/test/Target/LLVMIR/llvmir-debug.mlir:837:17: error: CHECK-LABEL: expected string not found in input
# | // CHECK-LABEL: define void @variant_part_emission
# |                 ^
# | <stdin>:507:34: note: scanning from here
# | define void @fn_cu_import_cycle() !dbg !6 {
# |                                  ^
# | <stdin>:514:89: note: possible intended match here
# | !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "p", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, imports: !2)
# |                                                                                         ^
# | 
# | Input file: <stdin>
# | Check file: /vol/worker/mi200-buildbot/mlir-rocm-mi200/llvm-project/mlir/test/Target/LLVMIR/llvmir-debug.mlir
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |              .
# |              .
# |              .
# |            502: !9 = !DILocation(line: 22, column: 3, scope: !6) 
# |            503:  
# |            504: ; ModuleID = 'LLVMDialectModule' 
# |            505: source_filename = "LLVMDialectModule" 
# |            506:  
# |            507: define void @fn_cu_import_cycle() !dbg !6 { 
# | label:837'0                                      X~~~~~~~~~~ error: no match found
# |            508:  ret void, !dbg !9 
# | label:837'0     ~~~~~~~~~~~~~~~~~~~
# |            509: } 
# | label:837'0     ~~
# |            510:  
# | label:837'0     ~
# |            511: !llvm.dbg.cu = !{!0} 
# | label:837'0     ~~~~~~~~~~~~~~~~~~~~~
...

@rupprecht

Copy link
Copy Markdown
Contributor

LLVM Buildbot has detected a new failure on builder mlir-rocm-mi200 running on mi200-buildbot while building flang,mlir at step 7 "test-build-check-mlir-build-only-check-mlir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/177/builds/34071

Here is the relevant piece of the build log for the reference

This failure is real, but not totally the fault of this PR, since it was a race condition between this and a different PR that adds extra validation. #195720 updates the test.

@gysit

gysit commented May 4, 2026

Copy link
Copy Markdown
Contributor

Thanks for the quick fix!

rupprecht added a commit that referenced this pull request May 4, 2026
Needed after #194556, and #195321 missed out on the cleanup since it was
still in review.
@llvm-ci

llvm-ci commented May 4, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder ppc64le-mlir-rhel-clang running on ppc64le-mlir-rhel-test while building flang,mlir at step 6 "test-build-check-mlir-build-only-check-mlir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/129/builds/43904

Here is the relevant piece of the build log for the reference
Step 6 (test-build-check-mlir-build-only-check-mlir) failure: test (failure)
******************** TEST 'MLIR :: Target/LLVMIR/llvmir-debug.mlir' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/build/bin/mlir-translate -mlir-to-llvmir --split-input-file /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/test/Target/LLVMIR/llvmir-debug.mlir | /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/test/Target/LLVMIR/llvmir-debug.mlir --check-prefixes=CHECK,RECORDS
# executed command: /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/build/bin/mlir-translate -mlir-to-llvmir --split-input-file /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/test/Target/LLVMIR/llvmir-debug.mlir
# .---command stderr------------
# | DISubprogram requires a non-null type
# | !3 = distinct !DISubprogram(name: "variant_part_emission", scope: !1, file: !1, spFlags: DISPFlagDefinition, unit: !0)
# `-----------------------------
# error: command failed with exit status: 1
# executed command: /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/build/bin/FileCheck /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/test/Target/LLVMIR/llvmir-debug.mlir --check-prefixes=CHECK,RECORDS
# .---command stderr------------
# | /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/test/Target/LLVMIR/llvmir-debug.mlir:837:17: error: CHECK-LABEL: expected string not found in input
# | // CHECK-LABEL: define void @variant_part_emission
# |                 ^
# | <stdin>:507:34: note: scanning from here
# | define void @fn_cu_import_cycle() !dbg !6 {
# |                                  ^
# | <stdin>:514:89: note: possible intended match here
# | !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "p", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, imports: !2)
# |                                                                                         ^
# | 
# | Input file: <stdin>
# | Check file: /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/test/Target/LLVMIR/llvmir-debug.mlir
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |              .
# |              .
# |              .
# |            502: !9 = !DILocation(line: 22, column: 3, scope: !6) 
# |            503:  
# |            504: ; ModuleID = 'LLVMDialectModule' 
# |            505: source_filename = "LLVMDialectModule" 
# |            506:  
# |            507: define void @fn_cu_import_cycle() !dbg !6 { 
# | label:837'0                                      X~~~~~~~~~~ error: no match found
# |            508:  ret void, !dbg !9 
# | label:837'0     ~~~~~~~~~~~~~~~~~~~
# |            509: } 
# | label:837'0     ~~
# |            510:  
# | label:837'0     ~
# |            511: !llvm.dbg.cu = !{!0} 
# | label:837'0     ~~~~~~~~~~~~~~~~~~~~~
...

moar55 pushed a commit to moar55/llvm-project that referenced this pull request May 12, 2026
#### Summary

This PR extends the MLIR LLVM dialect debug-info attributes to represent
DWARF variant parts, discriminators, and per-alternative discriminator
values.

The change adds `identifier` and `discriminator` support to
`DICompositeTypeAttr`, allowing MLIR to model `DW_TAG_variant_part`
metadata that LLVM IR already supports. It also broadens
`DIDerivedTypeAttr`'s `extraData` field from `DINodeAttr` to a verified
polymorphic `Attribute`, supporting both debug-info nodes and integer
constants used by variant alternatives.

#### Details

- Add `identifier` and `discriminator` fields to `DICompositeTypeAttr`,
bytecode serialization, LLVM IR import/export, C API bindings, and Flang
call sites.
- Change `DIDerivedTypeAttr.extraData` to accept either `DINodeAttr` or
`IntegerAttr`, with verifier coverage for invalid attribute kinds.
- Preserve integer bit width when importing
`ConstantAsMetadata(ConstantInt)` into MLIR.
- Add parse/print, verifier, LLVM IR import/export, and C API test
coverage for variant-part debug info.

---------

Co-authored-by: Tobias Gysi <tobias.gysi@nextsilicon.com>
moar55 pushed a commit to moar55/llvm-project that referenced this pull request May 12, 2026
Needed after llvm#194556, and llvm#195321 missed out on the cleanup since it was
still in review.
antiagainst added a commit to triton-lang/triton that referenced this pull request Jun 4, 2026
- Dropped -Os and -Oz after llvm/llvm-project#191363
- Emit scalar `{add,sub,mul}.rn.bf16` ops after llvm/llvm-project#190414
- Also changed to avoid hardcoding line numbers in test_line_info.py
- Add identifier/discriminator arguments to DICompositeTypeAttr::get
  calls after llvm/llvm-project#195321
- Pass MCRegisterInfo and MCSubtargetInfo by reference when constructing
  MCContext after llvm/llvm-project#195032
- Replace NVVM::Barrier0Op and nvvm.barrier0 test expectations with
  NVVM::BarrierOp/nvvm.barrier after llvm/llvm-project#195608
ThomasRaoux pushed a commit to ThomasRaoux/triton that referenced this pull request Jun 5, 2026
- Dropped -Os and -Oz after llvm/llvm-project#191363
- Emit scalar `{add,sub,mul}.rn.bf16` ops after llvm/llvm-project#190414
- Also changed to avoid hardcoding line numbers in test_line_info.py
- Add identifier/discriminator arguments to DICompositeTypeAttr::get
  calls after llvm/llvm-project#195321
- Pass MCRegisterInfo and MCSubtargetInfo by reference when constructing
  MCContext after llvm/llvm-project#195032
- Replace NVVM::Barrier0Op and nvvm.barrier0 test expectations with
  NVVM::BarrierOp/nvvm.barrier after llvm/llvm-project#195608
ThomasRaoux added a commit to triton-lang/triton that referenced this pull request Jun 5, 2026
* Dropped -Os and -Oz after
llvm/llvm-project#191363
* Emit scalar {add,sub,mul}.rn.bf16 ops after
llvm/llvm-project#190414
* Also changed to avoid hardcoding line numbers in test_line_info.py
* Add identifier/discriminator arguments to DICompositeTypeAttr::get
* calls after llvm/llvm-project#195321
* Pass MCRegisterInfo and MCSubtargetInfo by reference when constructing
* MCContext after llvm/llvm-project#195032
* Replace NVVM::Barrier0Op and nvvm.barrier0 test expectations with
* NVVM::BarrierOp/nvvm.barrier after
llvm/llvm-project#195608
* Update AMD target parser includes after
llvm/llvm-project#198433
* Add explicit TypeID for AMD UniformityAnalysis after
llvm/llvm-project#199634
* Update finite-trip-count AMD range analysis after
llvm/llvm-project#196616
* Update NVVM::BarrierOp creation after
llvm/llvm-project#199404

also disable SLP vectorizer on sm_80 to workaround a ptxas bug

---------

Co-authored-by: Lei Zhang <antiagainst@gmail.com>
Co-authored-by: Lei Zhang <Lei.Zhang2@amd.com>
neudinger pushed a commit to zml/intel-xpu-backend-for-triton that referenced this pull request Jun 23, 2026
* Dropped -Os and -Oz after
llvm/llvm-project#191363
* Emit scalar {add,sub,mul}.rn.bf16 ops after
llvm/llvm-project#190414
* Also changed to avoid hardcoding line numbers in test_line_info.py
* Add identifier/discriminator arguments to DICompositeTypeAttr::get
* calls after llvm/llvm-project#195321
* Pass MCRegisterInfo and MCSubtargetInfo by reference when constructing
* MCContext after llvm/llvm-project#195032
* Replace NVVM::Barrier0Op and nvvm.barrier0 test expectations with
* NVVM::BarrierOp/nvvm.barrier after
llvm/llvm-project#195608
* Update AMD target parser includes after
llvm/llvm-project#198433
* Add explicit TypeID for AMD UniformityAnalysis after
llvm/llvm-project#199634
* Update finite-trip-count AMD range analysis after
llvm/llvm-project#196616
* Update NVVM::BarrierOp creation after
llvm/llvm-project#199404

also disable SLP vectorizer on sm_80 to workaround a ptxas bug

---------

Co-authored-by: Lei Zhang <antiagainst@gmail.com>
Co-authored-by: Lei Zhang <Lei.Zhang2@amd.com>
ngocson2vn pushed a commit to ngocson2vn/triton that referenced this pull request Jul 5, 2026
* Dropped -Os and -Oz after
llvm/llvm-project#191363
* Emit scalar {add,sub,mul}.rn.bf16 ops after
llvm/llvm-project#190414
* Also changed to avoid hardcoding line numbers in test_line_info.py
* Add identifier/discriminator arguments to DICompositeTypeAttr::get
* calls after llvm/llvm-project#195321
* Pass MCRegisterInfo and MCSubtargetInfo by reference when constructing
* MCContext after llvm/llvm-project#195032
* Replace NVVM::Barrier0Op and nvvm.barrier0 test expectations with
* NVVM::BarrierOp/nvvm.barrier after
llvm/llvm-project#195608
* Update AMD target parser includes after
llvm/llvm-project#198433
* Add explicit TypeID for AMD UniformityAnalysis after
llvm/llvm-project#199634
* Update finite-trip-count AMD range analysis after
llvm/llvm-project#196616
* Update NVVM::BarrierOp creation after
llvm/llvm-project#199404

also disable SLP vectorizer on sm_80 to workaround a ptxas bug

---------

Co-authored-by: Lei Zhang <antiagainst@gmail.com>
Co-authored-by: Lei Zhang <Lei.Zhang2@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:fir-hlfir flang Flang issues not falling into any other category mlir:llvm mlir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants