Skip to content

[mlir][func]: Introduce ReplaceFuncSignature tranform operation #143381

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

Merged
merged 1 commit into from
Jun 24, 2025

Conversation

AviadCo
Copy link
Contributor

@AviadCo AviadCo commented Jun 9, 2025

This transform takes a module and a function name, and replaces the signature of the function by reordering the arguments and results according to the interchange arrays. The function is expected to be defined in the module, and the interchange arrays must match the number of arguments and results of the function.

@llvmbot
Copy link
Member

llvmbot commented Jun 9, 2025

@llvm/pr-subscribers-mlir-linalg

@llvm/pr-subscribers-mlir-func

Author: Aviad Cohen (AviadCo)

Changes

This transform takes a module and a function name, and replaces the signature of the function by reordering the arguments and results according to the interchange arrays. The function is expected to be defined in the module, and the interchange arrays must match the number of arguments and results of the function.


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

8 Files Affected:

  • (modified) mlir/include/mlir/Dialect/Func/TransformOps/FuncTransformOps.td (+37)
  • (added) mlir/include/mlir/Dialect/Func/Utils/Utils.h (+42)
  • (modified) mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td (+2-2)
  • (modified) mlir/lib/Dialect/Func/CMakeLists.txt (+1)
  • (modified) mlir/lib/Dialect/Func/TransformOps/FuncTransformOps.cpp (+93)
  • (added) mlir/lib/Dialect/Func/Utils/CMakeLists.txt (+13)
  • (added) mlir/lib/Dialect/Func/Utils/Utils.cpp (+103)
  • (modified) mlir/test/Dialect/Func/func-transform.mlir (+132)
diff --git a/mlir/include/mlir/Dialect/Func/TransformOps/FuncTransformOps.td b/mlir/include/mlir/Dialect/Func/TransformOps/FuncTransformOps.td
index 306fbf881de61..1cb9ca7418057 100644
--- a/mlir/include/mlir/Dialect/Func/TransformOps/FuncTransformOps.td
+++ b/mlir/include/mlir/Dialect/Func/TransformOps/FuncTransformOps.td
@@ -98,4 +98,41 @@ def CastAndCallOp : Op<Transform_Dialect,
   let hasVerifier = 1;
 }
 
+def ReplaceFuncSignatureOp : Op<Transform_Dialect,
+    "func.replace_func_signature",
+    [DeclareOpInterfaceMethods<TransformOpInterface>,
+     DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+  let description = [{
+      This transform takes a module and a function name, and replaces the
+      signature of the function by reordering the arguments and results
+      according to the interchange arrays. The function is expected to be
+      defined in the module, and the interchange arrays must match the number
+      of arguments and results of the function.
+
+      The `adjust_func_calls` attribute indicates whether the function calls
+      should be adjusted to match the new signature. If set to `true`, the
+      function calls will be adjusted to match the new signature, otherwise
+      they will not be adjusted.
+
+      This transform will emit a silenceable failure if:
+       - The function with the given name does not exist in the module.
+       - The interchange arrays do not match the number of arguments/results.
+       - The interchange arrays contain out of bound indices.
+  }];
+
+  let arguments = (ins TransformHandleTypeInterface:$module,
+                       SymbolRefAttr:$function_name,
+                       DenseI32ArrayAttr:$args_interchange,
+                       DenseI32ArrayAttr:$results_interchange,
+                       UnitAttr:$adjust_func_calls);
+  let results = (outs );
+
+  let assemblyFormat = [{
+    $function_name
+    `args_interchange` `=` $args_interchange
+    `results_interchange` `=` $results_interchange
+    `at` $module attr-dict `:` functional-type(operands, results)
+  }];
+}
+
 #endif // FUNC_TRANSFORM_OPS
diff --git a/mlir/include/mlir/Dialect/Func/Utils/Utils.h b/mlir/include/mlir/Dialect/Func/Utils/Utils.h
new file mode 100644
index 0000000000000..ff0746f55a96f
--- /dev/null
+++ b/mlir/include/mlir/Dialect/Func/Utils/Utils.h
@@ -0,0 +1,42 @@
+//===- Utils.h - General Func transformation utilities ----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This header file defines prototypes for various transformation utilities for
+// the Func dialect. These are not passes by themselves but are used
+// either by passes, optimization sequences, or in turn by other transformation
+// utilities.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_DIALECT_FUNC_UTILS_H
+#define MLIR_DIALECT_FUNC_UTILS_H
+
+#include "mlir/Dialect/Func/IR/FuncOps.h"
+
+namespace mlir {
+
+namespace func {
+
+// Creates a new function operation with the same name as the original
+// function operation, but with the arguments reordered according to
+// the `newArgsOrder` and `newResultsOrder`.
+mlir::func::FuncOp replaceFuncWithNewOrder(mlir::func::FuncOp funcOp,
+                                           mlir::ArrayRef<int> newArgsOrder,
+                                           mlir::ArrayRef<int> newResultsOrder);
+// Creates a new call operation with the values as the original
+// call operation, but with the arguments reordered according to
+// the `newArgsOrder` and `newResultsOrder`.
+mlir::func::CallOp
+replaceCallOpWithNewOrder(mlir::func::CallOp callOp,
+                          mlir::ArrayRef<int> newArgsOrder,
+                          mlir::ArrayRef<int> newResultsOrder);
+
+} // namespace func
+} // namespace mlir
+
+#endif // MLIR_DIALECT_FUNC_UTILS_H
diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
index 15ea5e7bf7159..c5b657aefc0e3 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -366,8 +366,8 @@ def FuseOp : Op<Transform_Dialect, "structured.fuse",
 
   let arguments =
     (ins TransformHandleTypeInterface:$target,
-         DefaultValuedAttr<I64ArrayAttr, "{}">:$tile_sizes,
-         DefaultValuedAttr<I64ArrayAttr, "{}">:$tile_interchange,
+        DefaultValuedAttr<I64ArrayAttr, "{}">:$tile_sizes,
+        DefaultValuedAttr<I64ArrayAttr, "{}">:$tile_interchange,
          DefaultValuedAttr<BoolAttr, "false">:$apply_cleanup);
   let results = (outs TransformHandleTypeInterface:$transformed,
                       Variadic<TransformHandleTypeInterface>:$loops);
diff --git a/mlir/lib/Dialect/Func/CMakeLists.txt b/mlir/lib/Dialect/Func/CMakeLists.txt
index ec999ffdb99da..a834aae8fbf81 100644
--- a/mlir/lib/Dialect/Func/CMakeLists.txt
+++ b/mlir/lib/Dialect/Func/CMakeLists.txt
@@ -2,3 +2,4 @@ add_subdirectory(Extensions)
 add_subdirectory(IR)
 add_subdirectory(Transforms)
 add_subdirectory(TransformOps)
+add_subdirectory(Utils)
diff --git a/mlir/lib/Dialect/Func/TransformOps/FuncTransformOps.cpp b/mlir/lib/Dialect/Func/TransformOps/FuncTransformOps.cpp
index 9966d7339e1b4..0a814f7cfdd13 100644
--- a/mlir/lib/Dialect/Func/TransformOps/FuncTransformOps.cpp
+++ b/mlir/lib/Dialect/Func/TransformOps/FuncTransformOps.cpp
@@ -11,6 +11,7 @@
 #include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVM.h"
 #include "mlir/Conversion/LLVMCommon/TypeConverter.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
+#include "mlir/Dialect/Func/Utils/Utils.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/Dialect/Transform/IR/TransformDialect.h"
 #include "mlir/Dialect/Transform/IR/TransformOps.h"
@@ -226,6 +227,98 @@ void transform::CastAndCallOp::getEffects(
   transform::modifiesPayload(effects);
 }
 
+//===----------------------------------------------------------------------===//
+// ReplaceFuncSignatureOp
+//===----------------------------------------------------------------------===//
+
+DiagnosedSilenceableFailure
+transform::ReplaceFuncSignatureOp::apply(transform::TransformRewriter &rewriter,
+                                         transform::TransformResults &results,
+                                         transform::TransformState &state) {
+  auto payloadOps = state.getPayloadOps(getModule());
+  if (!llvm::hasSingleElement(payloadOps))
+    return emitDefiniteFailure() << "requires a single module to operate on";
+
+  auto targetModuleOp = dyn_cast<ModuleOp>(*payloadOps.begin());
+  if (!targetModuleOp)
+    return emitSilenceableFailure(getLoc())
+           << "target is expected to be module operation";
+
+  func::FuncOp funcOp =
+      targetModuleOp.lookupSymbol<func::FuncOp>(getFunctionName());
+  if (!funcOp)
+    return emitSilenceableFailure(getLoc())
+           << "function with name '" << getFunctionName() << "' not found";
+
+  int numArgs = funcOp.getNumArguments();
+  int numResults = funcOp.getNumResults();
+  // Check that the number of arguments and results matches the
+  // interchange sizes.
+  if (numArgs != (int)getArgsInterchange().size())
+    return emitSilenceableFailure(getLoc())
+           << "function with name '" << getFunctionName() << "' has " << numArgs
+           << " arguments, but " << getArgsInterchange().size()
+           << " args interchange were given";
+
+  if (numResults != (int)getResultsInterchange().size())
+    return emitSilenceableFailure(getLoc())
+           << "function with name '" << getFunctionName() << "' has "
+           << numResults << " results, but " << getResultsInterchange().size()
+           << " results interchange were given";
+
+  // Check that the args and results interchanges are unique.
+  SetVector<int> argsInterchange, resultsInterchange;
+  argsInterchange.insert_range(getArgsInterchange());
+  resultsInterchange.insert_range(getResultsInterchange());
+  if (argsInterchange.size() != getArgsInterchange().size())
+    return emitSilenceableFailure(getLoc())
+           << "args interchange must be unique";
+
+  if (resultsInterchange.size() != getResultsInterchange().size())
+    return emitSilenceableFailure(getLoc())
+           << "results interchange must be unique";
+
+  // Check that the args and results interchange indices are in bounds.
+  for (auto index : argsInterchange) {
+    if (index < 0 || index >= numArgs) {
+      return emitSilenceableFailure(getLoc())
+             << "args interchange index " << index
+             << " is out of bounds for function with name '"
+             << getFunctionName() << "' with " << numArgs << " arguments";
+    }
+  }
+  for (auto index : resultsInterchange) {
+    if (index < 0 || index >= numResults) {
+      return emitSilenceableFailure(getLoc())
+             << "results interchange index " << index
+             << " is out of bounds for function with name '"
+             << getFunctionName() << "' with " << numResults << " results";
+    }
+  }
+
+  func::replaceFuncWithNewOrder(funcOp, argsInterchange.getArrayRef(),
+                                resultsInterchange.getArrayRef());
+  if (getAdjustFuncCalls()) {
+    SmallVector<func::CallOp> callOps;
+    targetModuleOp.walk([&](func::CallOp callOp) {
+      if (callOp.getCallee() == getFunctionName().getRootReference().str())
+        callOps.push_back(callOp);
+    });
+
+    for (auto callOp : callOps)
+      func::replaceCallOpWithNewOrder(callOp, argsInterchange.getArrayRef(),
+                                      resultsInterchange.getArrayRef());
+  }
+
+  return DiagnosedSilenceableFailure::success();
+}
+
+void transform::ReplaceFuncSignatureOp::getEffects(
+    SmallVectorImpl<MemoryEffects::EffectInstance> &effects) {
+  transform::consumesHandle(getModuleMutable(), effects);
+  transform::modifiesPayload(effects);
+}
+
 //===----------------------------------------------------------------------===//
 // Transform op registration
 //===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/Func/Utils/CMakeLists.txt b/mlir/lib/Dialect/Func/Utils/CMakeLists.txt
new file mode 100644
index 0000000000000..e39a8c8c25d03
--- /dev/null
+++ b/mlir/lib/Dialect/Func/Utils/CMakeLists.txt
@@ -0,0 +1,13 @@
+add_mlir_dialect_library(MLIRFuncUtils
+  Utils.cpp
+
+  ADDITIONAL_HEADER_DIRS
+  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Func/Utils
+
+  LINK_LIBS PUBLIC
+  MLIRFuncDialect
+  MLIRComplexDialect
+  MLIRDialect
+  MLIRDialectUtils
+  MLIRIR
+  )
diff --git a/mlir/lib/Dialect/Func/Utils/Utils.cpp b/mlir/lib/Dialect/Func/Utils/Utils.cpp
new file mode 100644
index 0000000000000..3bae13c354b20
--- /dev/null
+++ b/mlir/lib/Dialect/Func/Utils/Utils.cpp
@@ -0,0 +1,103 @@
+//===- Utils.cpp - Utilities to support the Func dialect ----------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements utilities for the Func dialect.
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Dialect/Func/Utils/Utils.h"
+#include "mlir/IR/IRMapping.h"
+#include "mlir/IR/PatternMatch.h"
+
+using namespace mlir;
+
+func::FuncOp func::replaceFuncWithNewOrder(func::FuncOp funcOp,
+                                           ArrayRef<int> newArgsOrder,
+                                           ArrayRef<int> newResultsOrder) {
+  // Generate an empty new function operation with the same name as the
+  // original.
+  assert(funcOp.getNumArguments() == newArgsOrder.size());
+  assert(funcOp.getNumResults() == newResultsOrder.size());
+  auto origInputTypes = funcOp.getFunctionType().getInputs();
+  auto origOutputTypes = funcOp.getFunctionType().getResults();
+  SmallVector<Type> newInputTypes, newOutputTypes;
+  for (unsigned int i = 0; i < origInputTypes.size(); ++i)
+    newInputTypes.push_back(origInputTypes[newArgsOrder[i]]);
+  for (unsigned int i = 0; i < origOutputTypes.size(); ++i)
+    newOutputTypes.push_back(origOutputTypes[newResultsOrder[i]]);
+  IRRewriter rewriter(funcOp);
+  rewriter.setInsertionPoint(funcOp);
+  auto newFuncOp = rewriter.create<func::FuncOp>(
+      funcOp.getLoc(), funcOp.getName(),
+      rewriter.getFunctionType(newInputTypes, newOutputTypes));
+  newFuncOp.addEntryBlock();
+  newFuncOp.setVisibility(funcOp.getVisibility());
+  newFuncOp->setDiscardableAttrs(funcOp->getDiscardableAttrDictionary());
+
+  // Map the arguments of the original function to the new function in
+  // the new order and adjust the attributes accordingly.
+  IRMapping operandMapper;
+  SmallVector<DictionaryAttr> argAttrs, resultAttrs;
+  funcOp.getAllArgAttrs(argAttrs);
+  for (unsigned int i = 0; i < newArgsOrder.size(); ++i) {
+    operandMapper.map(funcOp.getArgument(newArgsOrder[i]),
+                      newFuncOp.getArgument(i));
+    newFuncOp.setArgAttrs(i, argAttrs[newArgsOrder[i]]);
+  }
+  funcOp.getAllResultAttrs(resultAttrs);
+  for (unsigned int i = 0; i < newResultsOrder.size(); ++i)
+    newFuncOp.setResultAttrs(i, resultAttrs[newResultsOrder[i]]);
+
+  // Clone the operations from the original function to the new function.
+  rewriter.setInsertionPointToStart(&newFuncOp.getBody().front());
+  for (Operation &op : funcOp.getOps())
+    rewriter.clone(op, operandMapper);
+
+  // Handle the return operation.
+  auto returnOp = cast<func::ReturnOp>(
+      newFuncOp.getFunctionBody().begin()->getTerminator());
+  SmallVector<Value> newReturnValues;
+  for (unsigned int i = 0; i < newResultsOrder.size(); ++i)
+    newReturnValues.push_back(returnOp.getOperand(newResultsOrder[i]));
+  rewriter.setInsertionPoint(returnOp);
+  auto newReturnOp =
+      rewriter.create<func::ReturnOp>(newFuncOp.getLoc(), newReturnValues);
+  newReturnOp->setDiscardableAttrs(returnOp->getDiscardableAttrDictionary());
+  rewriter.eraseOp(returnOp);
+
+  rewriter.eraseOp(funcOp);
+
+  return newFuncOp;
+}
+
+func::CallOp func::replaceCallOpWithNewOrder(func::CallOp callOp,
+                                             ArrayRef<int> newArgsOrder,
+                                             ArrayRef<int> newResultsOrder) {
+  assert(callOp.getNumOperands() == newArgsOrder.size());
+  assert(callOp.getNumResults() == newResultsOrder.size());
+  IRRewriter rewriter(callOp);
+  SmallVector<Value> newArgsOrderValues;
+  for (auto argIdx : newArgsOrder)
+    newArgsOrderValues.push_back(callOp.getOperand(argIdx));
+  SmallVector<Type> newResultTypes;
+  for (auto resIdx : newResultsOrder)
+    newResultTypes.push_back(callOp.getResult(resIdx).getType());
+
+  // Replace the kernel call operation with a new one that has the
+  // reordered arguments.
+  auto newCallOp = rewriter.create<func::CallOp>(
+      callOp.getLoc(), callOp.getCallee(), newResultTypes, newArgsOrderValues);
+  newCallOp.setNoInlineAttr(callOp.getNoInlineAttr());
+  newCallOp->setDiscardableAttrs(callOp->getDiscardableAttrDictionary());
+  for (auto [newIndex, origIndex] : llvm::enumerate(newResultsOrder))
+    rewriter.replaceAllUsesWith(callOp.getResult(origIndex),
+                                newCallOp.getResult(newIndex));
+  rewriter.eraseOp(callOp);
+
+  return newCallOp;
+}
diff --git a/mlir/test/Dialect/Func/func-transform.mlir b/mlir/test/Dialect/Func/func-transform.mlir
index 6aab07b0cb38a..9cb91055d6143 100644
--- a/mlir/test/Dialect/Func/func-transform.mlir
+++ b/mlir/test/Dialect/Func/func-transform.mlir
@@ -118,3 +118,135 @@ module attributes {transform.with_named_sequence} {
     transform.yield
   }
 }
