Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mlir][LLVMIR] Add operand bundle support for llvm.intr.assume #112143

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

Lancern
Copy link
Member

@Lancern Lancern commented Oct 13, 2024

This PR adds operand bundle support for llvm.intr.assume.

This PR actually contains two parts:

  • llvm.intr.assume now accepts operand bundle related attributes and operands. llvm.intr.assume does not take constraint on the operand bundles, but obviously only a few set of operand bundles are meaningful. I plan to add some of those (e.g. aligned and separate_storage are what interest me but other people may be interested in other operand bundles as well) in future patches.

  • The definitions of llvm.call, llvm.invoke, and llvm.call_intrinsic actually define op_bundle_tags as an operation property. It turns out this approach would introduce some unnecessary burden if applied equally to the intrinsic operations because properties are not available through Operation * but we have to operate on Operation * during the import/export of intrinsics, so this PR changes it from a property to an array attribute.

@Lancern Lancern requested a review from grypp as a code owner October 13, 2024 15:33
@Lancern Lancern requested review from gysit and Dinistro and removed request for grypp October 13, 2024 15:34
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 13, 2024

@llvm/pr-subscribers-mlir-sme
@llvm/pr-subscribers-mlir-llvm

@llvm/pr-subscribers-mlir

Author: Sirui Mu (Lancern)

Changes

This PR adds operand bundle support for llvm.intr.assume.

This PR actually contains two parts:

  • llvm.intr.assume now accepts operand bundle related attributes and operands. llvm.intr.assume does not take constraint on the operand bundles, but obviously only a few set of operand bundles are meaningful. I plan to add some of those (e.g. aligned and separate_storage are what interest me but other people may be interested in other operand bundles as well) in future patches.

  • The definitions of llvm.call, llvm.invoke, and llvm.call_intrinsic actually define op_bundle_tags as an operation property. It turns out this approach would introduce some unnecessary burden if applied equally to the intrinsic operations, so this PR changes it from a property to an array attribute.


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

17 Files Affected:

  • (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td (+27-3)
  • (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td (+20-6)
  • (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td (+3-15)
  • (modified) mlir/include/mlir/Target/LLVMIR/ModuleImport.h (+3)
  • (modified) mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h (+2-2)
  • (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp (+64-33)
  • (modified) mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMIRToLLVMTranslation.cpp (+6)
  • (modified) mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp (+13-3)
  • (modified) mlir/lib/Target/LLVMIR/Dialect/NVVM/LLVMIRToNVVMTranslation.cpp (+6)
  • (modified) mlir/lib/Target/LLVMIR/ModuleImport.cpp (+35-2)
  • (modified) mlir/lib/Target/LLVMIR/ModuleTranslation.cpp (+37-4)
  • (modified) mlir/test/Conversion/MemRefToLLVM/expand-then-convert-to-llvm.mlir (+1-1)
  • (modified) mlir/test/Conversion/MemRefToLLVM/memref-to-llvm.mlir (+2-2)
  • (modified) mlir/test/Dialect/LLVMIR/inlining.mlir (+2-2)
  • (modified) mlir/test/Dialect/LLVMIR/roundtrip.mlir (+27)
  • (modified) mlir/test/Target/LLVMIR/Import/intrinsic.ll (+1-1)
  • (modified) mlir/test/Target/LLVMIR/llvmir-invalid.mlir (+1-1)
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
index 448a171cf3e412..c56065af07b10e 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -365,8 +365,8 @@ class LLVM_ConstrainedIntr<string mnem, int numArgs,
     SmallVector<Value> mlirOperands;
     SmallVector<NamedAttribute> mlirAttrs;
     if (failed(moduleImport.convertIntrinsicArguments(
-        llvmOperands.take_front( }] # numArgs # [{),
-        {}, {}, mlirOperands, mlirAttrs))) {
+        llvmOperands.take_front( }] # numArgs # [{), {}, {}, {},
+        StringLiteral(""), StringLiteral(""), mlirOperands, mlirAttrs))) {
       return failure();
     }
 
@@ -426,7 +426,31 @@ def LLVM_USHLSat : LLVM_BinarySameArgsIntrOpI<"ushl.sat">;
 //
 
 def LLVM_AssumeOp
-  : LLVM_ZeroResultIntrOp<"assume", []>, Arguments<(ins I1:$cond)>;
+    : LLVM_ZeroResultIntrOp<"assume", /*overloadedOperands=*/[], /*traits=*/[],
+                            /*requiresAccessGroup=*/0,
+                            /*requiresAliasAnalysis=*/0,
+                            /*immArgPositions=*/[], /*immArgAttrNames=*/[],
+                            /*opBundleSizesAttrName=*/"op_bundle_sizes",
+                            /*opBundleTagsAttrName=*/"op_bundle_tags"> {
+  let arguments = (ins I1:$cond,
+                       VariadicOfVariadic<LLVM_Type,
+                                         "op_bundle_sizes">:$op_bundle_operands,
+                       DenseI32ArrayAttr:$op_bundle_sizes,
+                       OptionalAttr<ArrayAttr>:$op_bundle_tags);
+
+  let assemblyFormat = [{
+    $cond
+    ( custom<OpBundles>($op_bundle_operands, type($op_bundle_operands),
+                        $op_bundle_tags)^ )?
+    `:` `(` type($cond) `)` `->` `(` `)` attr-dict
+  }];
+
+  let builders = [
+    OpBuilder<(ins "Value":$cond)>
+  ];
+
+  let hasVerifier = 1;
+}
 
 def LLVM_SSACopyOp : LLVM_OneResultIntrOp<"ssa.copy", [], [0],
                                             [Pure, SameOperandsAndResultType]> {
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
index c3d352d8d0dd48..dc59baed67472a 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
@@ -293,7 +293,9 @@ class LLVM_IntrOpBase<Dialect dialect, string opName, string enumName,
                       bit requiresAccessGroup = 0, bit requiresAliasAnalysis = 0,
                       bit requiresFastmath = 0,
                       list<int> immArgPositions = [],
-                      list<string> immArgAttrNames = []>
+                      list<string> immArgAttrNames = [],
+                      string opBundleSizesAttrName = "",
+                      string opBundleTagsAttrName = "">
     : LLVM_OpBase<dialect, opName, !listconcat(
         !if(!gt(requiresAccessGroup, 0),
             [DeclareOpInterfaceMethods<AccessGroupOpInterface>], []),
@@ -319,11 +321,14 @@ class LLVM_IntrOpBase<Dialect dialect, string opName, string enumName,
   string immArgPositionsCpp = "{" # !interleave(immArgPositions, ", ") # "}";
   string immArgAttrNamesCpp = "{" # !interleave(!foreach(name, immArgAttrNames,
     "StringLiteral(\"" # name # "\")"), ", ") # "}";
+  string opBundleSizesAttrNameCpp = "StringLiteral(\"" # opBundleSizesAttrName # "\")";
+  string opBundleTagsAttrNameCpp = "StringLiteral(\"" # opBundleTagsAttrName # "\")";
   string baseLlvmBuilder = [{
     auto *inst = LLVM::detail::createIntrinsicCall(
       builder, moduleTranslation, &opInst, llvm::Intrinsic::}] # !interleave([
         enumName, "" # numResults, overloadedResultsCpp, overloadedOperandsCpp,
-        immArgPositionsCpp, immArgAttrNamesCpp], ",") # [{);
+        immArgPositionsCpp, immArgAttrNamesCpp, opBundleSizesAttrNameCpp], ",")
+        # ", " # opBundleTagsAttrNameCpp # [{);
     (void) inst;
     }];
   string baseLlvmBuilderCoda = !if(!gt(numResults, 0), "$res = inst;", "");
@@ -336,8 +341,11 @@ class LLVM_IntrOpBase<Dialect dialect, string opName, string enumName,
     SmallVector<NamedAttribute> mlirAttrs;
     if (failed(moduleImport.convertIntrinsicArguments(
       llvmOperands,
+      opBundles,
       }] # immArgPositionsCpp # [{,
       }] # immArgAttrNamesCpp # [{,
+      }] # opBundleSizesAttrNameCpp # [{,
+      }] # opBundleTagsAttrNameCpp # [{,
       mlirOperands,
       mlirAttrs))
     ) {
@@ -382,11 +390,14 @@ class LLVM_IntrOp<string mnem, list<int> overloadedResults,
                   int numResults, bit requiresAccessGroup = 0,
                   bit requiresAliasAnalysis = 0, bit requiresFastmath = 0,
                   list<int> immArgPositions = [],
-                  list<string> immArgAttrNames = []>
+                  list<string> immArgAttrNames = [],
+                  string opBundleSizesAttrName = "",
+                  string opBundleTagsAttrName = "">
     : LLVM_IntrOpBase<LLVM_Dialect, "intr." # mnem, !subst(".", "_", mnem),
                       overloadedResults, overloadedOperands, traits,
                       numResults, requiresAccessGroup, requiresAliasAnalysis,
-                      requiresFastmath, immArgPositions, immArgAttrNames>;
+                      requiresFastmath, immArgPositions, immArgAttrNames,
+                      opBundleSizesAttrName, opBundleTagsAttrName>;
 
 // Base class for LLVM intrinsic operations returning no results. Places the
 // intrinsic into the LLVM dialect and prefixes its name with "intr.".
@@ -407,10 +418,13 @@ class LLVM_ZeroResultIntrOp<string mnem, list<int> overloadedOperands = [],
                             bit requiresAccessGroup = 0,
                             bit requiresAliasAnalysis = 0,
                             list<int> immArgPositions = [],
-                            list<string> immArgAttrNames = []>
+                            list<string> immArgAttrNames = [],
+                            string opBundleSizesAttrName = "",
+                            string opBundleTagsAttrName = "">
     : LLVM_IntrOp<mnem, [], overloadedOperands, traits, /*numResults=*/0,
                   requiresAccessGroup, requiresAliasAnalysis,
-                  /*requiresFastMath=*/0, immArgPositions, immArgAttrNames>;
+                  /*requiresFastMath=*/0, immArgPositions, immArgAttrNames,
+                  opBundleSizesAttrName, opBundleTagsAttrName>;
 
 // Base class for LLVM intrinsic operations returning one result. Places the
 // intrinsic into the LLVM dialect and prefixes its name with "intr.". This is
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
index 000d92f9ea3bcb..d388de3960f2b2 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -559,11 +559,7 @@ def LLVM_InvokeOp : LLVM_Op<"invoke", [
                    VariadicOfVariadic<LLVM_Type,
                                       "op_bundle_sizes">:$op_bundle_operands,
                    DenseI32ArrayAttr:$op_bundle_sizes,
-                   DefaultValuedProperty<
-                     ArrayProperty<StringProperty, "operand bundle tags">,
-                     "ArrayRef<std::string>{}",
-                     "SmallVector<std::string>{}"
-                   >:$op_bundle_tags);
+                   OptionalAttr<ArrayAttr>:$op_bundle_tags);
   let results = (outs Optional<LLVM_Type>:$result);
   let successors = (successor AnySuccessor:$normalDest,
                               AnySuccessor:$unwindDest);
@@ -678,11 +674,7 @@ def LLVM_CallOp : LLVM_MemAccessOpBase<"call",
                   VariadicOfVariadic<LLVM_Type,
                                      "op_bundle_sizes">:$op_bundle_operands,
                   DenseI32ArrayAttr:$op_bundle_sizes,
-                  DefaultValuedProperty<
-                    ArrayProperty<StringProperty, "operand bundle tags">,
-                    "ArrayRef<std::string>{}",
-                    "SmallVector<std::string>{}"
-                  >:$op_bundle_tags);
+                  OptionalAttr<ArrayAttr>:$op_bundle_tags);
   // Append the aliasing related attributes defined in LLVM_MemAccessOpBase.
   let arguments = !con(args, aliasAttrs);
   let results = (outs Optional<LLVM_Type>:$result);
@@ -1930,11 +1922,7 @@ def LLVM_CallIntrinsicOp
                        VariadicOfVariadic<LLVM_Type,
                                           "op_bundle_sizes">:$op_bundle_operands,
                        DenseI32ArrayAttr:$op_bundle_sizes,