+
+// -----
+
+module {
+  // CHECK:           func.func private @func_with_reverse_order_no_result_no_calls(%[[ARG0:.*]]: memref<1xi8, 1>, %[[ARG1:.*]]: memref<3xi8, 1>, %[[ARG2:.*]]: memref<2xi8, 1>) {
+  func.func private @func_with_reverse_order_no_result_no_calls(%arg0: memref<1xi8, 1>, %arg1: memref<2xi8, 1>, %arg2: memref<3xi8, 1>) {
+    // CHECK:             %[[C0:.*]] = arith.constant 0 : index
+    %c0 = arith.constant 0 : index
+    // CHECK:             %[[VAL_4:.*]] = memref.view %[[ARG0]]{{\[}}%[[C0]]][] : memref<1xi8, 1> to memref<1xi8, 1>
+    %view = memref.view %arg0[%c0][] : memref<1xi8, 1> to memref<1xi8, 1>
+    // CHECK:             %[[VAL_5:.*]] = memref.view %[[ARG2]]{{\[}}%[[C0]]][] : memref<2xi8, 1> to memref<2xi8, 1>
+    %view0 = memref.view %arg1[%c0][] : memref<2xi8, 1> to memref<2xi8, 1>
+    // CHECK:             %[[VAL_6:.*]] = memref.view %[[ARG1]]{{\[}}%[[C0]]][] : memref<3xi8, 1> to memref<3xi8, 1>
+    %view1 = memref.view %arg2[%c0][] : memref<3xi8, 1> to memref<3xi8, 1>
+    return
+  }
+}
+
+module attributes {transform.with_named_sequence} {
+  transform.named_sequence @__transform_main(%arg0: !transform.any_op {transform.readonly}) {
+    %func = transform.structured.match ops{["func.func"]} in %arg0 : (!transform.any_op) -> !transform.any_op
+    %module = transform.get_parent_op %func : (!transform.any_op) -> !transform.any_op
+    transform.func.replace_func_signature @func_with_reverse_order_no_result_no_calls args_interchange = [0, 2, 1] results_interchange = [] at %module : (!transform.any_op) -> ()
+    transform.yield
+  }
+}
+
+// -----
+
+module {
+  // CHECK:           func.func private @func_with_reverse_order_no_result(%[[ARG0:.*]]: memref<1xi8, 1>, %[[ARG1:.*]]: memref<3xi8, 1>, %[[ARG2:.*]]: memref<2xi8, 1>) {
+  func.func private @func_with_reverse_order_no_result(%arg0: memref<1xi8, 1>, %arg1: memref<2xi8, 1>, %arg2: memref<3xi8, 1>) {
+    // CHECK:             %[[C0:.*]] = arith.constant 0 : index
+    %c0 = arith.constant 0 : index
+    // CHECK:             %[[VAL_4:.*]] = memref.view %[[ARG0]]{{\[}}%[[C0]]][] : memref<1xi8, 1> to memref<1xi8, 1>
+    %view = memref.view %arg0[%c0][] : memref<1xi8, 1> to memref<1xi8, 1>
+    // CHECK:             %[[VAL_5:.*]] = memref.view %[[ARG2]]{{\[}}%[[C0]]][] : memref<2xi8, 1> to memref<2xi8, 1>
+    %view0 = memref.view %arg1[%c0][] : memref<2xi8, 1> to memref<2xi8, 1>
+    // CHECK:             %[[VAL_6:.*]] = memref.view %[[ARG1]]{{\[}}%[[C0]]][] : memref<3xi8, 1> to memref<3xi8, 1>
+    %view1 = memref.view %arg2[%c0][] : memref<3xi8, 1> to memref<3xi8, 1>
+    return
+  }
+
+  // CHECK:           func.func @func_with_reverse_order_no_result_caller(%[[ARG0:.*]]: memref<1xi8, 1>, %[[ARG1:.*]]: memref<2xi8, 1>, %[[ARG2:.*]]: memref<3xi8, 1>) {
+  func.func @func_with_reverse_order_no_result_caller(%arg0: memref<1xi8, 1>, %arg1: memref<2xi8, 1>, %arg2: memref<3xi8, 1>) {
+    // CHECK:             call @func_with_reverse_order_no_result(%[[ARG0]], %[[ARG2]], %[[ARG1]]) : (memref<1xi8, 1>, memref<3xi8, 1>, memref<2xi8, 1>) -> ()
+    call @func_with_reverse_order_no_result(%arg0, %arg1, %arg2) : (memref<1xi8, 1>, memref<2xi8, 1>, memref<3xi8, 1>) -> ()
+    return
+  }
+}
+
+module attributes {transform.with_named_sequence} {
+  transform.named_sequence @__transform_main(%arg0: !transform.any_op {transform.readonly}) {
+    %funcs = transform.structured.match ops{["func.func"]} in %arg0 : (!transform.any_op) -> !transform.any_op
+    %f:2 = transform.split_handle %funcs : (!transform.any_op) -> (!transform.any_op, !transform.any_op)
+    %module = transform.get_parent_op %f#0 : (!transform.any_op) -> !transform.any_op
+    transform.func.replace_func_signature @func_with_reverse_order_no_result args_interchange = [0, 2, 1] results_interchange = [] at %module {adjust_func_calls} : (!transform.any_op) -> ()
+    transform.yield
+  }
+}
+
+// -----
+
+module {
+  // CHECK:           func.func private @func_with_reverse_order(%[[ARG0:.*]]: memref<1xi8, 1>, %[[ARG1:.*]]: memref<3xi8, 1>, %[[ARG2:.*]]: memref<2xi8, 1>) -> (memref<2xi8, 1>, memref<1xi8, 1>) {
+  func.func private @func_with_reverse_order(%arg0: memref<1xi8, 1>, %arg1: memref<2xi8, 1>, %arg2: memref<3xi8, 1>) -> (memref<1xi8, 1>, memref<2xi8, 1>) {
+    // CHECK:             %[[C0:.*]] = arith.constant 0 : inde...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Jun 9, 2025

@llvm/pr-subscribers-mlir

Author: Aviad Cohen (AviadCo)

Changes

This transform takes a module and a function name, and replaces the signature of the function by reordering the arguments and results according to the interchange arrays. The function is expected to be defined in the module, and the interchange arrays must match the number of arguments and results of the function.


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

8 Files Affected:

  • (modified) mlir/include/mlir/Dialect/Func/TransformOps/FuncTransformOps.td (+37)
  • (added) mlir/include/mlir/Dialect/Func/Utils/Utils.h (+42)
  • (modified) mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td (+2-2)
  • (modified) mlir/lib/Dialect/Func/CMakeLists.txt (+1)
  • (modified) mlir/lib/Dialect/Func/TransformOps/FuncTransformOps.cpp (+93)
  • (added) mlir/lib/Dialect/Func/Utils/CMakeLists.txt (+13)
  • (added) mlir/lib/Dialect/Func/Utils/Utils.cpp (+103)
  • (modified) mlir/test/Dialect/Func/func-transform.mlir (+132)
diff --git a/mlir/include/mlir/Dialect/Func/TransformOps/FuncTransformOps.td b/mlir/include/mlir/Dialect/Func/TransformOps/FuncTransformOps.td
index 306fbf881de61..1cb9ca7418057 100644
--- a/mlir/include/mlir/Dialect/Func/TransformOps/FuncTransformOps.td
+++ b/mlir/include/mlir/Dialect/Func/TransformOps/FuncTransformOps.td
@@ -98,4 +98,41 @@ def CastAndCallOp : Op<Transform_Dialect,
   let hasVerifier = 1;
 }
 
+def ReplaceFuncSignatureOp : Op<Transform_Dialect,
+    "func.replace_func_signature",
+    [DeclareOpInterfaceMethods<TransformOpInterface>,
+     DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
+  let description = [{
+      This transform takes a module and a function name, and replaces the
+      signature of the function by reordering the arguments and results
+      according to the interchange arrays. The function is expected to be
+      defined in the module, and the interchange arrays must match the number
+      of arguments and results of the function.
+
+      The `adjust_func_calls` attribute indicates whether the function calls
+      should be adjusted to match the new signature. If set to `true`, the
+      function calls will be adjusted to match the new signature, otherwise
+      they will not be adjusted.
+
+      This transform will emit a silenceable failure if:
+       - The function with the given name does not exist in the module.
+       - The interchange arrays do not match the number of arguments/results.
+       - The interchange arrays contain out of bound indices.
+  }];
+
+  let arguments = (ins TransformHandleTypeInterface:$module,
+                       SymbolRefAttr:$function_name,
+                       DenseI32ArrayAttr:$args_interchange,
+                       DenseI32ArrayAttr:$results_interchange,
+                       UnitAttr:$adjust_func_calls);
+  let results = (outs );
+
+  let assemblyFormat = [{
+    $function_name
+    `args_interchange` `=` $args_interchange
+    `results_interchange` `=` $results_interchange
+    `at` $module attr-dict `:` functional-type(operands, results)
+  }];
+}
+
 #endif // FUNC_TRANSFORM_OPS
diff --git a/mlir/include/mlir/Dialect/Func/Utils/Utils.h b/mlir/include/mlir/Dialect/Func/Utils/Utils.h
new file mode 100644
index 0000000000000..ff0746f55a96f
--- /dev/null
+++ b/mlir/include/mlir/Dialect/Func/Utils/Utils.h
@@ -0,0 +1,42 @@
+//===- Utils.h - General Func transformation utilities ----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This header file defines prototypes for various transformation utilities for
+// the Func dialect. These are not passes by themselves but are used
+// either by passes, optimization sequences, or in turn by other transformation
+// utilities.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_DIALECT_FUNC_UTILS_H
+#define MLIR_DIALECT_FUNC_UTILS_H
+
+#include "mlir/Dialect/Func/IR/FuncOps.h"
+
+namespace mlir {
+
+namespace func {
+
+// Creates a new function operation with the same name as the original
+// function operation, but with the arguments reordered according to
+// the `newArgsOrder` and `newResultsOrder`.
+mlir::func::FuncOp replaceFuncWithNewOrder(mlir::func::FuncOp funcOp,
+                                           mlir::ArrayRef<int> newArgsOrder,
+                                           mlir::ArrayRef<int> newResultsOrder);
+// Creates a new call operation with the values as the original
+// call operation, but with the arguments reordered according to
+// the `newArgsOrder` and `newResultsOrder`.
+mlir::func::CallOp
+replaceCallOpWithNewOrder(mlir::func::CallOp callOp,
+                          mlir::ArrayRef<int> newArgsOrder,
+                          mlir::ArrayRef<int> newResultsOrder);
+
+} // namespace func
+} // namespace mlir
+
+#endif // MLIR_DIALECT_FUNC_UTILS_H
diff --git a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
index 15ea5e7bf7159..c5b657aefc0e3 100644
--- a/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
+++ b/mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
@@ -366,8 +366,8 @@ def FuseOp : Op<Transform_Dialect, "structured.fuse",
 
   let arguments =
     (ins TransformHandleTypeInterface:$target,
-         DefaultValuedAttr<I64ArrayAttr, "{}">:$tile_sizes,
-         DefaultValuedAttr<I64ArrayAttr, "{}">:$tile_interchange,
+        DefaultValuedAttr<I64ArrayAttr, "{}">:$tile_sizes,
+        DefaultValuedAttr<I64ArrayAttr, "{}">:$tile_interchange,
          DefaultValuedAttr<BoolAttr, "false">:$apply_cleanup);
   let results = (outs TransformHandleTypeInterface:$transformed,
                       Variadic<TransformHandleTypeInterface>:$loops);
diff --git a/mlir/lib/Dialect/Func/CMakeLists.txt b/mlir/lib/Dialect/Func/CMakeLists.txt
index ec999ffdb99da..a834aae8fbf81 100644
--- a/mlir/lib/Dialect/Func/CMakeLists.txt
+++ b/mlir/lib/Dialect/Func/CMakeLists.txt
@@ -2,3 +2,4 @@ add_subdirectory(Extensions)
 add_subdirectory(IR)
 add_subdirectory(Transforms)
 add_subdirectory(TransformOps)
+add_subdirectory(Utils)
diff --git a/mlir/lib/Dialect/Func/TransformOps/FuncTransformOps.cpp b/mlir/lib/Dialect/Func/TransformOps/FuncTransformOps.cpp
index 9966d7339e1b4..0a814f7cfdd13 100644
--- a/mlir/lib/Dialect/Func/TransformOps/FuncTransformOps.cpp
+++ b/mlir/lib/Dialect/Func/TransformOps/FuncTransformOps.cpp
@@ -11,6 +11,7 @@
 #include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVM.h"
 #include "mlir/Conversion/LLVMCommon/TypeConverter.h"
 #include "mlir/Dialect/Func/IR/FuncOps.h"
+#include "mlir/Dialect/Func/Utils/Utils.h"
 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
 #include "mlir/Dialect/Transform/IR/TransformDialect.h"
 #include "mlir/Dialect/Transform/IR/TransformOps.h"
@@ -226,6 +227,98 @@ void transform::CastAndCallOp::getEffects(
   transform::modifiesPayload(effects);
 }
 
+//===----------------------------------------------------------------------===//
+// ReplaceFuncSignatureOp
+//===----------------------------------------------------------------------===//
+
+DiagnosedSilenceableFailure
+transform::ReplaceFuncSignatureOp::apply(transform::TransformRewriter &rewriter,
+                                         transform::TransformResults &results,
+                                         transform::TransformState &state) {
+  auto payloadOps = state.getPayloadOps(getModule());
+  if (!llvm::hasSingleElement(payloadOps))
+    return emitDefiniteFailure() << "requires a single module to operate on";
+
+  auto targetModuleOp = dyn_cast<ModuleOp>(*payloadOps.begin());
+  if (!targetModuleOp)
+    return emitSilenceableFailure(getLoc())
+           << "target is expected to be module operation";
+
+  func::FuncOp funcOp =
+      targetModuleOp.lookupSymbol<func::FuncOp>(getFunctionName());
+  if (!funcOp)
+    return emitSilenceableFailure(getLoc())
+           << "function with name '" << getFunctionName() << "' not found";
+
+  int numArgs = funcOp.getNumArguments();
+  int numResults = funcOp.getNumResults();
+  // Check that the number of arguments and results matches the
+  // interchange sizes.
+  if (numArgs != (int)getArgsInterchange().size())
+    return emitSilenceableFailure(getLoc())
+           << "function with name '" << getFunctionName() << "' has " << numArgs
+           << " arguments, but " << getArgsInterchange().size()
+           << " args interchange were given";
+
+  if (numResults != (int)getResultsInterchange().size())
+    return emitSilenceableFailure(getLoc())
+           << "function with name '" << getFunctionName() << "' has "
+           << numResults << " results, but " << getResultsInterchange().size()
+           << " results interchange were given";
+
+  // Check that the args and results interchanges are unique.
+  SetVector<int> argsInterchange, resultsInterchange;
+  argsInterchange.insert_range(getArgsInterchange());
+  resultsInterchange.insert_range(getResultsInterchange());
+  if (argsInterchange.size() != getArgsInterchange().size())
+    return emitSilenceableFailure(getLoc())
+           << "args interchange must be unique";
+
+  if (resultsInterchange.size() != getResultsInterchange().size())
+    return emitSilenceableFailure(getLoc())
+           << "results interchange must be unique";
+
+  // Check that the args and results interchange indices are in bounds.
+  for (auto index : argsInterchange) {
+    if (index < 0 || index >= numArgs) {
+      return emitSilenceableFailure(getLoc())
+             << "args interchange index " << index
+             << " is out of bounds for function with name '"
+             << getFunctionName() << "' with " << numArgs << " arguments";
+    }
+  }
+  for (auto index : resultsInterchange) {
+    if (index < 0 || index >= numResults) {
+      return emitSilenceableFailure(getLoc())
+             << "results interchange index " << index
+             << " is out of bounds for function with name '"
+             << getFunctionName() << "' with " << numResults << " results";
+    }
+  }
+
+  func::replaceFuncWithNewOrder(funcOp, argsInterchange.getArrayRef(),
+                                resultsInterchange.getArrayRef());
+  if (getAdjustFuncCalls()) {
+    SmallVector<func::CallOp> callOps;
+    targetModuleOp.walk([&](func::CallOp callOp) {
+      if (callOp.getCallee() == getFunctionName().getRootReference().str())
+        callOps.push_back(callOp);
+    });
+
+    for (auto callOp : callOps)
+      func::replaceCallOpWithNewOrder(callOp, argsInterchange.getArrayRef(),
+                                      resultsInterchange.getArrayRef());
+  }
+
+  return DiagnosedSilenceableFailure::success();
+}
+
+void transform::ReplaceFuncSignatureOp::getEffects(
+    SmallVectorImpl<MemoryEffects::EffectInstance> &effects) {
+  transform::consumesHandle(getModuleMutable(), effects);
+  transform::modifiesPayload(effects);
+}
+
 //===----------------------------------------------------------------------===//
 // Transform op registration
 //===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/Func/Utils/CMakeLists.txt b/mlir/lib/Dialect/Func/Utils/CMakeLists.txt
new file mode 100644
index 0000000000000..e39a8c8c25d03
--- /dev/null
+++ b/mlir/lib/Dialect/Func/Utils/CMakeLists.txt
@@ -0,0 +1,13 @@
+add_mlir_dialect_library(MLIRFuncUtils
+  Utils.cpp
+
+  ADDITIONAL_HEADER_DIRS
+  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Func/Utils
+
+  LINK_LIBS PUBLIC
+  MLIRFuncDialect
+  MLIRComplexDialect
+  MLIRDialect
+  MLIRDialectUtils
+  MLIRIR
+  )
diff --git a/mlir/lib/Dialect/Func/Utils/Utils.cpp b/mlir/lib/Dialect/Func/Utils/Utils.cpp
new file mode 100644
index 0000000000000..3bae13c354b20
--- /dev/null
+++ b/mlir/lib/Dialect/Func/Utils/Utils.cpp
@@ -0,0 +1,103 @@
+//===- Utils.cpp - Utilities to support the Func dialect ----------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements utilities for the Func dialect.
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Dialect/Func/Utils/Utils.h"
+#include "mlir/IR/IRMapping.h"
+#include "mlir/IR/PatternMatch.h"
+
+using namespace mlir;
+
+func::FuncOp func::replaceFuncWithNewOrder(func::FuncOp funcOp,
+                                           ArrayRef<int> newArgsOrder,
+                                           ArrayRef<int> newResultsOrder) {
+  // Generate an empty new function operation with the same name as the
+  // original.
+  assert(funcOp.getNumArguments() == newArgsOrder.size());
+  assert(funcOp.getNumResults() == newResultsOrder.size());
+  auto origInputTypes = funcOp.getFunctionType().getInputs();
+  auto origOutputTypes = funcOp.getFunctionType().getResults();
+  SmallVector<Type> newInputTypes, newOutputTypes;
+  for (unsigned int i = 0; i < origInputTypes.size(); ++i)
+    newInputTypes.push_back(origInputTypes[newArgsOrder[i]]);
+  for (unsigned int i = 0; i < origOutputTypes.size(); ++i)
+    newOutputTypes.push_back(origOutputTypes[newResultsOrder[i]]);
+  IRRewriter rewriter(funcOp);
+  rewriter.setInsertionPoint(funcOp);
+  auto newFuncOp = rewriter.create<func::FuncOp>(
+      funcOp.getLoc(), funcOp.getName(),
+      rewriter.getFunctionType(newInputTypes, newOutputTypes));
+  newFuncOp.addEntryBlock();
+  newFuncOp.setVisibility(funcOp.getVisibility());
+  newFuncOp->setDiscardableAttrs(funcOp->getDiscardableAttrDictionary());
+
+  // Map the arguments of the original function to the new function in
+  // the new order and adjust the attributes accordingly.
+  IRMapping operandMapper;
+  SmallVector<DictionaryAttr> argAttrs, resultAttrs;
+  funcOp.getAllArgAttrs(argAttrs);
+  for (unsigned int i = 0; i < newArgsOrder.size(); ++i) {
+    operandMapper.map(funcOp.getArgument(newArgsOrder[i]),
+                      newFuncOp.getArgument(i));
+    newFuncOp.setArgAttrs(i, argAttrs[newArgsOrder[i]]);
+  }
+  funcOp.getAllResultAttrs(resultAttrs);
+  for (unsigned int i = 0; i < newResultsOrder.size(); ++i)
+    newFuncOp.setResultAttrs(i, resultAttrs[newResultsOrder[i]]);
+
+  // Clone the operations from the original function to the new function.
+  rewriter.setInsertionPointToStart(&newFuncOp.getBody().front());
+  for (Operation &op : funcOp.getOps())
+    rewriter.clone(op, operandMapper);
+
+  // Handle the return operation.
+  auto returnOp = cast<func::ReturnOp>(
+      newFuncOp.getFunctionBody().begin()->getTerminator());
+  SmallVector<Value> newReturnValues;
+  for (unsigned int i = 0; i < newResultsOrder.size(); ++i)
+    newReturnValues.push_back(returnOp.getOperand(newResultsOrder[i]));
+  rewriter.setInsertionPoint(returnOp);
+  auto newReturnOp =
+      rewriter.create<func::ReturnOp>(newFuncOp.getLoc(), newReturnValues);
+  newReturnOp->setDiscardableAttrs(returnOp->getDiscardableAttrDictionary());
+  rewriter.eraseOp(returnOp);
+
+  rewriter.eraseOp(funcOp);
+
+  return newFuncOp;
+}
+
+func::CallOp func::replaceCallOpWithNewOrder(func::CallOp callOp,
+                                             ArrayRef<int> newArgsOrder,
+                                             ArrayRef<int> newResultsOrder) {
+  assert(callOp.getNumOperands() == newArgsOrder.size());
+  assert(callOp.getNumResults() == newResultsOrder.size());
+  IRRewriter rewriter(callOp);
+  SmallVector<Value> newArgsOrderValues;
+  for (auto argIdx : newArgsOrder)
+    newArgsOrderValues.push_back(callOp.getOperand(argIdx));
+  SmallVector<Type> newResultTypes;
+  for (auto resIdx : newResultsOrder)
+    newResultTypes.push_back(callOp.getResult(resIdx).getType());
+
+  // Replace the kernel call operation with a new one that has the
+  // reordered arguments.
+  auto newCallOp = rewriter.create<func::CallOp>(
+      callOp.getLoc(), callOp.getCallee(), newResultTypes, newArgsOrderValues);
+  newCallOp.setNoInlineAttr(callOp.getNoInlineAttr());
+  newCallOp->setDiscardableAttrs(callOp->getDiscardableAttrDictionary());
+  for (auto [newIndex, origIndex] : llvm::enumerate(newResultsOrder))
+    rewriter.replaceAllUsesWith(callOp.getResult(origIndex),
+                                newCallOp.getResult(newIndex));
+  rewriter.eraseOp(callOp);
+
+  return newCallOp;
+}
diff --git a/mlir/test/Dialect/Func/func-transform.mlir b/mlir/test/Dialect/Func/func-transform.mlir
index 6aab07b0cb38a..9cb91055d6143 100644
--- a/mlir/test/Dialect/Func/func-transform.mlir
+++ b/mlir/test/Dialect/Func/func-transform.mlir
@@ -118,3 +118,135 @@ module attributes {transform.with_named_sequence} {
     transform.yield
   }
 }