-                       DefaultValuedProperty<
-                         ArrayProperty<StringProperty, "operand bundle tags">,
-                         "ArrayRef<std::string>{}",
-                         "SmallVector<std::string>{}"
-                       >:$op_bundle_tags);
+                       OptionalAttr<ArrayAttr>:$op_bundle_tags);
   let results = (outs Optional<LLVM_Type>:$results);
   let llvmBuilder = [{
     return convertCallLLVMIntrinsicOp(op, builder, moduleTranslation);
diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleImport.h b/mlir/include/mlir/Target/LLVMIR/ModuleImport.h
index 436675793062eb..a2cf065bb9eb76 100644
--- a/mlir/include/mlir/Target/LLVMIR/ModuleImport.h
+++ b/mlir/include/mlir/Target/LLVMIR/ModuleImport.h
@@ -239,8 +239,11 @@ class ModuleImport {
   /// corresponding MLIR attribute names.
   LogicalResult
   convertIntrinsicArguments(ArrayRef<llvm::Value *> values,
+                            ArrayRef<llvm::OperandBundleUse> opBundles,
                             ArrayRef<unsigned> immArgPositions,
                             ArrayRef<StringLiteral> immArgAttrNames,
+                            StringLiteral opBundleSizesAttrName,
+                            StringLiteral opBundleTagsAttrName,
                             SmallVectorImpl<Value> &valuesOut,
                             SmallVectorImpl<NamedAttribute> &attrsOut);
 
diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
index 3c85338bc642f6..4a8503ceb4cd9c 100644
--- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
+++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
@@ -431,8 +431,8 @@ llvm::CallInst *createIntrinsicCall(
     llvm::IRBuilderBase &builder, ModuleTranslation &moduleTranslation,
     Operation *intrOp, llvm::Intrinsic::ID intrinsic, unsigned numResults,
     ArrayRef<unsigned> overloadedResults, ArrayRef<unsigned> overloadedOperands,
-    ArrayRef<unsigned> immArgPositions,
-    ArrayRef<StringLiteral> immArgAttrNames);
+    ArrayRef<unsigned> immArgPositions, ArrayRef<StringLiteral> immArgAttrNames,
+    StringLiteral opBundleSizesAttrName, StringLiteral opBundleTagsAttrName);
 
 } // namespace detail
 
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 006d412936a337..967aafd1dbc86e 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -241,13 +241,18 @@ static void printOneOpBundle(OpAsmPrinter &p, OperandRange operands,
 static void printOpBundles(OpAsmPrinter &p, Operation *op,
                            OperandRangeRange opBundleOperands,
                            TypeRangeRange opBundleOperandTypes,
-                           ArrayRef<std::string> opBundleTags) {
+                           std::optional<ArrayAttr> opBundleTags) {
+  if (opBundleOperands.empty())
+    return;
+  assert(opBundleTags && "expect operand bundle tags");
+
   p << "[";
   llvm::interleaveComma(
-      llvm::zip(opBundleOperands, opBundleOperandTypes, opBundleTags), p,
+      llvm::zip(opBundleOperands, opBundleOperandTypes, *opBundleTags), p,
       [&p](auto bundle) {
+        auto bundleTag = llvm::cast<StringAttr>(std::get<2>(bundle)).getValue();
         printOneOpBundle(p, std::get<0>(bundle), std::get<1>(bundle),
-                         std::get<2>(bundle));
+                         bundleTag);
       });
   p << "]";
 }
@@ -256,7 +261,7 @@ static ParseResult parseOneOpBundle(
     OpAsmParser &p,
     SmallVector<SmallVector<OpAsmParser::UnresolvedOperand>> &opBundleOperands,
     SmallVector<SmallVector<Type>> &opBundleOperandTypes,
-    SmallVector<std::string> &opBundleTags) {
+    SmallVector<Attribute> &opBundleTags) {
   SMLoc currentParserLoc = p.getCurrentLocation();
   SmallVector<OpAsmParser::UnresolvedOperand> operands;
   SmallVector<Type> types;
@@ -276,7 +281,7 @@ static ParseResult parseOneOpBundle(
 
   opBundleOperands.push_back(std::move(operands));
   opBundleOperandTypes.push_back(std::move(types));
-  opBundleTags.push_back(std::move(tag));
+  opBundleTags.push_back(StringAttr::get(p.getContext(), tag));
 
   return success();
 }
@@ -285,16 +290,17 @@ static std::optional<ParseResult> parseOpBundles(
     OpAsmParser &p,
     SmallVector<SmallVector<OpAsmParser::UnresolvedOperand>> &opBundleOperands,
     SmallVector<SmallVector<Type>> &opBundleOperandTypes,
-    SmallVector<std::string> &opBundleTags) {
+    ArrayAttr &opBundleTags) {
   if (p.parseOptionalLSquare())
     return std::nullopt;
 
   if (succeeded(p.parseOptionalRSquare()))
     return success();
 
+  SmallVector<Attribute> opBundleTagAttrs;
   auto bundleParser = [&] {
     return parseOneOpBundle(p, opBundleOperands, opBundleOperandTypes,
-                            opBundleTags);
+                            opBundleTagAttrs);
   };
   if (p.parseCommaSeparatedList(bundleParser))
     return failure();
@@ -302,6 +308,8 @@ static std::optional<ParseResult> parseOpBundles(
   if (p.parseRSquare())
     return failure();
 
+  opBundleTags = ArrayAttr::get(p.getContext(), opBundleTagAttrs);
+
   return success();
 }
 
@@ -1039,7 +1047,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state, TypeRange results,
         /*CConv=*/nullptr, /*TailCallKind=*/nullptr,
         /*memory_effects=*/nullptr,
         /*convergent=*/nullptr, /*no_unwind=*/nullptr, /*will_return=*/nullptr,
-        /*op_bundle_operands=*/{}, /*op_bundle_tags=*/std::nullopt,
+        /*op_bundle_operands=*/{}, /*op_bundle_tags=*/{},
         /*access_groups=*/nullptr, /*alias_scopes=*/nullptr,
         /*noalias_scopes=*/nullptr, /*tbaa=*/nullptr);
 }
@@ -1066,7 +1074,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state,
         /*TailCallKind=*/nullptr, /*memory_effects=*/nullptr,
         /*convergent=*/nullptr,
         /*no_unwind=*/nullptr, /*will_return=*/nullptr,
-        /*op_bundle_operands=*/{}, /*op_bundle_tags=*/std::nullopt,
+        /*op_bundle_operands=*/{}, /*op_bundle_tags=*/{},
         /*access_groups=*/nullptr,
         /*alias_scopes=*/nullptr, /*noalias_scopes=*/nullptr, /*tbaa=*/nullptr);
 }
@@ -1079,7 +1087,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state,
         /*fastmathFlags=*/nullptr, /*branch_weights=*/nullptr,
         /*CConv=*/nullptr, /*TailCallKind=*/nullptr, /*memory_effects=*/nullptr,
         /*convergent=*/nullptr, /*no_unwind=*/nullptr, /*will_return=*/nullptr,
-        /*op_bundle_operands=*/{}, /*op_bundle_tags=*/std::nullopt,
+        /*op_bundle_operands=*/{}, /*op_bundle_tags=*/{},
         /*access_groups=*/nullptr, /*alias_scopes=*/nullptr,
         /*noalias_scopes=*/nullptr, /*tbaa=*/nullptr);
 }
@@ -1092,7 +1100,7 @@ void CallOp::build(OpBuilder &builder, OperationState &state, LLVMFuncOp func,
         /*fastmathFlags=*/nullptr, /*branch_weights=*/nullptr,
         /*CConv=*/nullptr, /*TailCallKind=*/nullptr, /*memory_effects=*/nullptr,
         /*convergent=*/nullptr, /*no_unwind=*/nullptr, /*will_return=*/nullptr,
-        /*op_bundle_operands=*/{}, /*op_bundle_tags=*/std::nullopt,
+        /*op_bundle_operands=*/{}, /*op_bundle_tags=*/{},
         /*access_groups=*/nullptr, /*alias_scopes=*/nullptr,
         /*noalias_scopes=*/nullptr, /*tbaa=*/nullptr);
 }
@@ -1192,12 +1200,21 @@ LogicalResult verifyCallOpVarCalleeType(OpTy callOp) {
 template <typename OpType>
 static LogicalResult verifyOperandBundles(OpType &op) {
   OperandRangeRange opBundleOperands = op.getOpBundleOperands();
-  ArrayRef<std::string> opBundleTags = op.getOpBundleTags();
+  std::optional<ArrayAttr> opBundleTags = op.getOpBundleTags();
 
-  if (opBundleTags.size() != opBundleOperands.size())
+  if (opBundleTags) {
+    for (Attribute tagAttr : *opBundleTags) {
+      if (!llvm::isa<StringAttr>(tagAttr))
+        return op.emitError("operand bundle tag must be a StringAttr");
+    }
+  }
+
+  size_t numOpBundles = opBundleOperands.size();
+  size_t numOpBundleTags = opBundleTags ? opBundleTags->size() : 0;
+  if (numOpBundles != numOpBundleTags)
     return op.emitError("expected ")
-           << opBundleOperands.size()
-           << " operand bundle tags, but actually got " << opBundleTags.size();
+           << numOpBundles << " operand bundle tags, but actually got "
+           << numOpBundleTags;
 
   return success();
 }
@@ -1329,7 +1346,8 @@ void CallOp::print(OpAsmPrinter &p) {
                           {getCalleeAttrName(), getTailCallKindAttrName(),
                            getVarCalleeTypeAttrName(), getCConvAttrName(),
                            getOperandSegmentSizesAttrName(),
-                           getOpBundleSizesAttrName()});
+                           getOpBundleSizesAttrName(),
+                           getOpBundleTagsAttrName()});
 
   p << " : ";
   if (!isDirect)
@@ -1437,7 +1455,7 @@ ParseResult CallOp::parse(OpAsmParser &parser, OperationState &result) {
   SmallVector<OpAsmParser::UnresolvedOperand> operands;
   SmallVector<SmallVector<OpAsmParser::UnresolvedOperand>> opBundleOperands;
   SmallVector<SmallVector<Type>> opBundleOperandTypes;
-  SmallVector<std::string> opBundleTags;
+  ArrayAttr opBundleTags;
 
   // Default to C Calling Convention if no keyword is provided.
   result.addAttribute(
@@ -1483,9 +1501,9 @@ ParseResult CallOp::parse(OpAsmParser &parser, OperationState &result) {
           parser, opBundleOperands, opBundleOperandTypes, opBundleTags);
       result && failed(*result))
     return failure();
-  if (!opBundleTags.empty())
-    result.getOrAddProperties<CallOp::Properties>().op_bundle_tags =
-        std::move(opBundleTags);
+  if (opBundleTags && !opBundleTags.empty())
+    result.addAttribute(CallOp::getOpBundleTagsAttrName(result.name).getValue(),
+                        opBundleTags);
 
   if (parser.parseOptionalAttrDict(result.attributes))
     return failure();
@@ -1525,8 +1543,7 @@ void InvokeOp::build(OpBuilder &builder, OperationState &state, LLVMFuncOp func,
   auto calleeType = func.getFunctionType();
   build(builder, state, getCallOpResultTypes(calleeType),
         getCallOpVarCalleeType(calleeType), SymbolRefAttr::get(func), ops,
-        normalOps, unwindOps, nullptr, nullptr, {}, std::nullopt, normal,
-        unwind);
+        normalOps, unwindOps, nullptr, nullptr, {}, {}, normal, unwind);
 }
 
 void InvokeOp::build(OpBuilder &builder, OperationState &state, TypeRange tys,
@@ -1535,7 +1552,7 @@ void InvokeOp::build(OpBuilder &builder, OperationState &state, TypeRange tys,
                      ValueRange unwindOps) {
   build(builder, state, tys,
         /*var_callee_type=*/nullptr, callee, ops, normalOps, unwindOps, nullptr,
-        nullptr, {}, std::nullopt, normal, unwind);
+        nullptr, {}, {}, normal, unwind);
 }
 
 void InvokeOp::build(OpBuilder &builder, OperationState &state,
@@ -1544,7 +1561,7 @@ void InvokeOp::build(OpBuilder &builder, OperationState &state,
                      Block *unwind, ValueRange unwindOps) {
   build(builder, state, getCallOpResultTypes(calleeType),
         getCallOpVarCalleeType(calleeType), callee, ops, normalOps, unwindOps,
-        nullptr, nullptr, {}, std::nullopt, normal, unwind);
+        nullptr, nullptr, {}, {}, normal, unwind);
 }
 
 SuccessorOperands InvokeOp::getSuccessorOperands(unsigned index) {
@@ -1634,7 +1651,8 @@ void InvokeOp::print(OpAsmPrinter &p) {
   p.printOptionalAttrDict((*this)->getAttrs(),
                           {getCalleeAttrName(), getOperandSegmentSizeAttr(),
                            getCConvAttrName(), getVarCalleeTypeAttrName(),
-                           getOpBundleSizesAttrName()});
+                           getOpBundleSizesAttrName(),
+                           getOpBundleTagsAttrName()});
 
   p << " : ";
   if (!isDirect)
@@ -1657,7 +1675,...
[truncated]

@Lancern Lancern requested a review from grypp October 13, 2024 15:34
Copy link
Contributor

@gysit gysit left a comment

Choose a reason for hiding this comment

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

Thanks a lot for following up on this!

I added some suggestions around the tablegen modifications. In particular, it could make sense to follow the implementation of the alias attributes. Let me know if that doesn't make sense or if you have questions.

mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td Outdated Show resolved Hide resolved
mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td Outdated Show resolved Hide resolved
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp Outdated Show resolved Hide resolved
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp Outdated Show resolved Hide resolved
mlir/test/Target/LLVMIR/Import/intrinsic.ll Outdated Show resolved Hide resolved
mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td Outdated Show resolved Hide resolved
mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td Outdated Show resolved Hide resolved
mlir/lib/Target/LLVMIR/ModuleImport.cpp Outdated Show resolved Hide resolved
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp Outdated Show resolved Hide resolved
@zero9178
Copy link
Member