+
+// -----
+
+module {
+  // CHECK:           func.func private @func_with_reverse_order_no_result_no_calls(%[[ARG0:.*]]: memref<1xi8, 1>, %[[ARG1:.*]]: memref<3xi8, 1>, %[[ARG2:.*]]: memref<2xi8, 1>) {
+  func.func private @func_with_reverse_order_no_result_no_calls(%arg0: memref<1xi8, 1>, %arg1: memref<2xi8, 1>, %arg2: memref<3xi8, 1>) {
+    // CHECK:             %[[C0:.*]] = arith.constant 0 : index
+    %c0 = arith.constant 0 : index
+    // CHECK:             %[[VAL_4:.*]] = memref.view %[[ARG0]]{{\[}}%[[C0]]][] : memref<1xi8, 1> to memref<1xi8, 1>
+    %view = memref.view %arg0[%c0][] : memref<1xi8, 1> to memref<1xi8, 1>
+    // CHECK:             %[[VAL_5:.*]] = memref.view %[[ARG2]]{{\[}}%[[C0]]][] : memref<2xi8, 1> to memref<2xi8, 1>
+    %view0 = memref.view %arg1[%c0][] : memref<2xi8, 1> to memref<2xi8, 1>
+    // CHECK:             %[[VAL_6:.*]] = memref.view %[[ARG1]]{{\[}}%[[C0]]][] : memref<3xi8, 1> to memref<3xi8, 1>
+    %view1 = memref.view %arg2[%c0][] : memref<3xi8, 1> to memref<3xi8, 1>
+    return
+  }
+}
+
+module attributes {transform.with_named_sequence} {
+  transform.named_sequence @__transform_main(%arg0: !transform.any_op {transform.readonly}) {
+    %func = transform.structured.match ops{["func.func"]} in %arg0 : (!transform.any_op) -> !transform.any_op
+    %module = transform.get_parent_op %func : (!transform.any_op) -> !transform.any_op
+    transform.func.replace_func_signature @func_with_reverse_order_no_result_no_calls args_interchange = [0, 2, 1] results_interchange = [] at %module : (!transform.any_op) -> ()
+    transform.yield
+  }
+}
+
+// -----
+
+module {
+  // CHECK:           func.func private @func_with_reverse_order_no_result(%[[ARG0:.*]]: memref<1xi8, 1>, %[[ARG1:.*]]: memref<3xi8, 1>, %[[ARG2:.*]]: memref<2xi8, 1>) {
+  func.func private @func_with_reverse_order_no_result(%arg0: memref<1xi8, 1>, %arg1: memref<2xi8, 1>, %arg2: memref<3xi8, 1>) {
+    // CHECK:             %[[C0:.*]] = arith.constant 0 : index
+    %c0 = arith.constant 0 : index
+    // CHECK:             %[[VAL_4:.*]] = memref.view %[[ARG0]]{{\[}}%[[C0]]][] : memref<1xi8, 1> to memref<1xi8, 1>
+    %view = memref.view %arg0[%c0][] : memref<1xi8, 1> to memref<1xi8, 1>
+    // CHECK:             %[[VAL_5:.*]] = memref.view %[[ARG2]]{{\[}}%[[C0]]][] : memref<2xi8, 1> to memref<2xi8, 1>
+    %view0 = memref.view %arg1[%c0][] : memref<2xi8, 1> to memref<2xi8, 1>
+    // CHECK:             %[[VAL_6:.*]] = memref.view %[[ARG1]]{{\[}}%[[C0]]][] : memref<3xi8, 1> to memref<3xi8, 1>
+    %view1 = memref.view %arg2[%c0][] : memref<3xi8, 1> to memref<3xi8, 1>
+    return
+  }
+
+  // CHECK:           func.func @func_with_reverse_order_no_result_caller(%[[ARG0:.*]]: memref<1xi8, 1>, %[[ARG1:.*]]: memref<2xi8, 1>, %[[ARG2:.*]]: memref<3xi8, 1>) {
+  func.func @func_with_reverse_order_no_result_caller(%arg0: memref<1xi8, 1>, %arg1: memref<2xi8, 1>, %arg2: memref<3xi8, 1>) {
+    // CHECK:             call @func_with_reverse_order_no_result(%[[ARG0]], %[[ARG2]], %[[ARG1]]) : (memref<1xi8, 1>, memref<3xi8, 1>, memref<2xi8, 1>) -> ()
+    call @func_with_reverse_order_no_result(%arg0, %arg1, %arg2) : (memref<1xi8, 1>, memref<2xi8, 1>, memref<3xi8, 1>) -> ()
+    return
+  }
+}
+
+module attributes {transform.with_named_sequence} {
+  transform.named_sequence @__transform_main(%arg0: !transform.any_op {transform.readonly}) {
+    %funcs = transform.structured.match ops{["func.func"]} in %arg0 : (!transform.any_op) -> !transform.any_op
+    %f:2 = transform.split_handle %funcs : (!transform.any_op) -> (!transform.any_op, !transform.any_op)
+    %module = transform.get_parent_op %f#0 : (!transform.any_op) -> !transform.any_op
+    transform.func.replace_func_signature @func_with_reverse_order_no_result args_interchange = [0, 2, 1] results_interchange = [] at %module {adjust_func_calls} : (!transform.any_op) -> ()
+    transform.yield
+  }
+}
+
+// -----
+
+module {
+  // CHECK:           func.func private @func_with_reverse_order(%[[ARG0:.*]]: memref<1xi8, 1>, %[[ARG1:.*]]: memref<3xi8, 1>, %[[ARG2:.*]]: memref<2xi8, 1>) -> (memref<2xi8, 1>, memref<1xi8, 1>) {
+  func.func private @func_with_reverse_order(%arg0: memref<1xi8, 1>, %arg1: memref<2xi8, 1>, %arg2: memref<3xi8, 1>) -> (memref<1xi8, 1>, memref<2xi8, 1>) {
+    // CHECK:             %[[C0:.*]] = arith.constant 0 : inde...
[truncated]

@AviadCo AviadCo requested a review from qedawkins June 9, 2025 14:02
@AviadCo AviadCo self-assigned this Jun 10, 2025
Copy link
Member

@ftynse ftynse left a comment

Choose a reason for hiding this comment

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

Thank you for the patch!

Please address the comments and consider making this transformation operate on FunctionOpInterface.

@AviadCo
Copy link
Contributor Author

AviadCo commented Jun 14, 2025

Thank you for the patch!

Please address the comments and consider making this transformation operate on FunctionOpInterface.

Thanks for review!
The transform can break the IR if call operation exists in the IR, for this reason I set it to operate on Module and not on a function.

@AviadCo AviadCo force-pushed the func/add-utils branch 2 times, most recently from 9881989 to 144ee52 Compare June 16, 2025 06:48
@ftynse
Copy link
Member

ftynse commented Jun 16, 2025

The transform can break the IR if call operation exists in the IR, for this reason I set it to operate on Module and not on a function.

What I mean is the transformation logic itself, not the transformation operation. It should be applicable to, e.g., LLVM dialect functions as well. There's no reason why it should be specific to the function dialect functions.

This transform takes a module and a function name, and replaces the
signature of the function by reordering the arguments and results
according to the interchange arrays. The function is expected to be
defined in the module, and the interchange arrays must match the number
of arguments and results of the function.
@AviadCo
Copy link
Contributor Author

AviadCo commented Jun 16, 2025

The transform can break the IR if call operation exists in the IR, for this reason I set it to operate on Module and not on a function.

What I mean is the transformation logic itself, not the transformation operation. It should be applicable to, e.g., LLVM dialect functions as well. There's no reason why it should be specific to the function dialect functions.

I see.
I tried but I am not sure how to clone a FunctionOpInterface and also how to handle its' terminator (func::ReturnOp creation)

@AviadCo AviadCo requested a review from ftynse June 18, 2025 10:27
@AviadCo
Copy link
Contributor Author

AviadCo commented Jun 20, 2025

@ftynse I prefer to land it as func transform. If you wanna guide me about to deal with the ReturnOp creation and make the utils function working FunctionOpInterface it is also works for me.

Copy link
Member

@ftynse ftynse left a comment

Choose a reason for hiding this comment

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

Let's land first and iterate afterwards.

I think you might need to add methods to the function interface, in particular to create a return matching the function type. Cloning shouldn't be hard, just RewriterBase::clone should do the trick.

@AviadCo AviadCo merged commit 3ba7a87 into llvm:main Jun 24, 2025
7 checks passed
@AviadCo
Copy link
Contributor Author

AviadCo commented Jun 24, 2025

@ftynse I will try to work on some addition to FunctionOpInterface which will allow to implement this transform in more generic manner

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 24, 2025

LLVM Buildbot has detected a new failure on builder amdgpu-offload-rhel-8-cmake-build-only running on rocm-docker-rhel-8 while building mlir at step 4 "annotate".

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

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: '../llvm-zorg/zorg/buildbot/builders/annotated/amdgpu-offload-cmake.py --jobs=32' (failure)
...
[6473/7874] Building CXX object tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/DiagnosticNames.cpp.o
[6474/7874] Building HLFIRTypes.cpp.inc...
[6475/7874] Building HLFIRTypes.h.inc...
[6476/7874] Building HLFIROps.cpp.inc...
[6477/7874] Building Passes.h.inc...
[6478/7874] Building Passes.h.inc...
[6479/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RetainPtrCtorAdoptChecker.cpp.o
[6480/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/FrontendActions.cpp.o
[6481/7874] Building HLFIROps.h.inc...
[6482/7874] Linking CXX shared library lib/libMLIRFuncTransformOps.so.21.0git
FAILED: lib/libMLIRFuncTransformOps.so.21.0git 
: && /usr/bin/c++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -Wno-misleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Wundef -Wno-unused-but-set-parameter -Wno-deprecated-copy -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libMLIRFuncTransformOps.so.21.0git -o lib/libMLIRFuncTransformOps.so.21.0git tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/build/lib:"  lib/libMLIRFuncToLLVM.so.21.0git  lib/libMLIRTransformDialect.so.21.0git  lib/libMLIRArithToLLVM.so.21.0git  lib/libMLIRArithAttrToLLVMConversion.so.21.0git  lib/libMLIRArithTransforms.so.21.0git  lib/libMLIRBufferizationTransforms.so.21.0git  lib/libMLIRBufferizationDialect.so.21.0git  lib/libMLIRSparseTensorDialect.so.21.0git  lib/libMLIRSCFDialect.so.21.0git  lib/libMLIRFuncTransforms.so.21.0git  lib/libMLIRFuncDialect.so.21.0git  lib/libMLIRShardingInterface.so.21.0git  lib/libMLIRMeshDialect.so.21.0git  lib/libMLIRVectorDialect.so.21.0git  lib/libMLIRTensorDialect.so.21.0git  lib/libMLIRParallelCombiningOpInterface.so.21.0git  lib/libMLIRAffineDialect.so.21.0git  lib/libMLIRMemRefDialect.so.21.0git  lib/libMLIRArithUtils.so.21.0git  lib/libMLIRComplexDialect.so.21.0git  lib/libMLIRMaskableOpInterface.so.21.0git  lib/libMLIRMaskingOpInterface.so.21.0git  lib/libMLIRVectorInterfaces.so.21.0git  lib/libMLIRControlFlowToLLVM.so.21.0git  lib/libMLIRControlFlowDialect.so.21.0git  lib/libMLIRArithDialect.so.21.0git  lib/libMLIRDialect.so.21.0git  lib/libMLIRInferIntRangeCommon.so.21.0git  lib/libMLIRShapedOpInterfaces.so.21.0git  lib/libMLIRLLVMCommonConversion.so.21.0git  lib/libMLIRLLVMDialect.so.21.0git  lib/libLLVMBitWriter.so.21.0git  lib/libLLVMAsmParser.so.21.0git  lib/libLLVMBitReader.so.21.0git  lib/libLLVMCore.so.21.0git  lib/libLLVMBinaryFormat.so.21.0git  lib/libMLIRParser.so.21.0git  lib/libMLIRBytecodeReader.so.21.0git  lib/libMLIRAsmParser.so.21.0git  lib/libMLIRTransformDialectInterfaces.so.21.0git  lib/libMLIRTransforms.so.21.0git  lib/libMLIRTransformUtils.so.21.0git  lib/libMLIRSubsetOpInterface.so.21.0git  lib/libMLIRValueBoundsOpInterface.so.21.0git  lib/libMLIRDestinationStyleOpInterface.so.21.0git  lib/libMLIRMemorySlotInterfaces.so.21.0git  lib/libMLIRRuntimeVerifiableOpInterface.so.21.0git  lib/libMLIRUBDialect.so.21.0git  lib/libMLIRCastInterfaces.so.21.0git  lib/libMLIRRewrite.so.21.0git  lib/libMLIRRewritePDL.so.21.0git  lib/libMLIRPDLToPDLInterp.so.21.0git  lib/libMLIRPass.so.21.0git  lib/libMLIRAnalysis.so.21.0git  lib/libMLIRControlFlowInterfaces.so.21.0git  lib/libMLIRDataLayoutInterfaces.so.21.0git  lib/libMLIRLoopLikeInterface.so.21.0git  lib/libMLIRInferIntRangeInterface.so.21.0git  lib/libMLIRPresburger.so.21.0git  lib/libMLIRPDLInterpDialect.so.21.0git  lib/libMLIRFunctionInterfaces.so.21.0git  lib/libMLIRCallInterfaces.so.21.0git  lib/libMLIRPDLDialect.so.21.0git  lib/libMLIRInferTypeOpInterface.so.21.0git  lib/libMLIRSideEffectInterfaces.so.21.0git  lib/libMLIRTransformDialectUtils.so.21.0git  lib/libMLIRViewLikeInterface.so.21.0git  lib/libMLIRDialectUtils.so.21.0git  lib/libMLIRIR.so.21.0git  lib/libMLIRSupport.so.21.0git  -lpthread  lib/libLLVMSupport.so.21.0git  -Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/build/lib && :
tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o: In function `mlir::transform::ReplaceFuncSignatureOp::apply(mlir::transform::TransformRewriter&, mlir::transform::TransformResults&, mlir::transform::TransformState&) [clone .localalias.42]':
FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0xc99): undefined reference to `mlir::func::replaceFuncWithNewOrder(mlir::RewriterBase&, mlir::func::FuncOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0xd70): undefined reference to `mlir::func::replaceCallOpWithNewOrder(mlir::RewriterBase&, mlir::func::CallOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
collect2: error: ld returned 1 exit status
[6483/7874] Building Options.inc...
[6484/7874] Building CanonicalizationPatterns.inc...
[6485/7874] Linking CXX executable bin/clang-format
[6486/7874] Linking CXX executable bin/offload-arch
[6487/7874] Building CXX object tools/llvm-bcanalyzer/CMakeFiles/llvm-bcanalyzer.dir/llvm-bcanalyzer.cpp.o
[6488/7874] Building CXX object tools/lli/ChildTarget/CMakeFiles/lli-child-target.dir/ChildTarget.cpp.o
[6489/7874] Building CXX object tools/llvm-as/CMakeFiles/llvm-as.dir/llvm-as.cpp.o
[6490/7874] Linking CXX static library lib/libLLVMCFIVerify_static.a
[6491/7874] Building Opts.inc...
[6492/7874] Building CXX object tools/llvm-cat/CMakeFiles/llvm-cat.dir/llvm-cat.cpp.o
[6493/7874] Building CXX object tools/lli/CMakeFiles/lli.dir/lli.cpp.o
[6494/7874] Linking CXX shared library lib/libFortranDecimal.so.21.0git
[6495/7874] Generating VCSVersion.inc
[6496/7874] Linking CXX shared library lib/libNonGTestTesting.so
[6497/7874] Linking CXX shared library lib/libclangTooling.so.21.0git
[6498/7874] Linking CXX shared library lib/libLLVMCFIVerify.so.21.0git
[6499/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/ModelInjector.cpp.o
In file included from /home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/llvm-project/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp:18:
/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/llvm-project/clang/include/clang/Serialization/ASTReader.h:245:16: warning: ‘virtual bool clang::ASTReaderListener::visitInputFile(llvm::StringRef, llvm::StringRef, bool, bool, bool)’ was hidden [-Woverloaded-virtual]
   virtual bool visitInputFile(StringRef FilenameAsRequested, StringRef Filename,
                ^~~~~~~~~~~~~~
/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/llvm-project/clang/include/clang/Serialization/ASTReader.h:306:8: warning:   by ‘virtual bool clang::ChainedASTReaderListener::visitInputFile(llvm::StringRef, bool, bool, bool)’ [-Woverloaded-virtual]
   bool visitInputFile(StringRef Filename, bool isSystem,
        ^~~~~~~~~~~~~~
[6500/7874] Linking CXX shared library lib/libclangIndex.so.21.0git
[6501/7874] Linking CXX executable bin/diagtool
[6502/7874] Building CXX object tools/clang/tools/clang-installapi/CMakeFiles/clang-installapi.dir/Options.cpp.o
[6503/7874] Building CXX object tools/clang/tools/clang-fuzzer/handle-cxx/CMakeFiles/obj.clangHandleCXX.dir/handle_cxx.cpp.o
[6504/7874] Building CXX object tools/clang/tools/clang-diff/CMakeFiles/clang-diff.dir/ClangDiff.cpp.o
[6505/7874] Building CXX object tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o
[6506/7874] Building CXX object tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/CodeCompletion.cpp.o
[6507/7874] Building CXX object tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/IncrementalParser.cpp.o
[6508/7874] Building CXX object tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/ClangRefactor.cpp.o
Step 7 (build cmake config) failure: build cmake config (failure)
...
[6473/7874] Building CXX object tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/DiagnosticNames.cpp.o
[6474/7874] Building HLFIRTypes.cpp.inc...
[6475/7874] Building HLFIRTypes.h.inc...
[6476/7874] Building HLFIROps.cpp.inc...
[6477/7874] Building Passes.h.inc...
[6478/7874] Building Passes.h.inc...
[6479/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RetainPtrCtorAdoptChecker.cpp.o
[6480/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/FrontendActions.cpp.o
[6481/7874] Building HLFIROps.h.inc...
[6482/7874] Linking CXX shared library lib/libMLIRFuncTransformOps.so.21.0git
FAILED: lib/libMLIRFuncTransformOps.so.21.0git 
: && /usr/bin/c++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -Wno-misleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -Wundef -Wno-unused-but-set-parameter -Wno-deprecated-copy -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libMLIRFuncTransformOps.so.21.0git -o lib/libMLIRFuncTransformOps.so.21.0git tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/build/lib:"  lib/libMLIRFuncToLLVM.so.21.0git  lib/libMLIRTransformDialect.so.21.0git  lib/libMLIRArithToLLVM.so.21.0git  lib/libMLIRArithAttrToLLVMConversion.so.21.0git  lib/libMLIRArithTransforms.so.21.0git  lib/libMLIRBufferizationTransforms.so.21.0git  lib/libMLIRBufferizationDialect.so.21.0git  lib/libMLIRSparseTensorDialect.so.21.0git  lib/libMLIRSCFDialect.so.21.0git  lib/libMLIRFuncTransforms.so.21.0git  lib/libMLIRFuncDialect.so.21.0git  lib/libMLIRShardingInterface.so.21.0git  lib/libMLIRMeshDialect.so.21.0git  lib/libMLIRVectorDialect.so.21.0git  lib/libMLIRTensorDialect.so.21.0git  lib/libMLIRParallelCombiningOpInterface.so.21.0git  lib/libMLIRAffineDialect.so.21.0git  lib/libMLIRMemRefDialect.so.21.0git  lib/libMLIRArithUtils.so.21.0git  lib/libMLIRComplexDialect.so.21.0git  lib/libMLIRMaskableOpInterface.so.21.0git  lib/libMLIRMaskingOpInterface.so.21.0git  lib/libMLIRVectorInterfaces.so.21.0git  lib/libMLIRControlFlowToLLVM.so.21.0git  lib/libMLIRControlFlowDialect.so.21.0git  lib/libMLIRArithDialect.so.21.0git  lib/libMLIRDialect.so.21.0git  lib/libMLIRInferIntRangeCommon.so.21.0git  lib/libMLIRShapedOpInterfaces.so.21.0git  lib/libMLIRLLVMCommonConversion.so.21.0git  lib/libMLIRLLVMDialect.so.21.0git  lib/libLLVMBitWriter.so.21.0git  lib/libLLVMAsmParser.so.21.0git  lib/libLLVMBitReader.so.21.0git  lib/libLLVMCore.so.21.0git  lib/libLLVMBinaryFormat.so.21.0git  lib/libMLIRParser.so.21.0git  lib/libMLIRBytecodeReader.so.21.0git  lib/libMLIRAsmParser.so.21.0git  lib/libMLIRTransformDialectInterfaces.so.21.0git  lib/libMLIRTransforms.so.21.0git  lib/libMLIRTransformUtils.so.21.0git  lib/libMLIRSubsetOpInterface.so.21.0git  lib/libMLIRValueBoundsOpInterface.so.21.0git  lib/libMLIRDestinationStyleOpInterface.so.21.0git  lib/libMLIRMemorySlotInterfaces.so.21.0git  lib/libMLIRRuntimeVerifiableOpInterface.so.21.0git  lib/libMLIRUBDialect.so.21.0git  lib/libMLIRCastInterfaces.so.21.0git  lib/libMLIRRewrite.so.21.0git  lib/libMLIRRewritePDL.so.21.0git  lib/libMLIRPDLToPDLInterp.so.21.0git  lib/libMLIRPass.so.21.0git  lib/libMLIRAnalysis.so.21.0git  lib/libMLIRControlFlowInterfaces.so.21.0git  lib/libMLIRDataLayoutInterfaces.so.21.0git  lib/libMLIRLoopLikeInterface.so.21.0git  lib/libMLIRInferIntRangeInterface.so.21.0git  lib/libMLIRPresburger.so.21.0git  lib/libMLIRPDLInterpDialect.so.21.0git  lib/libMLIRFunctionInterfaces.so.21.0git  lib/libMLIRCallInterfaces.so.21.0git  lib/libMLIRPDLDialect.so.21.0git  lib/libMLIRInferTypeOpInterface.so.21.0git  lib/libMLIRSideEffectInterfaces.so.21.0git  lib/libMLIRTransformDialectUtils.so.21.0git  lib/libMLIRViewLikeInterface.so.21.0git  lib/libMLIRDialectUtils.so.21.0git  lib/libMLIRIR.so.21.0git  lib/libMLIRSupport.so.21.0git  -lpthread  lib/libLLVMSupport.so.21.0git  -Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/build/lib && :
tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o: In function `mlir::transform::ReplaceFuncSignatureOp::apply(mlir::transform::TransformRewriter&, mlir::transform::TransformResults&, mlir::transform::TransformState&) [clone .localalias.42]':
FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0xc99): undefined reference to `mlir::func::replaceFuncWithNewOrder(mlir::RewriterBase&, mlir::func::FuncOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0xd70): undefined reference to `mlir::func::replaceCallOpWithNewOrder(mlir::RewriterBase&, mlir::func::CallOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
collect2: error: ld returned 1 exit status
[6483/7874] Building Options.inc...
[6484/7874] Building CanonicalizationPatterns.inc...
[6485/7874] Linking CXX executable bin/clang-format
[6486/7874] Linking CXX executable bin/offload-arch
[6487/7874] Building CXX object tools/llvm-bcanalyzer/CMakeFiles/llvm-bcanalyzer.dir/llvm-bcanalyzer.cpp.o
[6488/7874] Building CXX object tools/lli/ChildTarget/CMakeFiles/lli-child-target.dir/ChildTarget.cpp.o
[6489/7874] Building CXX object tools/llvm-as/CMakeFiles/llvm-as.dir/llvm-as.cpp.o
[6490/7874] Linking CXX static library lib/libLLVMCFIVerify_static.a
[6491/7874] Building Opts.inc...
[6492/7874] Building CXX object tools/llvm-cat/CMakeFiles/llvm-cat.dir/llvm-cat.cpp.o
[6493/7874] Building CXX object tools/lli/CMakeFiles/lli.dir/lli.cpp.o
[6494/7874] Linking CXX shared library lib/libFortranDecimal.so.21.0git
[6495/7874] Generating VCSVersion.inc
[6496/7874] Linking CXX shared library lib/libNonGTestTesting.so
[6497/7874] Linking CXX shared library lib/libclangTooling.so.21.0git
[6498/7874] Linking CXX shared library lib/libLLVMCFIVerify.so.21.0git
[6499/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/ModelInjector.cpp.o
In file included from /home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/llvm-project/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp:18:
/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/llvm-project/clang/include/clang/Serialization/ASTReader.h:245:16: warning: ‘virtual bool clang::ASTReaderListener::visitInputFile(llvm::StringRef, llvm::StringRef, bool, bool, bool)’ was hidden [-Woverloaded-virtual]
   virtual bool visitInputFile(StringRef FilenameAsRequested, StringRef Filename,
                ^~~~~~~~~~~~~~
/home/botworker/bbot/amdgpu-offload-rhel-8-cmake-build-only/llvm-project/clang/include/clang/Serialization/ASTReader.h:306:8: warning:   by ‘virtual bool clang::ChainedASTReaderListener::visitInputFile(llvm::StringRef, bool, bool, bool)’ [-Woverloaded-virtual]
   bool visitInputFile(StringRef Filename, bool isSystem,
        ^~~~~~~~~~~~~~
[6500/7874] Linking CXX shared library lib/libclangIndex.so.21.0git
[6501/7874] Linking CXX executable bin/diagtool
[6502/7874] Building CXX object tools/clang/tools/clang-installapi/CMakeFiles/clang-installapi.dir/Options.cpp.o
[6503/7874] Building CXX object tools/clang/tools/clang-fuzzer/handle-cxx/CMakeFiles/obj.clangHandleCXX.dir/handle_cxx.cpp.o
[6504/7874] Building CXX object tools/clang/tools/clang-diff/CMakeFiles/clang-diff.dir/ClangDiff.cpp.o
[6505/7874] Building CXX object tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o
[6506/7874] Building CXX object tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/CodeCompletion.cpp.o
[6507/7874] Building CXX object tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/IncrementalParser.cpp.o
[6508/7874] Building CXX object tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/ClangRefactor.cpp.o

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 24, 2025

LLVM Buildbot has detected a new failure on builder amdgpu-offload-ubuntu-22-cmake-build-only running on rocm-docker-ubu-22 while building mlir at step 4 "annotate".

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

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: '../llvm-zorg/zorg/buildbot/builders/annotated/amdgpu-offload-cmake.py --jobs=32' (failure)
...
[6268/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ArrayBoundChecker.cpp.o
[6269/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CastValueChecker.cpp.o
[6270/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CheckPlacementNew.cpp.o
[6271/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CheckerDocumentation.cpp.o
[6272/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CastToStructChecker.cpp.o
[6273/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CastSizeChecker.cpp.o
[6274/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CheckObjCInstMethSignature.cpp.o
[6275/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CheckObjCDealloc.cpp.o
[6276/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CStringSyntaxChecker.cpp.o
[6277/7874] Linking CXX shared library lib/libMLIRFuncTransformOps.so.21.0git
FAILED: lib/libMLIRFuncTransformOps.so.21.0git 
: && /usr/bin/c++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wundef -Wno-unused-but-set-parameter -Wno-deprecated-copy -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libMLIRFuncTransformOps.so.21.0git -o lib/libMLIRFuncTransformOps.so.21.0git tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build/lib:"  lib/libMLIRFuncToLLVM.so.21.0git  lib/libMLIRTransformDialect.so.21.0git  lib/libMLIRArithToLLVM.so.21.0git  lib/libMLIRArithAttrToLLVMConversion.so.21.0git  lib/libMLIRArithTransforms.so.21.0git  lib/libMLIRBufferizationTransforms.so.21.0git  lib/libMLIRBufferizationDialect.so.21.0git  lib/libMLIRSparseTensorDialect.so.21.0git  lib/libMLIRSCFDialect.so.21.0git  lib/libMLIRFuncTransforms.so.21.0git  lib/libMLIRFuncDialect.so.21.0git  lib/libMLIRShardingInterface.so.21.0git  lib/libMLIRMeshDialect.so.21.0git  lib/libMLIRVectorDialect.so.21.0git  lib/libMLIRTensorDialect.so.21.0git  lib/libMLIRParallelCombiningOpInterface.so.21.0git  lib/libMLIRAffineDialect.so.21.0git  lib/libMLIRMemRefDialect.so.21.0git  lib/libMLIRArithUtils.so.21.0git  lib/libMLIRComplexDialect.so.21.0git  lib/libMLIRMaskableOpInterface.so.21.0git  lib/libMLIRMaskingOpInterface.so.21.0git  lib/libMLIRVectorInterfaces.so.21.0git  lib/libMLIRControlFlowToLLVM.so.21.0git  lib/libMLIRControlFlowDialect.so.21.0git  lib/libMLIRArithDialect.so.21.0git  lib/libMLIRDialect.so.21.0git  lib/libMLIRInferIntRangeCommon.so.21.0git  lib/libMLIRShapedOpInterfaces.so.21.0git  lib/libMLIRLLVMCommonConversion.so.21.0git  lib/libMLIRLLVMDialect.so.21.0git  lib/libLLVMBitWriter.so.21.0git  lib/libLLVMAsmParser.so.21.0git  lib/libLLVMBitReader.so.21.0git  lib/libLLVMCore.so.21.0git  lib/libLLVMBinaryFormat.so.21.0git  lib/libMLIRParser.so.21.0git  lib/libMLIRBytecodeReader.so.21.0git  lib/libMLIRAsmParser.so.21.0git  lib/libMLIRTransformDialectInterfaces.so.21.0git  lib/libMLIRTransforms.so.21.0git  lib/libMLIRTransformUtils.so.21.0git  lib/libMLIRSubsetOpInterface.so.21.0git  lib/libMLIRValueBoundsOpInterface.so.21.0git  lib/libMLIRDestinationStyleOpInterface.so.21.0git  lib/libMLIRMemorySlotInterfaces.so.21.0git  lib/libMLIRRuntimeVerifiableOpInterface.so.21.0git  lib/libMLIRUBDialect.so.21.0git  lib/libMLIRCastInterfaces.so.21.0git  lib/libMLIRRewrite.so.21.0git  lib/libMLIRRewritePDL.so.21.0git  lib/libMLIRPDLToPDLInterp.so.21.0git  lib/libMLIRPass.so.21.0git  lib/libMLIRAnalysis.so.21.0git  lib/libMLIRControlFlowInterfaces.so.21.0git  lib/libMLIRDataLayoutInterfaces.so.21.0git  lib/libMLIRLoopLikeInterface.so.21.0git  lib/libMLIRInferIntRangeInterface.so.21.0git  lib/libMLIRPresburger.so.21.0git  lib/libMLIRPDLInterpDialect.so.21.0git  lib/libMLIRFunctionInterfaces.so.21.0git  lib/libMLIRCallInterfaces.so.21.0git  lib/libMLIRPDLDialect.so.21.0git  lib/libMLIRInferTypeOpInterface.so.21.0git  lib/libMLIRSideEffectInterfaces.so.21.0git  lib/libMLIRTransformDialectUtils.so.21.0git  lib/libMLIRViewLikeInterface.so.21.0git  lib/libMLIRDialectUtils.so.21.0git  lib/libMLIRIR.so.21.0git  lib/libMLIRSupport.so.21.0git  lib/libLLVMSupport.so.21.0git  -Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build/lib && :
/usr/bin/ld: tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o: in function `mlir::transform::ReplaceFuncSignatureOp::apply(mlir::transform::TransformRewriter&, mlir::transform::TransformResults&, mlir::transform::TransformState&) [clone .localalias]':
FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0x128e): undefined reference to `mlir::func::replaceFuncWithNewOrder(mlir::RewriterBase&, mlir::func::FuncOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
/usr/bin/ld: FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0x1382): undefined reference to `mlir::func::replaceCallOpWithNewOrder(mlir::RewriterBase&, mlir::func::CallOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
collect2: error: ld returned 1 exit status
[6278/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/Iterator.cpp.o
[6279/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ChrootChecker.cpp.o
[6280/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CheckSecuritySyntaxOnly.cpp.o
[6281/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ContainerModeling.cpp.o
[6282/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CXXDeleteChecker.cpp.o
[6283/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CXXSelfAssignmentChecker.cpp.o
[6284/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DeadStoresChecker.cpp.o
[6285/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DebugCheckers.cpp.o
[6286/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ConversionChecker.cpp.o
[6287/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DynamicTypeChecker.cpp.o
[6288/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DivZeroChecker.cpp.o
[6289/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CloneChecker.cpp.o
[6290/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/EnumCastOutOfRangeChecker.cpp.o
[6291/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DereferenceChecker.cpp.o
[6292/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DebugContainerModeling.cpp.o
[6293/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ErrnoChecker.cpp.o
[6294/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DynamicTypePropagation.cpp.o
[6295/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ErrnoModeling.cpp.o
[6296/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DebugIteratorModeling.cpp.o
[6297/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ErrnoTesterChecker.cpp.o
[6298/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DirectIvarAssignment.cpp.o
[6299/7874] Building AMDGPUGenRegisterBank.inc...
[6300/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ExprInspectionChecker.cpp.o
[6301/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/FixedAddressChecker.cpp.o
[6302/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/GTestChecker.cpp.o
[6303/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/GenericTaintChecker.cpp.o
[6304/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/InvalidatedIteratorChecker.cpp.o
[6305/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/InnerPointerChecker.cpp.o
[6306/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/FuchsiaHandleChecker.cpp.o
[6307/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/IteratorModeling.cpp.o
[6308/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/cert/InvalidPtrChecker.cpp.o
[6309/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/GCDAntipatternChecker.cpp.o
[6310/7874] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o
Step 7 (build cmake config) failure: build cmake config (failure)
...
[6268/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ArrayBoundChecker.cpp.o
[6269/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CastValueChecker.cpp.o
[6270/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CheckPlacementNew.cpp.o
[6271/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CheckerDocumentation.cpp.o
[6272/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CastToStructChecker.cpp.o
[6273/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CastSizeChecker.cpp.o
[6274/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CheckObjCInstMethSignature.cpp.o
[6275/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CheckObjCDealloc.cpp.o
[6276/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CStringSyntaxChecker.cpp.o
[6277/7874] Linking CXX shared library lib/libMLIRFuncTransformOps.so.21.0git
FAILED: lib/libMLIRFuncTransformOps.so.21.0git 
: && /usr/bin/c++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wundef -Wno-unused-but-set-parameter -Wno-deprecated-copy -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libMLIRFuncTransformOps.so.21.0git -o lib/libMLIRFuncTransformOps.so.21.0git tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build/lib:"  lib/libMLIRFuncToLLVM.so.21.0git  lib/libMLIRTransformDialect.so.21.0git  lib/libMLIRArithToLLVM.so.21.0git  lib/libMLIRArithAttrToLLVMConversion.so.21.0git  lib/libMLIRArithTransforms.so.21.0git  lib/libMLIRBufferizationTransforms.so.21.0git  lib/libMLIRBufferizationDialect.so.21.0git  lib/libMLIRSparseTensorDialect.so.21.0git  lib/libMLIRSCFDialect.so.21.0git  lib/libMLIRFuncTransforms.so.21.0git  lib/libMLIRFuncDialect.so.21.0git  lib/libMLIRShardingInterface.so.21.0git  lib/libMLIRMeshDialect.so.21.0git  lib/libMLIRVectorDialect.so.21.0git  lib/libMLIRTensorDialect.so.21.0git  lib/libMLIRParallelCombiningOpInterface.so.21.0git  lib/libMLIRAffineDialect.so.21.0git  lib/libMLIRMemRefDialect.so.21.0git  lib/libMLIRArithUtils.so.21.0git  lib/libMLIRComplexDialect.so.21.0git  lib/libMLIRMaskableOpInterface.so.21.0git  lib/libMLIRMaskingOpInterface.so.21.0git  lib/libMLIRVectorInterfaces.so.21.0git  lib/libMLIRControlFlowToLLVM.so.21.0git  lib/libMLIRControlFlowDialect.so.21.0git  lib/libMLIRArithDialect.so.21.0git  lib/libMLIRDialect.so.21.0git  lib/libMLIRInferIntRangeCommon.so.21.0git  lib/libMLIRShapedOpInterfaces.so.21.0git  lib/libMLIRLLVMCommonConversion.so.21.0git  lib/libMLIRLLVMDialect.so.21.0git  lib/libLLVMBitWriter.so.21.0git  lib/libLLVMAsmParser.so.21.0git  lib/libLLVMBitReader.so.21.0git  lib/libLLVMCore.so.21.0git  lib/libLLVMBinaryFormat.so.21.0git  lib/libMLIRParser.so.21.0git  lib/libMLIRBytecodeReader.so.21.0git  lib/libMLIRAsmParser.so.21.0git  lib/libMLIRTransformDialectInterfaces.so.21.0git  lib/libMLIRTransforms.so.21.0git  lib/libMLIRTransformUtils.so.21.0git  lib/libMLIRSubsetOpInterface.so.21.0git  lib/libMLIRValueBoundsOpInterface.so.21.0git  lib/libMLIRDestinationStyleOpInterface.so.21.0git  lib/libMLIRMemorySlotInterfaces.so.21.0git  lib/libMLIRRuntimeVerifiableOpInterface.so.21.0git  lib/libMLIRUBDialect.so.21.0git  lib/libMLIRCastInterfaces.so.21.0git  lib/libMLIRRewrite.so.21.0git  lib/libMLIRRewritePDL.so.21.0git  lib/libMLIRPDLToPDLInterp.so.21.0git  lib/libMLIRPass.so.21.0git  lib/libMLIRAnalysis.so.21.0git  lib/libMLIRControlFlowInterfaces.so.21.0git  lib/libMLIRDataLayoutInterfaces.so.21.0git  lib/libMLIRLoopLikeInterface.so.21.0git  lib/libMLIRInferIntRangeInterface.so.21.0git  lib/libMLIRPresburger.so.21.0git  lib/libMLIRPDLInterpDialect.so.21.0git  lib/libMLIRFunctionInterfaces.so.21.0git  lib/libMLIRCallInterfaces.so.21.0git  lib/libMLIRPDLDialect.so.21.0git  lib/libMLIRInferTypeOpInterface.so.21.0git  lib/libMLIRSideEffectInterfaces.so.21.0git  lib/libMLIRTransformDialectUtils.so.21.0git  lib/libMLIRViewLikeInterface.so.21.0git  lib/libMLIRDialectUtils.so.21.0git  lib/libMLIRIR.so.21.0git  lib/libMLIRSupport.so.21.0git  lib/libLLVMSupport.so.21.0git  -Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-ubuntu-22-cmake-build-only/build/lib && :
/usr/bin/ld: tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o: in function `mlir::transform::ReplaceFuncSignatureOp::apply(mlir::transform::TransformRewriter&, mlir::transform::TransformResults&, mlir::transform::TransformState&) [clone .localalias]':
FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0x128e): undefined reference to `mlir::func::replaceFuncWithNewOrder(mlir::RewriterBase&, mlir::func::FuncOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
/usr/bin/ld: FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0x1382): undefined reference to `mlir::func::replaceCallOpWithNewOrder(mlir::RewriterBase&, mlir::func::CallOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
collect2: error: ld returned 1 exit status
[6278/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/Iterator.cpp.o
[6279/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ChrootChecker.cpp.o
[6280/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CheckSecuritySyntaxOnly.cpp.o
[6281/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ContainerModeling.cpp.o
[6282/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CXXDeleteChecker.cpp.o
[6283/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CXXSelfAssignmentChecker.cpp.o
[6284/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DeadStoresChecker.cpp.o
[6285/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DebugCheckers.cpp.o
[6286/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ConversionChecker.cpp.o
[6287/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DynamicTypeChecker.cpp.o
[6288/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DivZeroChecker.cpp.o
[6289/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/CloneChecker.cpp.o
[6290/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/EnumCastOutOfRangeChecker.cpp.o
[6291/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DereferenceChecker.cpp.o
[6292/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DebugContainerModeling.cpp.o
[6293/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ErrnoChecker.cpp.o
[6294/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DynamicTypePropagation.cpp.o
[6295/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ErrnoModeling.cpp.o
[6296/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DebugIteratorModeling.cpp.o
[6297/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ErrnoTesterChecker.cpp.o
[6298/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/DirectIvarAssignment.cpp.o
[6299/7874] Building AMDGPUGenRegisterBank.inc...
[6300/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/ExprInspectionChecker.cpp.o
[6301/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/FixedAddressChecker.cpp.o
[6302/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/GTestChecker.cpp.o
[6303/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/GenericTaintChecker.cpp.o
[6304/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/InvalidatedIteratorChecker.cpp.o
[6305/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/InnerPointerChecker.cpp.o
[6306/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/FuchsiaHandleChecker.cpp.o
[6307/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/IteratorModeling.cpp.o
[6308/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/cert/InvalidPtrChecker.cpp.o
[6309/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/GCDAntipatternChecker.cpp.o
[6310/7874] Building CXX object tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/HIPUtility.cpp.o

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 24, 2025

LLVM Buildbot has detected a new failure on builder amdgpu-offload-rhel-9-cmake-build-only running on rocm-docker-rhel-9 while building mlir at step 4 "annotate".

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

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: '../llvm-zorg/zorg/buildbot/builders/annotated/amdgpu-offload-cmake.py --jobs=32' (failure)
...
[6474/7874] Building NVLinkOpts.inc...
[6475/7874] Building CXX object tools/clang/tools/clang-fuzzer/handle-llvm/CMakeFiles/obj.clangHandleLLVM.dir/handle_llvm.cpp.o
[6476/7874] Linking CXX shared library lib/libclangFormat.so.21.0git
[6477/7874] Building CXX object tools/clang/tools/clang-offload-bundler/CMakeFiles/clang-offload-bundler.dir/ClangOffloadBundler.cpp.o
[6478/7874] Building SYCLLinkOpts.inc...
[6479/7874] Building Opts.inc...
[6480/7874] Building InstallAPIOpts.inc...
[6481/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/VirtualCallChecker.cpp.o
[6482/7874] Creating library symlink lib/libclangFormat.so
[6483/7874] Linking CXX shared library lib/libMLIRFuncTransformOps.so.21.0git
FAILED: lib/libMLIRFuncTransformOps.so.21.0git 
: && /usr/bin/c++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wundef -Wno-unused-but-set-parameter -Wno-deprecated-copy -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libMLIRFuncTransformOps.so.21.0git -o lib/libMLIRFuncTransformOps.so.21.0git tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/lib:"  lib/libMLIRFuncToLLVM.so.21.0git  lib/libMLIRTransformDialect.so.21.0git  lib/libMLIRArithToLLVM.so.21.0git  lib/libMLIRArithAttrToLLVMConversion.so.21.0git  lib/libMLIRArithTransforms.so.21.0git  lib/libMLIRBufferizationTransforms.so.21.0git  lib/libMLIRBufferizationDialect.so.21.0git  lib/libMLIRSparseTensorDialect.so.21.0git  lib/libMLIRSCFDialect.so.21.0git  lib/libMLIRFuncTransforms.so.21.0git  lib/libMLIRFuncDialect.so.21.0git  lib/libMLIRShardingInterface.so.21.0git  lib/libMLIRMeshDialect.so.21.0git  lib/libMLIRVectorDialect.so.21.0git  lib/libMLIRTensorDialect.so.21.0git  lib/libMLIRParallelCombiningOpInterface.so.21.0git  lib/libMLIRAffineDialect.so.21.0git  lib/libMLIRMemRefDialect.so.21.0git  lib/libMLIRArithUtils.so.21.0git  lib/libMLIRComplexDialect.so.21.0git  lib/libMLIRMaskableOpInterface.so.21.0git  lib/libMLIRMaskingOpInterface.so.21.0git  lib/libMLIRVectorInterfaces.so.21.0git  lib/libMLIRControlFlowToLLVM.so.21.0git  lib/libMLIRControlFlowDialect.so.21.0git  lib/libMLIRArithDialect.so.21.0git  lib/libMLIRDialect.so.21.0git  lib/libMLIRInferIntRangeCommon.so.21.0git  lib/libMLIRShapedOpInterfaces.so.21.0git  lib/libMLIRLLVMCommonConversion.so.21.0git  lib/libMLIRLLVMDialect.so.21.0git  lib/libLLVMBitWriter.so.21.0git  lib/libLLVMAsmParser.so.21.0git  lib/libLLVMBitReader.so.21.0git  lib/libLLVMCore.so.21.0git  lib/libLLVMBinaryFormat.so.21.0git  lib/libMLIRParser.so.21.0git  lib/libMLIRBytecodeReader.so.21.0git  lib/libMLIRAsmParser.so.21.0git  lib/libMLIRTransformDialectInterfaces.so.21.0git  lib/libMLIRTransforms.so.21.0git  lib/libMLIRTransformUtils.so.21.0git  lib/libMLIRSubsetOpInterface.so.21.0git  lib/libMLIRValueBoundsOpInterface.so.21.0git  lib/libMLIRDestinationStyleOpInterface.so.21.0git  lib/libMLIRMemorySlotInterfaces.so.21.0git  lib/libMLIRRuntimeVerifiableOpInterface.so.21.0git  lib/libMLIRUBDialect.so.21.0git  lib/libMLIRCastInterfaces.so.21.0git  lib/libMLIRRewrite.so.21.0git  lib/libMLIRRewritePDL.so.21.0git  lib/libMLIRPDLToPDLInterp.so.21.0git  lib/libMLIRPass.so.21.0git  lib/libMLIRAnalysis.so.21.0git  lib/libMLIRControlFlowInterfaces.so.21.0git  lib/libMLIRDataLayoutInterfaces.so.21.0git  lib/libMLIRLoopLikeInterface.so.21.0git  lib/libMLIRInferIntRangeInterface.so.21.0git  lib/libMLIRPresburger.so.21.0git  lib/libMLIRPDLInterpDialect.so.21.0git  lib/libMLIRFunctionInterfaces.so.21.0git  lib/libMLIRCallInterfaces.so.21.0git  lib/libMLIRPDLDialect.so.21.0git  lib/libMLIRInferTypeOpInterface.so.21.0git  lib/libMLIRSideEffectInterfaces.so.21.0git  lib/libMLIRTransformDialectUtils.so.21.0git  lib/libMLIRViewLikeInterface.so.21.0git  lib/libMLIRDialectUtils.so.21.0git  lib/libMLIRIR.so.21.0git  lib/libMLIRSupport.so.21.0git  lib/libLLVMSupport.so.21.0git  -Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/lib && :
/usr/bin/ld: tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o: in function `mlir::transform::ReplaceFuncSignatureOp::apply(mlir::transform::TransformRewriter&, mlir::transform::TransformResults&, mlir::transform::TransformState&) [clone .localalias]':
FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0x12cd): undefined reference to `mlir::func::replaceFuncWithNewOrder(mlir::RewriterBase&, mlir::func::FuncOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
/usr/bin/ld: FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0x13c6): undefined reference to `mlir::func::replaceCallOpWithNewOrder(mlir::RewriterBase&, mlir::func::CallOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
collect2: error: ld returned 1 exit status
[6484/7874] Building CXX object tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/TestSupport.cpp.o
[6485/7874] Linking CXX executable bin/apinotes-test
[6486/7874] Building CXX object tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/FindDiagnosticID.cpp.o
[6487/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/UninitializedObject/UninitializedObjectChecker.cpp.o
[6488/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RawPtrRefLambdaCapturesChecker.cpp.o
[6489/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RawPtrRefLocalVarsChecker.cpp.o
[6490/7874] Linking CXX shared library lib/libclangFrontend.so.21.0git
[6491/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RawPtrRefCallArgsChecker.cpp.o
[6492/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RawPtrRefMemberChecker.cpp.o
[6493/7874] Building CXX object tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/ListWarnings.cpp.o
[6494/7874] Linking CXX executable bin/clang-offload-bundler
[6495/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RefCntblBaseVirtualDtorChecker.cpp.o
[6496/7874] Building CXX object tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/TreeView.cpp.o
[6497/7874] Linking CXX shared library lib/libclangHandleLLVM.so.21.0git
[6498/7874] Linking CXX executable bin/clang-format
[6499/7874] Building CXX object tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/DiagnosticNames.cpp.o
[6500/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/FrontendActions.cpp.o
[6501/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/ForwardDeclChecker.cpp.o
[6502/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/MemoryUnsafeCastChecker.cpp.o
[6503/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/AnalysisConsumer.cpp.o
[6504/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RetainPtrCtorAdoptChecker.cpp.o
[6505/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/ModelInjector.cpp.o
In file included from /home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp:18:
/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/clang/include/clang/Serialization/ASTReader.h:245:16: warning: ‘virtual bool clang::ASTReaderListener::visitInputFile(llvm::StringRef, llvm::StringRef, bool, bool, bool)’ was hidden [-Woverloaded-virtual]
  245 |   virtual bool visitInputFile(StringRef FilenameAsRequested, StringRef Filename,
      |                ^~~~~~~~~~~~~~
/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/clang/include/clang/Serialization/ASTReader.h:306:8: note:   by ‘virtual bool clang::ChainedASTReaderListener::visitInputFile(llvm::StringRef, bool, bool, bool)’
  306 |   bool visitInputFile(StringRef Filename, bool isSystem,
      |        ^~~~~~~~~~~~~~
[6506/7874] Building CXX object tools/clang/tools/clang-installapi/CMakeFiles/clang-installapi.dir/Options.cpp.o
[6507/7874] Building CXX object tools/clang/tools/clang-fuzzer/handle-cxx/CMakeFiles/obj.clangHandleCXX.dir/handle_cxx.cpp.o
[6508/7874] Building CXX object tools/clang/tools/clang-diff/CMakeFiles/clang-diff.dir/ClangDiff.cpp.o
[6509/7874] Building CXX object tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o
Step 7 (build cmake config) failure: build cmake config (failure)
...
[6474/7874] Building NVLinkOpts.inc...
[6475/7874] Building CXX object tools/clang/tools/clang-fuzzer/handle-llvm/CMakeFiles/obj.clangHandleLLVM.dir/handle_llvm.cpp.o
[6476/7874] Linking CXX shared library lib/libclangFormat.so.21.0git
[6477/7874] Building CXX object tools/clang/tools/clang-offload-bundler/CMakeFiles/clang-offload-bundler.dir/ClangOffloadBundler.cpp.o
[6478/7874] Building SYCLLinkOpts.inc...
[6479/7874] Building Opts.inc...
[6480/7874] Building InstallAPIOpts.inc...
[6481/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/VirtualCallChecker.cpp.o
[6482/7874] Creating library symlink lib/libclangFormat.so
[6483/7874] Linking CXX shared library lib/libMLIRFuncTransformOps.so.21.0git
FAILED: lib/libMLIRFuncTransformOps.so.21.0git 
: && /usr/bin/c++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wundef -Wno-unused-but-set-parameter -Wno-deprecated-copy -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libMLIRFuncTransformOps.so.21.0git -o lib/libMLIRFuncTransformOps.so.21.0git tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/lib:"  lib/libMLIRFuncToLLVM.so.21.0git  lib/libMLIRTransformDialect.so.21.0git  lib/libMLIRArithToLLVM.so.21.0git  lib/libMLIRArithAttrToLLVMConversion.so.21.0git  lib/libMLIRArithTransforms.so.21.0git  lib/libMLIRBufferizationTransforms.so.21.0git  lib/libMLIRBufferizationDialect.so.21.0git  lib/libMLIRSparseTensorDialect.so.21.0git  lib/libMLIRSCFDialect.so.21.0git  lib/libMLIRFuncTransforms.so.21.0git  lib/libMLIRFuncDialect.so.21.0git  lib/libMLIRShardingInterface.so.21.0git  lib/libMLIRMeshDialect.so.21.0git  lib/libMLIRVectorDialect.so.21.0git  lib/libMLIRTensorDialect.so.21.0git  lib/libMLIRParallelCombiningOpInterface.so.21.0git  lib/libMLIRAffineDialect.so.21.0git  lib/libMLIRMemRefDialect.so.21.0git  lib/libMLIRArithUtils.so.21.0git  lib/libMLIRComplexDialect.so.21.0git  lib/libMLIRMaskableOpInterface.so.21.0git  lib/libMLIRMaskingOpInterface.so.21.0git  lib/libMLIRVectorInterfaces.so.21.0git  lib/libMLIRControlFlowToLLVM.so.21.0git  lib/libMLIRControlFlowDialect.so.21.0git  lib/libMLIRArithDialect.so.21.0git  lib/libMLIRDialect.so.21.0git  lib/libMLIRInferIntRangeCommon.so.21.0git  lib/libMLIRShapedOpInterfaces.so.21.0git  lib/libMLIRLLVMCommonConversion.so.21.0git  lib/libMLIRLLVMDialect.so.21.0git  lib/libLLVMBitWriter.so.21.0git  lib/libLLVMAsmParser.so.21.0git  lib/libLLVMBitReader.so.21.0git  lib/libLLVMCore.so.21.0git  lib/libLLVMBinaryFormat.so.21.0git  lib/libMLIRParser.so.21.0git  lib/libMLIRBytecodeReader.so.21.0git  lib/libMLIRAsmParser.so.21.0git  lib/libMLIRTransformDialectInterfaces.so.21.0git  lib/libMLIRTransforms.so.21.0git  lib/libMLIRTransformUtils.so.21.0git  lib/libMLIRSubsetOpInterface.so.21.0git  lib/libMLIRValueBoundsOpInterface.so.21.0git  lib/libMLIRDestinationStyleOpInterface.so.21.0git  lib/libMLIRMemorySlotInterfaces.so.21.0git  lib/libMLIRRuntimeVerifiableOpInterface.so.21.0git  lib/libMLIRUBDialect.so.21.0git  lib/libMLIRCastInterfaces.so.21.0git  lib/libMLIRRewrite.so.21.0git  lib/libMLIRRewritePDL.so.21.0git  lib/libMLIRPDLToPDLInterp.so.21.0git  lib/libMLIRPass.so.21.0git  lib/libMLIRAnalysis.so.21.0git  lib/libMLIRControlFlowInterfaces.so.21.0git  lib/libMLIRDataLayoutInterfaces.so.21.0git  lib/libMLIRLoopLikeInterface.so.21.0git  lib/libMLIRInferIntRangeInterface.so.21.0git  lib/libMLIRPresburger.so.21.0git  lib/libMLIRPDLInterpDialect.so.21.0git  lib/libMLIRFunctionInterfaces.so.21.0git  lib/libMLIRCallInterfaces.so.21.0git  lib/libMLIRPDLDialect.so.21.0git  lib/libMLIRInferTypeOpInterface.so.21.0git  lib/libMLIRSideEffectInterfaces.so.21.0git  lib/libMLIRTransformDialectUtils.so.21.0git  lib/libMLIRViewLikeInterface.so.21.0git  lib/libMLIRDialectUtils.so.21.0git  lib/libMLIRIR.so.21.0git  lib/libMLIRSupport.so.21.0git  lib/libLLVMSupport.so.21.0git  -Wl,-rpath-link,/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/build/lib && :
/usr/bin/ld: tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o: in function `mlir::transform::ReplaceFuncSignatureOp::apply(mlir::transform::TransformRewriter&, mlir::transform::TransformResults&, mlir::transform::TransformState&) [clone .localalias]':
FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0x12cd): undefined reference to `mlir::func::replaceFuncWithNewOrder(mlir::RewriterBase&, mlir::func::FuncOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
/usr/bin/ld: FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0x13c6): undefined reference to `mlir::func::replaceCallOpWithNewOrder(mlir::RewriterBase&, mlir::func::CallOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
collect2: error: ld returned 1 exit status
[6484/7874] Building CXX object tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/TestSupport.cpp.o
[6485/7874] Linking CXX executable bin/apinotes-test
[6486/7874] Building CXX object tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/FindDiagnosticID.cpp.o
[6487/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/UninitializedObject/UninitializedObjectChecker.cpp.o
[6488/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RawPtrRefLambdaCapturesChecker.cpp.o
[6489/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RawPtrRefLocalVarsChecker.cpp.o
[6490/7874] Linking CXX shared library lib/libclangFrontend.so.21.0git
[6491/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RawPtrRefCallArgsChecker.cpp.o
[6492/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RawPtrRefMemberChecker.cpp.o
[6493/7874] Building CXX object tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/ListWarnings.cpp.o
[6494/7874] Linking CXX executable bin/clang-offload-bundler
[6495/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RefCntblBaseVirtualDtorChecker.cpp.o
[6496/7874] Building CXX object tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/TreeView.cpp.o
[6497/7874] Linking CXX shared library lib/libclangHandleLLVM.so.21.0git
[6498/7874] Linking CXX executable bin/clang-format
[6499/7874] Building CXX object tools/clang/tools/diagtool/CMakeFiles/diagtool.dir/DiagnosticNames.cpp.o
[6500/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/FrontendActions.cpp.o
[6501/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/ForwardDeclChecker.cpp.o
[6502/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/MemoryUnsafeCastChecker.cpp.o
[6503/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/AnalysisConsumer.cpp.o
[6504/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/RetainPtrCtorAdoptChecker.cpp.o
[6505/7874] Building CXX object tools/clang/lib/StaticAnalyzer/Frontend/CMakeFiles/obj.clangStaticAnalyzerFrontend.dir/ModelInjector.cpp.o
In file included from /home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/clang/lib/StaticAnalyzer/Frontend/ModelInjector.cpp:18:
/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/clang/include/clang/Serialization/ASTReader.h:245:16: warning: ‘virtual bool clang::ASTReaderListener::visitInputFile(llvm::StringRef, llvm::StringRef, bool, bool, bool)’ was hidden [-Woverloaded-virtual]
  245 |   virtual bool visitInputFile(StringRef FilenameAsRequested, StringRef Filename,
      |                ^~~~~~~~~~~~~~
/home/botworker/bbot/amdgpu-offload-rhel-9-cmake-build-only/llvm-project/clang/include/clang/Serialization/ASTReader.h:306:8: note:   by ‘virtual bool clang::ChainedASTReaderListener::visitInputFile(llvm::StringRef, bool, bool, bool)’
  306 |   bool visitInputFile(StringRef Filename, bool isSystem,
      |        ^~~~~~~~~~~~~~
[6506/7874] Building CXX object tools/clang/tools/clang-installapi/CMakeFiles/clang-installapi.dir/Options.cpp.o
[6507/7874] Building CXX object tools/clang/tools/clang-fuzzer/handle-cxx/CMakeFiles/obj.clangHandleCXX.dir/handle_cxx.cpp.o
[6508/7874] Building CXX object tools/clang/tools/clang-diff/CMakeFiles/clang-diff.dir/ClangDiff.cpp.o
[6509/7874] Building CXX object tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 24, 2025

LLVM Buildbot has detected a new failure on builder mlir-nvidia running on mlir-nvidia while building mlir at step 6 "build-check-mlir-build-only".

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

Here is the relevant piece of the build log for the reference
Step 6 (build-check-mlir-build-only) failure: build (failure)
...
32.597 [60/13/5207] Linking CXX shared library lib/libMLIRGPUTransformOps.so.21.0git
32.605 [59/13/5208] Creating library symlink lib/libMLIRGPUTransformOps.so
32.764 [59/12/5209] Linking CXX shared library lib/libMLIRGPUTestPasses.so.21.0git
32.765 [58/12/5210] Linking CXX shared library lib/libMLIRCAPIConversion.so.21.0git
32.772 [57/12/5211] Creating library symlink lib/libMLIRCAPIConversion.so
32.772 [57/11/5212] Creating library symlink lib/libMLIRGPUTestPasses.so
32.784 [57/10/5213] Linking CXX shared library lib/libMLIRTestPass.so.21.0git
32.789 [56/10/5214] Creating library symlink lib/libMLIRTestPass.so
36.916 [56/9/5215] Building CXX object tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o
37.023 [55/9/5216] Linking CXX shared library lib/libMLIRFuncTransformOps.so.21.0git
FAILED: lib/libMLIRFuncTransformOps.so.21.0git 
: && /usr/bin/clang++ -fPIC -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  -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=lld -Wl,--color-diagnostics   -Wl,--gc-sections -shared -Wl,-soname,libMLIRFuncTransformOps.so.21.0git -o lib/libMLIRFuncTransformOps.so.21.0git tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/vol/worker/mlir-nvidia/mlir-nvidia/llvm.obj/lib:"  lib/libMLIRFuncToLLVM.so.21.0git  lib/libMLIRTransformDialect.so.21.0git  lib/libMLIRArithToLLVM.so.21.0git  lib/libMLIRArithAttrToLLVMConversion.so.21.0git  lib/libMLIRArithTransforms.so.21.0git  lib/libMLIRBufferizationTransforms.so.21.0git  lib/libMLIRBufferizationDialect.so.21.0git  lib/libMLIRSparseTensorDialect.so.21.0git  lib/libMLIRSCFDialect.so.21.0git  lib/libMLIRFuncTransforms.so.21.0git  lib/libMLIRFuncDialect.so.21.0git  lib/libMLIRShardingInterface.so.21.0git  lib/libMLIRMeshDialect.so.21.0git  lib/libMLIRVectorDialect.so.21.0git  lib/libMLIRTensorDialect.so.21.0git  lib/libMLIRParallelCombiningOpInterface.so.21.0git  lib/libMLIRAffineDialect.so.21.0git  lib/libMLIRMemRefDialect.so.21.0git  lib/libMLIRArithUtils.so.21.0git  lib/libMLIRComplexDialect.so.21.0git  lib/libMLIRMaskableOpInterface.so.21.0git  lib/libMLIRMaskingOpInterface.so.21.0git  lib/libMLIRVectorInterfaces.so.21.0git  lib/libMLIRControlFlowToLLVM.so.21.0git  lib/libMLIRControlFlowDialect.so.21.0git  lib/libMLIRArithDialect.so.21.0git  lib/libMLIRDialect.so.21.0git  lib/libMLIRInferIntRangeCommon.so.21.0git  lib/libMLIRShapedOpInterfaces.so.21.0git  lib/libMLIRLLVMCommonConversion.so.21.0git  lib/libMLIRLLVMDialect.so.21.0git  lib/libLLVMBitWriter.so.21.0git  lib/libLLVMAsmParser.so.21.0git  lib/libLLVMBitReader.so.21.0git  lib/libLLVMCore.so.21.0git  lib/libLLVMBinaryFormat.so.21.0git  lib/libMLIRParser.so.21.0git  lib/libMLIRBytecodeReader.so.21.0git  lib/libMLIRAsmParser.so.21.0git  lib/libMLIRTransformDialectInterfaces.so.21.0git  lib/libMLIRTransforms.so.21.0git  lib/libMLIRTransformUtils.so.21.0git  lib/libMLIRSubsetOpInterface.so.21.0git  lib/libMLIRValueBoundsOpInterface.so.21.0git  lib/libMLIRDestinationStyleOpInterface.so.21.0git  lib/libMLIRMemorySlotInterfaces.so.21.0git  lib/libMLIRRuntimeVerifiableOpInterface.so.21.0git  lib/libMLIRUBDialect.so.21.0git  lib/libMLIRCastInterfaces.so.21.0git  lib/libMLIRRewrite.so.21.0git  lib/libMLIRRewritePDL.so.21.0git  lib/libMLIRPDLToPDLInterp.so.21.0git  lib/libMLIRPass.so.21.0git  lib/libMLIRAnalysis.so.21.0git  lib/libMLIRControlFlowInterfaces.so.21.0git  lib/libMLIRDataLayoutInterfaces.so.21.0git  lib/libMLIRLoopLikeInterface.so.21.0git  lib/libMLIRInferIntRangeInterface.so.21.0git  lib/libMLIRPresburger.so.21.0git  lib/libMLIRPDLInterpDialect.so.21.0git  lib/libMLIRFunctionInterfaces.so.21.0git  lib/libMLIRCallInterfaces.so.21.0git  lib/libMLIRPDLDialect.so.21.0git  lib/libMLIRInferTypeOpInterface.so.21.0git  lib/libMLIRSideEffectInterfaces.so.21.0git  lib/libMLIRTransformDialectUtils.so.21.0git  lib/libMLIRViewLikeInterface.so.21.0git  lib/libMLIRDialectUtils.so.21.0git  lib/libMLIRIR.so.21.0git  lib/libMLIRSupport.so.21.0git  lib/libLLVMSupport.so.21.0git  -Wl,-rpath-link,/vol/worker/mlir-nvidia/mlir-nvidia/llvm.obj/lib && :
ld.lld: error: undefined symbol: mlir::func::replaceFuncWithNewOrder(mlir::RewriterBase&, mlir::func::FuncOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)
>>> referenced by FuncTransformOps.cpp
>>>               tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o:(mlir::transform::ReplaceFuncSignatureOp::apply(mlir::transform::TransformRewriter&, mlir::transform::TransformResults&, mlir::transform::TransformState&))

ld.lld: error: undefined symbol: mlir::func::replaceCallOpWithNewOrder(mlir::RewriterBase&, mlir::func::CallOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)
>>> referenced by FuncTransformOps.cpp
>>>               tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o:(mlir::transform::ReplaceFuncSignatureOp::apply(mlir::transform::TransformRewriter&, mlir::transform::TransformResults&, mlir::transform::TransformState&))
clang: error: linker command failed with exit code 1 (use -v to see invocation)
58.870 [55/8/5217] Building CXX object tools/mlir/examples/transform/Ch2/CMakeFiles/transform-opt-ch2.dir/transform-opt/transform-opt.cpp.o
59.235 [55/7/5218] Building CXX object tools/mlir/examples/transform/Ch3/CMakeFiles/transform-opt-ch3.dir/transform-opt/transform-opt.cpp.o
60.590 [55/6/5219] Building CXX object tools/mlir/tools/mlir-lsp-server/CMakeFiles/mlir-lsp-server.dir/mlir-lsp-server.cpp.o
62.233 [55/5/5220] Building CXX object tools/mlir/examples/transform/Ch4/CMakeFiles/transform-opt-ch4.dir/transform-opt/transform-opt.cpp.o
62.801 [55/4/5221] Building CXX object tools/mlir/lib/CAPI/RegisterEverything/CMakeFiles/obj.MLIRCAPIRegisterEverything.dir/RegisterEverything.cpp.o
65.459 [55/3/5222] Building CXX object tools/mlir/tools/mlir-opt/CMakeFiles/mlir-opt.dir/mlir-opt.cpp.o
67.500 [55/2/5223] Building CXX object tools/mlir/tools/mlir-opt/CMakeFiles/MLIRMlirOptMain.dir/mlir-opt.cpp.o
69.860 [55/1/5224] Building CXX object tools/mlir/examples/transform-opt/CMakeFiles/mlir-transform-opt.dir/mlir-transform-opt.cpp.o
ninja: build stopped: subcommand failed.

ergawy added a commit that referenced this pull request Jun 24, 2025
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 24, 2025

LLVM Buildbot has detected a new failure on builder flang-aarch64-sharedlibs running on linaro-flang-aarch64-sharedlibs while building mlir at step 5 "build-unified-tree".

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

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
655.938 [531/1/7146] Creating library symlink lib/libMLIRAffineTransformOps.so
656.159 [530/1/7147] Linking CXX shared library lib/libMLIRArmNeonVectorTransformOps.so.21.0git
656.170 [529/1/7148] Creating library symlink lib/libMLIRArmNeonVectorTransformOps.so
656.408 [528/1/7149] Linking CXX shared library lib/libMLIRArmSVEVectorTransformOps.so.21.0git
656.418 [527/1/7150] Creating library symlink lib/libMLIRArmSVEVectorTransformOps.so
656.672 [526/1/7151] Linking CXX shared library lib/libMLIRBufferizationTransformOps.so.21.0git
656.681 [525/1/7152] Creating library symlink lib/libMLIRBufferizationTransformOps.so
656.870 [524/1/7153] Linking CXX shared library lib/libMLIRDLTITransformOps.so.21.0git
656.880 [523/1/7154] Creating library symlink lib/libMLIRDLTITransformOps.so
657.131 [522/1/7155] Linking CXX shared library lib/libMLIRFuncTransformOps.so.21.0git
FAILED: lib/libMLIRFuncTransformOps.so.21.0git 
: && /usr/local/bin/c++ -fPIC -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  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-sharedlibs/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libMLIRFuncTransformOps.so.21.0git -o lib/libMLIRFuncTransformOps.so.21.0git tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/tcwg-buildbot/worker/flang-aarch64-sharedlibs/build/lib:"  lib/libMLIRFuncToLLVM.so.21.0git  lib/libMLIRTransformDialect.so.21.0git  lib/libMLIRArithToLLVM.so.21.0git  lib/libMLIRArithAttrToLLVMConversion.so.21.0git  lib/libMLIRArithTransforms.so.21.0git  lib/libMLIRBufferizationTransforms.so.21.0git  lib/libMLIRBufferizationDialect.so.21.0git  lib/libMLIRSparseTensorDialect.so.21.0git  lib/libMLIRSCFDialect.so.21.0git  lib/libMLIRFuncTransforms.so.21.0git  lib/libMLIRFuncDialect.so.21.0git  lib/libMLIRShardingInterface.so.21.0git  lib/libMLIRMeshDialect.so.21.0git  lib/libMLIRVectorDialect.so.21.0git  lib/libMLIRTensorDialect.so.21.0git  lib/libMLIRParallelCombiningOpInterface.so.21.0git  lib/libMLIRAffineDialect.so.21.0git  lib/libMLIRMemRefDialect.so.21.0git  lib/libMLIRArithUtils.so.21.0git  lib/libMLIRComplexDialect.so.21.0git  lib/libMLIRMaskableOpInterface.so.21.0git  lib/libMLIRMaskingOpInterface.so.21.0git  lib/libMLIRVectorInterfaces.so.21.0git  lib/libMLIRControlFlowToLLVM.so.21.0git  lib/libMLIRControlFlowDialect.so.21.0git  lib/libMLIRArithDialect.so.21.0git  lib/libMLIRDialect.so.21.0git  lib/libMLIRInferIntRangeCommon.so.21.0git  lib/libMLIRShapedOpInterfaces.so.21.0git  lib/libMLIRLLVMCommonConversion.so.21.0git  lib/libMLIRLLVMDialect.so.21.0git  lib/libLLVMBitWriter.so.21.0git  lib/libLLVMAsmParser.so.21.0git  lib/libLLVMBitReader.so.21.0git  lib/libLLVMCore.so.21.0git  lib/libLLVMBinaryFormat.so.21.0git  lib/libMLIRParser.so.21.0git  lib/libMLIRBytecodeReader.so.21.0git  lib/libMLIRAsmParser.so.21.0git  lib/libMLIRTransformDialectInterfaces.so.21.0git  lib/libMLIRTransforms.so.21.0git  lib/libMLIRTransformUtils.so.21.0git  lib/libMLIRSubsetOpInterface.so.21.0git  lib/libMLIRValueBoundsOpInterface.so.21.0git  lib/libMLIRDestinationStyleOpInterface.so.21.0git  lib/libMLIRMemorySlotInterfaces.so.21.0git  lib/libMLIRRuntimeVerifiableOpInterface.so.21.0git  lib/libMLIRUBDialect.so.21.0git  lib/libMLIRCastInterfaces.so.21.0git  lib/libMLIRRewrite.so.21.0git  lib/libMLIRRewritePDL.so.21.0git  lib/libMLIRPDLToPDLInterp.so.21.0git  lib/libMLIRPass.so.21.0git  lib/libMLIRAnalysis.so.21.0git  lib/libMLIRControlFlowInterfaces.so.21.0git  lib/libMLIRDataLayoutInterfaces.so.21.0git  lib/libMLIRLoopLikeInterface.so.21.0git  lib/libMLIRInferIntRangeInterface.so.21.0git  lib/libMLIRPresburger.so.21.0git  lib/libMLIRPDLInterpDialect.so.21.0git  lib/libMLIRFunctionInterfaces.so.21.0git  lib/libMLIRCallInterfaces.so.21.0git  lib/libMLIRPDLDialect.so.21.0git  lib/libMLIRInferTypeOpInterface.so.21.0git  lib/libMLIRSideEffectInterfaces.so.21.0git  lib/libMLIRTransformDialectUtils.so.21.0git  lib/libMLIRViewLikeInterface.so.21.0git  lib/libMLIRDialectUtils.so.21.0git  lib/libMLIRIR.so.21.0git  lib/libMLIRSupport.so.21.0git  lib/libLLVMSupport.so.21.0git  -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-sharedlibs/build/lib && :
/usr/bin/ld: tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o: in function `mlir::transform::ReplaceFuncSignatureOp::apply(mlir::transform::TransformRewriter&, mlir::transform::TransformResults&, mlir::transform::TransformState&)':
FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0x3a8): undefined reference to `mlir::func::replaceFuncWithNewOrder(mlir::RewriterBase&, mlir::func::FuncOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
/usr/bin/ld: FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0x438): undefined reference to `mlir::func::replaceCallOpWithNewOrder(mlir::RewriterBase&, mlir::func::CallOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 24, 2025

LLVM Buildbot has detected a new failure on builder flang-aarch64-latest-gcc running on linaro-flang-aarch64-latest-gcc while building mlir at step 5 "build-unified-tree".

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

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
1365.065 [850/33/6601] Linking CXX shared library lib/libMLIRNVGPUTestPasses.so.21.0git
1365.101 [850/32/6602] Linking CXX shared library lib/libMLIROpenACCToLLVMIRTranslation.so.21.0git
1365.102 [850/31/6603] Linking CXX shared library lib/libMLIRMathTestPasses.so.21.0git
1365.102 [850/30/6604] Linking CXX shared library lib/libMLIRMeshTest.so.21.0git
1365.102 [850/29/6605] Linking CXX shared library lib/libMLIRVectorToGPU.so.21.0git
1365.124 [850/28/6606] Linking CXX shared library lib/libMLIRSPIRVToLLVMIRTranslation.so.21.0git
1365.140 [850/27/6607] Linking CXX shared library lib/libMLIRTargetLLVM.so.21.0git
1365.271 [850/26/6608] Linking CXX shared library lib/libMLIRLLVMToLLVMIRTranslation.so.21.0git
1365.380 [850/25/6609] Linking CXX shared library lib/libMLIROpenMPToLLVM.so.21.0git
1365.381 [850/24/6610] Linking CXX shared library lib/libMLIRFuncTransformOps.so.21.0git
FAILED: lib/libMLIRFuncTransformOps.so.21.0git 
: && /usr/local/bin/c++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wundef -Wno-unused-but-set-parameter -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libMLIRFuncTransformOps.so.21.0git -o lib/libMLIRFuncTransformOps.so.21.0git tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/build/lib:"  lib/libMLIRFuncToLLVM.so.21.0git  lib/libMLIRTransformDialect.so.21.0git  lib/libMLIRArithToLLVM.so.21.0git  lib/libMLIRArithAttrToLLVMConversion.so.21.0git  lib/libMLIRArithTransforms.so.21.0git  lib/libMLIRBufferizationTransforms.so.21.0git  lib/libMLIRBufferizationDialect.so.21.0git  lib/libMLIRSparseTensorDialect.so.21.0git  lib/libMLIRSCFDialect.so.21.0git  lib/libMLIRFuncTransforms.so.21.0git  lib/libMLIRFuncDialect.so.21.0git  lib/libMLIRShardingInterface.so.21.0git  lib/libMLIRMeshDialect.so.21.0git  lib/libMLIRVectorDialect.so.21.0git  lib/libMLIRTensorDialect.so.21.0git  lib/libMLIRParallelCombiningOpInterface.so.21.0git  lib/libMLIRAffineDialect.so.21.0git  lib/libMLIRMemRefDialect.so.21.0git  lib/libMLIRArithUtils.so.21.0git  lib/libMLIRComplexDialect.so.21.0git  lib/libMLIRMaskableOpInterface.so.21.0git  lib/libMLIRMaskingOpInterface.so.21.0git  lib/libMLIRVectorInterfaces.so.21.0git  lib/libMLIRControlFlowToLLVM.so.21.0git  lib/libMLIRControlFlowDialect.so.21.0git  lib/libMLIRArithDialect.so.21.0git  lib/libMLIRDialect.so.21.0git  lib/libMLIRInferIntRangeCommon.so.21.0git  lib/libMLIRShapedOpInterfaces.so.21.0git  lib/libMLIRLLVMCommonConversion.so.21.0git  lib/libMLIRLLVMDialect.so.21.0git  lib/libLLVMBitWriter.so.21.0git  lib/libLLVMAsmParser.so.21.0git  lib/libLLVMBitReader.so.21.0git  lib/libLLVMCore.so.21.0git  lib/libLLVMBinaryFormat.so.21.0git  lib/libMLIRParser.so.21.0git  lib/libMLIRBytecodeReader.so.21.0git  lib/libMLIRAsmParser.so.21.0git  lib/libMLIRTransformDialectInterfaces.so.21.0git  lib/libMLIRTransforms.so.21.0git  lib/libMLIRTransformUtils.so.21.0git  lib/libMLIRSubsetOpInterface.so.21.0git  lib/libMLIRValueBoundsOpInterface.so.21.0git  lib/libMLIRDestinationStyleOpInterface.so.21.0git  lib/libMLIRMemorySlotInterfaces.so.21.0git  lib/libMLIRRuntimeVerifiableOpInterface.so.21.0git  lib/libMLIRUBDialect.so.21.0git  lib/libMLIRCastInterfaces.so.21.0git  lib/libMLIRRewrite.so.21.0git  lib/libMLIRRewritePDL.so.21.0git  lib/libMLIRPDLToPDLInterp.so.21.0git  lib/libMLIRPass.so.21.0git  lib/libMLIRAnalysis.so.21.0git  lib/libMLIRControlFlowInterfaces.so.21.0git  lib/libMLIRDataLayoutInterfaces.so.21.0git  lib/libMLIRLoopLikeInterface.so.21.0git  lib/libMLIRInferIntRangeInterface.so.21.0git  lib/libMLIRPresburger.so.21.0git  lib/libMLIRPDLInterpDialect.so.21.0git  lib/libMLIRFunctionInterfaces.so.21.0git  lib/libMLIRCallInterfaces.so.21.0git  lib/libMLIRPDLDialect.so.21.0git  lib/libMLIRInferTypeOpInterface.so.21.0git  lib/libMLIRSideEffectInterfaces.so.21.0git  lib/libMLIRTransformDialectUtils.so.21.0git  lib/libMLIRViewLikeInterface.so.21.0git  lib/libMLIRDialectUtils.so.21.0git  lib/libMLIRIR.so.21.0git  lib/libMLIRSupport.so.21.0git  lib/libLLVMSupport.so.21.0git  -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/build/lib && :
/usr/bin/ld: tools/mlir/lib/Dialect/Func/TransformOps/CMakeFiles/obj.MLIRFuncTransformOps.dir/FuncTransformOps.cpp.o: in function `mlir::transform::ReplaceFuncSignatureOp::apply(mlir::transform::TransformRewriter&, mlir::transform::TransformResults&, mlir::transform::TransformState&) [clone .localalias]':
FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0x1044): undefined reference to `mlir::func::replaceFuncWithNewOrder(mlir::RewriterBase&, mlir::func::FuncOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
/usr/bin/ld: FuncTransformOps.cpp:(.text._ZN4mlir9transform22ReplaceFuncSignatureOp5applyERNS0_17TransformRewriterERNS0_16TransformResultsERNS0_14TransformStateE+0x10d8): undefined reference to `mlir::func::replaceCallOpWithNewOrder(mlir::RewriterBase&, mlir::func::CallOp, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>)'
collect2: error: ld returned 1 exit status
1365.449 [850/23/6611] Linking CXX shared library lib/libMLIRROCDLToLLVMIRTranslation.so.21.0git
1365.487 [850/22/6612] Linking CXX shared library lib/libMLIRAsyncToLLVM.so.21.0git
1365.696 [850/21/6613] Linking CXX shared library lib/libMLIRVectorToLLVM.so.21.0git
1365.797 [850/20/6614] Linking CXX shared library lib/libMLIRSPIRVToLLVM.so.21.0git
1365.843 [850/19/6615] Linking CXX shared library lib/libMLIRArithTestPasses.so.21.0git
1365.846 [850/18/6616] Linking CXX shared library lib/libMLIROpenMPToLLVMIRTranslation.so.21.0git
1366.289 [850/17/6617] Linking CXX shared library lib/libFortranParser.so.21.0git
1368.043 [850/16/6618] Building CXX object tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/PFTBuilder.cpp.o
1370.819 [850/15/6619] Building CXX object tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/expression.cpp.o
1375.438 [850/14/6620] Building CXX object tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/ConvertExprToHLFIR.cpp.o
1376.288 [850/13/6621] Building CXX object tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenMP/DataSharingProcessor.cpp.o
1377.770 [850/12/6622] Building CXX object tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenMP/OpenMP.cpp.o
1386.422 [850/11/6623] Building CXX object tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenMP/Clauses.cpp.o
1386.802 [850/10/6624] Building CXX object tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenMP/Decomposer.cpp.o
1392.686 [850/9/6625] Building CXX object tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/fold-logical.cpp.o
1420.824 [850/8/6626] Building CXX object tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/semantics.cpp.o
1423.719 [850/7/6627] Building CXX object tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/resolve-names.cpp.o
1438.336 [850/6/6628] Building CXX object tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/fold-real.cpp.o
1453.043 [850/5/6629] Building CXX object tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/ConvertExpr.cpp.o
In file included from /usr/include/c++/13/string_view:40,
                 from /home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/llvm-project/flang/include/flang/Common/enum-class.h:22,
                 from /home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/llvm-project/flang/include/flang/Common/idioms.h:26,
                 from /home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/llvm-project/flang/include/flang/Common/indirection.h:23,
                 from /home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/llvm-project/flang/include/flang/Lower/Support/Utils.h:16,
                 from /home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/llvm-project/flang/include/flang/Lower/ConvertExpr.h:20,
                 from /home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/build/tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/cmake_pch.hxx:5,
                 from <command-line>:
In static member function ‘static std::char_traits<char>::char_type* std::char_traits<char>::copy(char_type*, const char_type*, std::size_t)’,
    inlined from ‘std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/13/bits/basic_string.h:672:23,
    inlined from ‘std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&) [with _CharT = char; _Traits = char_traits<char>; _Alloc = allocator<char>]’ at /usr/include/c++/13/bits/basic_string.h:3664:46,
    inlined from ‘void Fortran::semantics::DumpEvaluateExpr::Show(const Fortran::evaluate::Expr<RESULT>&) [with T = Fortran::evaluate::SomeKind<Fortran::common::TypeCategory::Complex>]’ at /home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/llvm-project/flang/include/flang/Semantics/dump-expr.h:202:11:
/usr/include/c++/13/bits/char_traits.h:445:56: warning: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ forming offset [32, 89] is out of the bounds [0, 32] of object ‘<anonymous>’ with type ‘std::__cxx11::basic_string<char>’ [-Warray-bounds=]
  445 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));

DrSergei pushed a commit to DrSergei/llvm-project that referenced this pull request Jun 24, 2025
…#143381)

This transform takes a module and a function name, and replaces the
signature of the function by reordering the arguments and results
according to the interchange arrays. The function is expected to be
defined in the module, and the interchange arrays must match the number
of arguments and results of the function.
anthonyhatran pushed a commit to anthonyhatran/llvm-project that referenced this pull request Jun 26, 2025
…#143381)

This transform takes a module and a function name, and replaces the
signature of the function by reordering the arguments and results
according to the interchange arrays. The function is expected to be
defined in the module, and the interchange arrays must match the number
of arguments and results of the function.
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.

4 participants