It turns out this approach would introduce some unnecessary burden if applied equally to the intrinsic operations, so this PR changes it from a property to an array attribute.

What are those burdens? Don't really care either way, but I'm just very curious 🙂 Might also be worth summarizing super shortly in the commit message

Copy link
Contributor

@gysit gysit left a comment

Choose a reason for hiding this comment

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

Nice!

LGTM modulo nit comments.

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp Outdated Show resolved Hide resolved
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp Show resolved Hide resolved
mlir/test/Target/LLVMIR/Import/intrinsic.ll Outdated Show resolved Hide resolved
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp Outdated Show resolved Hide resolved
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp Outdated Show resolved Hide resolved
@Lancern
Copy link
Member Author

Lancern commented Oct 15, 2024

What are those burdens?

The main problem with properties is that they are not available through Operation *. You have to cast it to a mlir::LLVM::FooOp before getting/setting properties. However, when importing and exporting intrinsics, we all operate on Operation * and thus storing operand bundle tags in properties could introduce a bit trouble in such a case.

Might also be worth summarizing super shortly in the commit message

Updated.

@Lancern
Copy link
Member Author

Lancern commented Oct 16, 2024

Any other comments on this PR?

@gysit
Copy link
Contributor

gysit commented Oct 16, 2024

Looks good from my side! I believe you have now commit access? So feel free to land.

@Lancern
Copy link
Member Author

Lancern commented Oct 16, 2024

Great, I'll merge now.

@Lancern Lancern merged commit d8fadad into llvm:main Oct 16, 2024
8 checks passed
@Lancern Lancern deleted the mlir-llvm-assume-opbundle branch October 16, 2024 04:52
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 16, 2024

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

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

Here is the relevant piece of the build log for the reference
Step 5 (build-check-mlir-build-only) failure: build (failure)
...
33.327 [172/83/3825] Building CXX object tools/mlir/lib/Conversion/MathToROCDL/CMakeFiles/obj.MLIRMathToROCDL.dir/MathToROCDL.cpp.o
33.585 [172/82/3826] Building CXX object tools/mlir/lib/Conversion/GPUCommon/CMakeFiles/obj.MLIRGPUToGPURuntimeTransforms.dir/GPUOpsLowering.cpp.o
33.679 [172/81/3827] Building CXX object tools/mlir/lib/Target/LLVMIR/Dialect/GPU/CMakeFiles/obj.MLIRGPUToLLVMIRTranslation.dir/SelectObjectAttr.cpp.o
33.727 [172/80/3828] Building CXX object tools/mlir/lib/Conversion/SCFToControlFlow/CMakeFiles/obj.MLIRSCFToControlFlow.dir/SCFToControlFlow.cpp.o
33.898 [172/79/3829] Building CXX object tools/mlir/test/lib/Conversion/MathToVCIX/CMakeFiles/MLIRTestMathToVCIX.dir/TestMathToVCIXConversion.cpp.o
34.225 [172/78/3830] Building CXX object tools/mlir/test/lib/Conversion/FuncToLLVM/CMakeFiles/MLIRTestFuncToLLVM.dir/TestConvertFuncOp.cpp.o
34.275 [172/77/3831] Building CXX object tools/mlir/lib/ExecutionEngine/CMakeFiles/MLIRExecutionEngine.dir/ExecutionEngine.cpp.o
35.006 [172/76/3832] Building CXX object tools/mlir/test/lib/Dialect/LLVM/CMakeFiles/MLIRLLVMTestPasses.dir/TestLowerToLLVM.cpp.o
35.036 [172/75/3833] Building CXX object tools/mlir/lib/Dialect/SparseTensor/Transforms/CMakeFiles/obj.MLIRSparseTensorTransforms.dir/Utils/SparseTensorIterator.cpp.o
35.394 [172/74/3834] Building CXX object tools/mlir/lib/Target/LLVMIR/CMakeFiles/obj.MLIRTargetLLVMIRExport.dir/ModuleTranslation.cpp.o
FAILED: tools/mlir/lib/Target/LLVMIR/CMakeFiles/obj.MLIRTargetLLVMIRExport.dir/ModuleTranslation.cpp.o 
ccache /home/buildbots/llvm-external-buildbots/clang.16.0.1/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/build/tools/mlir/lib/Target/LLVMIR -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/lib/Target/LLVMIR -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/build/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/llvm/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/build/tools/mlir/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wundef -Werror=mismatched-tags -Werror=global-constructors -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/mlir/lib/Target/LLVMIR/CMakeFiles/obj.MLIRTargetLLVMIRExport.dir/ModuleTranslation.cpp.o -MF tools/mlir/lib/Target/LLVMIR/CMakeFiles/obj.MLIRTargetLLVMIRExport.dir/ModuleTranslation.cpp.o.d -o tools/mlir/lib/Target/LLVMIR/CMakeFiles/obj.MLIRTargetLLVMIRExport.dir/ModuleTranslation.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-mlir-rhel-test/ppc64le-mlir-rhel-clang-build/llvm-project/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:871:14: error: no member named 'reduce' in namespace 'std'
        std::reduce(opBundleSizes.begin(), opBundleSizes.end());
        ~~~~~^
1 error generated.
35.571 [172/73/3835] Building CXX object tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRLLVMDialect.dir/IR/LLVMTypes.cpp.o
35.634 [172/72/3836] Building CXX object tools/mlir/lib/Target/LLVMIR/Dialect/ROCDL/CMakeFiles/obj.MLIRROCDLToLLVMIRTranslation.dir/ROCDLToLLVMIRTranslation.cpp.o
36.342 [172/71/3837] Building CXX object tools/mlir/lib/Target/LLVM/CMakeFiles/obj.MLIRROCDLTarget.dir/ROCDL/Target.cpp.o
36.625 [172/70/3838] Building CXX object tools/mlir/lib/Dialect/SparseTensor/Transforms/CMakeFiles/obj.MLIRSparseTensorTransforms.dir/Utils/CodegenEnv.cpp.o
36.654 [172/69/3839] Building CXX object tools/mlir/lib/Conversion/ArithToLLVM/CMakeFiles/obj.MLIRArithToLLVM.dir/ArithToLLVM.cpp.o
36.687 [172/68/3840] Building CXX object tools/mlir/lib/Conversion/IndexToLLVM/CMakeFiles/obj.MLIRIndexToLLVM.dir/IndexToLLVM.cpp.o
36.890 [172/67/3841] Building CXX object tools/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/CMakeFiles/obj.MLIRLLVMIRToLLVMTranslation.dir/LLVMIRToLLVMTranslation.cpp.o
36.967 [172/66/3842] Building CXX object tools/mlir/lib/ExecutionEngine/CMakeFiles/MLIRJitRunner.dir/JitRunner.cpp.o
36.977 [172/65/3843] Building CXX object tools/mlir/lib/Conversion/SPIRVToLLVM/CMakeFiles/obj.MLIRSPIRVToLLVM.dir/ConvertLaunchFuncToLLVMCalls.cpp.o
37.078 [172/64/3844] Building CXX object tools/mlir/lib/Conversion/GPUToNVVM/CMakeFiles/obj.MLIRGPUToNVVMTransforms.dir/WmmaOpsToNvvm.cpp.o
37.257 [172/63/3845] Building CXX object tools/mlir/lib/Conversion/SCFToOpenMP/CMakeFiles/obj.MLIRSCFToOpenMP.dir/SCFToOpenMP.cpp.o
37.258 [172/62/3846] Building CXX object tools/mlir/lib/Conversion/FuncToLLVM/CMakeFiles/obj.MLIRFuncToLLVM.dir/FuncToLLVM.cpp.o
37.273 [172/61/3847] Building CXX object tools/mlir/lib/Dialect/GPU/CMakeFiles/obj.MLIRGPUTransforms.dir/Transforms/ROCDLAttachTarget.cpp.o
37.354 [172/60/3848] Building CXX object tools/mlir/lib/Conversion/ArithToAMDGPU/CMakeFiles/obj.MLIRArithToAMDGPU.dir/ArithToAMDGPU.cpp.o
37.841 [172/59/3849] Building CXX object tools/mlir/lib/Dialect/SparseTensor/Transforms/CMakeFiles/obj.MLIRSparseTensorTransforms.dir/SparseBufferRewriting.cpp.o
37.912 [172/58/3850] Building CXX object tools/mlir/lib/CAPI/Conversion/CMakeFiles/obj.MLIRCAPIConversion.dir/Passes.cpp.o
37.926 [172/57/3851] Building CXX object tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o
38.140 [172/56/3852] Building CXX object tools/mlir/lib/Dialect/SparseTensor/Transforms/CMakeFiles/obj.MLIRSparseTensorTransforms.dir/SparseIterationToScf.cpp.o
38.146 [172/55/3853] Building CXX object tools/mlir/lib/Conversion/GPUToLLVMSPV/CMakeFiles/obj.MLIRGPUToLLVMSPV.dir/GPUToLLVMSPV.cpp.o
38.404 [172/54/3854] Building CXX object tools/mlir/lib/Target/LLVMIR/Dialect/NVVM/CMakeFiles/obj.MLIRNVVMToLLVMIRTranslation.dir/NVVMToLLVMIRTranslation.cpp.o
38.501 [172/53/3855] Building CXX object tools/mlir/test/lib/Dialect/NVGPU/CMakeFiles/MLIRNVGPUTestPasses.dir/TestNVGPUTransforms.cpp.o
38.509 [172/52/3856] Building CXX object tools/mlir/lib/Dialect/SparseTensor/Transforms/CMakeFiles/obj.MLIRSparseTensorTransforms.dir/Sparsification.cpp.o
38.626 [172/51/3857] Building CXX object tools/mlir/lib/Dialect/SparseTensor/Transforms/CMakeFiles/obj.MLIRSparseTensorTransforms.dir/SparseTensorPasses.cpp.o
38.738 [172/50/3858] Building CXX object tools/mlir/lib/Dialect/SparseTensor/Transforms/CMakeFiles/obj.MLIRSparseTensorTransforms.dir/SparseVectorization.cpp.o
38.845 [172/49/3859] Building CXX object tools/mlir/lib/Conversion/AMDGPUToROCDL/CMakeFiles/obj.MLIRAMDGPUToROCDL.dir/AMDGPUToROCDL.cpp.o
38.890 [172/48/3860] Building CXX object tools/mlir/test/lib/Dialect/Test/CMakeFiles/MLIRTestFromLLVMIRTranslation.dir/TestFromLLVMIRTranslation.cpp.o
38.904 [172/47/3861] Building CXX object tools/mlir/tools/mlir-lsp-server/CMakeFiles/mlir-lsp-server.dir/mlir-lsp-server.cpp.o
38.987 [172/46/3862] Building CXX object tools/mlir/lib/Conversion/LinalgToStandard/CMakeFiles/obj.MLIRLinalgToStandard.dir/LinalgToStandard.cpp.o
39.095 [172/45/3863] Building CXX object tools/mlir/lib/Conversion/MathToFuncs/CMakeFiles/obj.MLIRMathToFuncs.dir/MathToFuncs.cpp.o
39.105 [172/44/3864] Building CXX object tools/mlir/lib/Dialect/SparseTensor/Transforms/CMakeFiles/obj.MLIRSparseTensorTransforms.dir/SparseReinterpretMap.cpp.o
39.213 [172/43/3865] Building CXX object tools/mlir/lib/Dialect/SparseTensor/Transforms/CMakeFiles/obj.MLIRSparseTensorTransforms.dir/Utils/CodegenUtils.cpp.o
39.708 [172/42/3866] Building CXX object tools/mlir/lib/Conversion/AsyncToLLVM/CMakeFiles/obj.MLIRAsyncToLLVM.dir/AsyncToLLVM.cpp.o
40.030 [172/41/3867] Building CXX object tools/mlir/lib/Dialect/SparseTensor/Transforms/CMakeFiles/obj.MLIRSparseTensorTransforms.dir/SparseGPUCodegen.cpp.o

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 16, 2024

LLVM Buildbot has detected a new failure on builder ppc64le-flang-rhel-clang running on ppc64le-flang-rhel-test while building mlir at step 5 "build-unified-tree".

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

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
44.165 [319/177/6105] Building CXX object tools/mlir/lib/Target/LLVMIR/Dialect/AMX/CMakeFiles/obj.MLIRAMXToLLVMIRTranslation.dir/AMXToLLVMIRTranslation.cpp.o
44.170 [319/176/6106] Building CXX object tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/TBAABuilder.cpp.o
44.192 [319/175/6107] Building CXX object tools/flang/lib/Optimizer/Passes/CMakeFiles/flangPasses.dir/Pipelines.cpp.o
44.373 [319/174/6108] Building CXX object tools/mlir/lib/Target/LLVMIR/CMakeFiles/obj.MLIRTargetLLVMIRExport.dir/LoopAnnotationTranslation.cpp.o
44.459 [319/173/6109] Building CXX object tools/mlir/lib/Dialect/X86Vector/Transforms/CMakeFiles/obj.MLIRX86VectorTransforms.dir/LegalizeForLLVMExport.cpp.o
44.835 [319/172/6110] Building CXX object tools/mlir/lib/Conversion/LLVMCommon/CMakeFiles/obj.MLIRLLVMCommonConversion.dir/TypeConverter.cpp.o
44.956 [319/171/6111] Building CXX object tools/mlir/lib/Dialect/AMX/Transforms/CMakeFiles/obj.MLIRAMXTransforms.dir/LegalizeForLLVMExport.cpp.o
45.025 [319/170/6112] Building CXX object tools/mlir/test/lib/Conversion/MathToVCIX/CMakeFiles/MLIRTestMathToVCIX.dir/TestMathToVCIXConversion.cpp.o
45.141 [319/169/6113] Building CXX object tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/TypeConverter.cpp.o
45.270 [319/168/6114] Building CXX object tools/mlir/lib/Target/LLVMIR/CMakeFiles/obj.MLIRTargetLLVMIRExport.dir/ModuleTranslation.cpp.o
FAILED: tools/mlir/lib/Target/LLVMIR/CMakeFiles/obj.MLIRTargetLLVMIRExport.dir/ModuleTranslation.cpp.o 
ccache /home/buildbots/llvm-external-buildbots/clang.16.0.1/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/mlir/lib/Target/LLVMIR -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/mlir/lib/Target/LLVMIR -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/mlir/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/mlir/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wundef -Werror=mismatched-tags -Werror=global-constructors -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/mlir/lib/Target/LLVMIR/CMakeFiles/obj.MLIRTargetLLVMIRExport.dir/ModuleTranslation.cpp.o -MF tools/mlir/lib/Target/LLVMIR/CMakeFiles/obj.MLIRTargetLLVMIRExport.dir/ModuleTranslation.cpp.o.d -o tools/mlir/lib/Target/LLVMIR/CMakeFiles/obj.MLIRTargetLLVMIRExport.dir/ModuleTranslation.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp:871:14: error: no member named 'reduce' in namespace 'std'
        std::reduce(opBundleSizes.begin(), opBundleSizes.end());
        ~~~~~^
1 error generated.
45.385 [319/167/6115] Building CXX object tools/mlir/lib/Dialect/X86Vector/Transforms/CMakeFiles/obj.MLIRX86VectorTransforms.dir/AVXTranspose.cpp.o
45.513 [319/166/6116] Building CXX object tools/mlir/lib/Conversion/ControlFlowToSCF/CMakeFiles/obj.MLIRControlFlowToSCF.dir/ControlFlowToSCF.cpp.o
45.527 [319/165/6117] Building CXX object tools/mlir/lib/Target/LLVMIR/Dialect/OpenACC/CMakeFiles/obj.MLIROpenACCToLLVMIRTranslation.dir/OpenACCToLLVMIRTranslation.cpp.o
45.616 [319/164/6118] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/ControlFlowConverter.cpp.o
45.736 [319/163/6119] Building CXX object tools/mlir/lib/Target/LLVMIR/Dialect/ROCDL/CMakeFiles/obj.MLIRROCDLToLLVMIRTranslation.dir/ROCDLToLLVMIRTranslation.cpp.o
45.744 [319/162/6120] Building CXX object tools/mlir/lib/Conversion/ConvertToLLVM/CMakeFiles/obj.MLIRConvertToLLVMPass.dir/ConvertToLLVMPass.cpp.o
45.844 [319/161/6121] Building CXX object tools/mlir/lib/Conversion/ControlFlowToLLVM/CMakeFiles/obj.MLIRControlFlowToLLVM.dir/ControlFlowToLLVM.cpp.o
45.859 [319/160/6122] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/CUFAddConstructor.cpp.o
46.209 [319/159/6123] Building CXX object lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/AsmPrinter.cpp.o
46.248 [319/158/6124] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/CompilerGeneratedNames.cpp.o
46.356 [319/157/6125] Building CXX object tools/mlir/lib/Conversion/MathToLLVM/CMakeFiles/obj.MLIRMathToLLVM.dir/MathToLLVM.cpp.o
46.386 [319/156/6126] Building CXX object tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRLLVMDialect.dir/IR/LLVMMemorySlot.cpp.o
46.451 [319/155/6127] Building CXX object tools/mlir/lib/Conversion/SPIRVToLLVM/CMakeFiles/obj.MLIRSPIRVToLLVM.dir/SPIRVToLLVMPass.cpp.o
46.548 [319/154/6128] Building CXX object tools/mlir/lib/Conversion/VectorToLLVM/CMakeFiles/obj.MLIRVectorToLLVMPass.dir/ConvertVectorToLLVMPass.cpp.o
46.577 [319/153/6129] Building CXX object tools/mlir/lib/Dialect/LLVMIR/CMakeFiles/obj.MLIRLLVMDialect.dir/IR/LLVMInterfaces.cpp.o
46.580 [319/152/6130] Building CXX object tools/flang/lib/Optimizer/OpenMP/CMakeFiles/FlangOpenMPTransforms.dir/MarkDeclareTarget.cpp.o
46.605 [319/151/6131] Building CXX object tools/mlir/lib/Target/LLVMIR/Dialect/X86Vector/CMakeFiles/obj.MLIRX86VectorToLLVMIRTranslation.dir/X86VectorToLLVMIRTranslation.cpp.o
46.722 [319/150/6132] Building CXX object tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGenOpenMP.cpp.o
47.055 [319/149/6133] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/AssumedRankOpConversion.cpp.o
47.135 [319/148/6134] Building CXX object tools/mlir/lib/Dialect/SparseTensor/Transforms/CMakeFiles/obj.MLIRSparseTensorTransforms.dir/SparsificationAndBufferizationPass.cpp.o
47.136 [319/147/6135] Building CXX object tools/mlir/test/lib/Dialect/NVGPU/CMakeFiles/MLIRNVGPUTestPasses.dir/TestNVGPUTransforms.cpp.o
47.195 [319/146/6136] Building CXX object tools/mlir/lib/Conversion/MathToFuncs/CMakeFiles/obj.MLIRMathToFuncs.dir/MathToFuncs.cpp.o
47.236 [319/145/6137] Building CXX object tools/flang/lib/Optimizer/Transforms/CMakeFiles/FIRTransforms.dir/SimplifyRegionLite.cpp.o
47.388 [319/144/6138] Building CXX object tools/mlir/lib/Dialect/SparseTensor/Transforms/CMakeFiles/obj.MLIRSparseTensorTransforms.dir/Utils/SparseTensorDescriptor.cpp.o
47.441 [319/143/6139] Building CXX object tools/mlir/lib/Conversion/ArithToAMDGPU/CMakeFiles/obj.MLIRArithToAMDGPU.dir/ArithToAMDGPU.cpp.o
47.450 [319/142/6140] Building CXX object tools/mlir/lib/Target/LLVM/CMakeFiles/obj.MLIRTargetLLVM.dir/ModuleToObject.cpp.o
47.509 [319/141/6141] Building CXX object tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/FIROpPatterns.cpp.o
47.552 [319/140/6142] Building CXX object tools/mlir/lib/Dialect/SparseTensor/Transforms/CMakeFiles/obj.MLIRSparseTensorTransforms.dir/SparseIterationToScf.cpp.o
47.571 [319/139/6143] Building CXX object tools/mlir/lib/Dialect/NVGPU/Utils/CMakeFiles/obj.MLIRNVGPUUtils.dir/MMAUtils.cpp.o
47.749 [319/138/6144] Building CXX object tools/mlir/lib/Target/LLVM/CMakeFiles/obj.MLIRROCDLTarget.dir/ROCDL/Utils.cpp.o
47.895 [319/137/6145] Building CXX object tools/mlir/lib/CAPI/Conversion/CMakeFiles/obj.MLIRCAPIConversion.dir/Passes.cpp.o
47.923 [319/136/6146] Building CXX object tools/mlir/test/lib/Dialect/Test/CMakeFiles/MLIRTestFromLLVMIRTranslation.dir/TestFromLLVMIRTranslation.cpp.o
47.976 [319/135/6147] Building CXX object lib/LTO/CMakeFiles/LLVMLTO.dir/LTO.cpp.o

@Lancern
Copy link
Member Author

Lancern commented Oct 16, 2024

Sorry but I'm not very familiar with how we deal with CI failures. Should I revert the patch and reland it after fixing? Or I just push another patch to fix it?

@gysit
Copy link
Contributor

gysit commented Oct 16, 2024

Yes the correct way is to revert the commit briefly mentioning the failure in the commit message (maybe just put a link to the build bot). And then reland later.

Lancern added a commit that referenced this pull request Oct 16, 2024
@Lancern
Copy link
Member Author

Lancern commented Oct 16, 2024

Reverted, will reland later after fixing the build error.

@gysit
Copy link
Contributor

gysit commented Oct 16, 2024

I guess you have to replace std::reduce since this is apparently not supported on power pc. std::accumulate seems to have uses in llvm so I supposes this maybe the way to go.

When you reland the PR it makes sense to add the commit hash of the original commit and of the revert commit to the commit message for transparency.

bricknerb pushed a commit to bricknerb/llvm-project that referenced this pull request Oct 16, 2024
…112143)

This patch adds operand bundle support for `llvm.intr.assume`.

This patch actually contains two parts:

- `llvm.intr.assume` now accepts operand bundle related attributes and
operands. `llvm.intr.assume` does not take constraint on the operand
bundles, but obviously only a few set of operand bundles are meaningful.
I plan to add some of those (e.g. `aligned` and `separate_storage` are
what interest me but other people may be interested in other operand
bundles as well) in future patches.

- The definitions of `llvm.call`, `llvm.invoke`, and
`llvm.call_intrinsic` actually define `op_bundle_tags` as an operation
property. It turns out this approach would introduce some unnecessary
burden if applied equally to the intrinsic operations because properties
are not available through `Operation *` but we have to operate on
`Operation *` during the import/export of intrinsics, so this PR changes
it from a property to an array attribute.
bricknerb pushed a commit to bricknerb/llvm-project that referenced this pull request Oct 16, 2024
Lancern added a commit that referenced this pull request Oct 16, 2024
This patch adds operand bundle support for `llvm.intr.assume`.

This patch actually contains two parts:

- `llvm.intr.assume` now accepts operand bundle related attributes and
operands. `llvm.intr.assume` does not take constraint on the operand
bundles, but obviously only a few set of operand bundles are meaningful.
I plan to add some of those (e.g. `aligned` and `separate_storage` are
what interest me but other people may be interested in other operand
bundles as well) in future patches.

- The definitions of `llvm.call`, `llvm.invoke`, and
`llvm.call_intrinsic` actually define `op_bundle_tags` as an operation
property. It turns out this approach would introduce some unnecessary
burden if applied equally to the intrinsic operations because properties
are not available through `Operation *` but we have to operate on
`Operation *` during the import/export of intrinsics, so this PR changes
it from a property to an array attribute.

This patch relands commit d8fadad.
@Lancern
Copy link
Member Author

Lancern commented Oct 16, 2024

Just re-landed. Let's see if CI build could pass now.

@Lancern
Copy link
Member Author

Lancern commented Oct 16, 2024

Let's see if CI build could pass now.

It passed.

bricknerb pushed a commit to bricknerb/llvm-project that referenced this pull request Oct 17, 2024
…112143)

This patch adds operand bundle support for `llvm.intr.assume`.

This patch actually contains two parts:

- `llvm.intr.assume` now accepts operand bundle related attributes and
operands. `llvm.intr.assume` does not take constraint on the operand
bundles, but obviously only a few set of operand bundles are meaningful.
I plan to add some of those (e.g. `aligned` and `separate_storage` are
what interest me but other people may be interested in other operand
bundles as well) in future patches.

- The definitions of `llvm.call`, `llvm.invoke`, and
`llvm.call_intrinsic` actually define `op_bundle_tags` as an operation
property. It turns out this approach would introduce some unnecessary
burden if applied equally to the intrinsic operations because properties
are not available through `Operation *` but we have to operate on
`Operation *` during the import/export of intrinsics, so this PR changes
it from a property to an array attribute.
bricknerb pushed a commit to bricknerb/llvm-project that referenced this pull request Oct 17, 2024
bricknerb pushed a commit to bricknerb/llvm-project that referenced this pull request Oct 17, 2024
…112143)

This patch adds operand bundle support for `llvm.intr.assume`.

This patch actually contains two parts:

- `llvm.intr.assume` now accepts operand bundle related attributes and
operands. `llvm.intr.assume` does not take constraint on the operand
bundles, but obviously only a few set of operand bundles are meaningful.
I plan to add some of those (e.g. `aligned` and `separate_storage` are
what interest me but other people may be interested in other operand
bundles as well) in future patches.

- The definitions of `llvm.call`, `llvm.invoke`, and
`llvm.call_intrinsic` actually define `op_bundle_tags` as an operation
property. It turns out this approach would introduce some unnecessary
burden if applied equally to the intrinsic operations because properties
are not available through `Operation *` but we have to operate on
`Operation *` during the import/export of intrinsics, so this PR changes
it from a property to an array attribute.

This patch relands commit d8fadad.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants