Skip to content

[mlir][EmitC] Add pass that combines all available emitc conversions #117549

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 14 commits into from
May 1, 2025

Conversation

simon-camp
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Nov 25, 2024

@llvm/pr-subscribers-mlir-func
@llvm/pr-subscribers-mlir-memref
@llvm/pr-subscribers-mlir-emitc

@llvm/pr-subscribers-mlir

Author: Simon Camphausen (simon-camp)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/117549.diff

8 Files Affected:

  • (added) mlir/include/mlir/Conversion/ConvertToEmitC/ConvertToEmitCPass.h (+22)
  • (modified) mlir/include/mlir/Conversion/Passes.h (+1)
  • (modified) mlir/include/mlir/Conversion/Passes.td (+14)
  • (modified) mlir/lib/Conversion/CMakeLists.txt (+1)
  • (added) mlir/lib/Conversion/ConvertToEmitC/CMakeLists.txt (+25)
  • (added) mlir/lib/Conversion/ConvertToEmitC/ConvertToEmitCPass.cpp (+77)
  • (added) mlir/test/Conversion/ConvertToEmitC/func-signature.mlir (+19)
  • (added) mlir/test/Conversion/ConvertToEmitC/tosa.mlir (+46)
diff --git a/mlir/include/mlir/Conversion/ConvertToEmitC/ConvertToEmitCPass.h b/mlir/include/mlir/Conversion/ConvertToEmitC/ConvertToEmitCPass.h
new file mode 100644
index 00000000000000..e6244276e6e680
--- /dev/null
+++ b/mlir/include/mlir/Conversion/ConvertToEmitC/ConvertToEmitCPass.h
@@ -0,0 +1,22 @@
+//===- ConvertToEmitCPass.h - Conversion to EmitC pass ----*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_CONVERSION_CONVERTTOEMITC_CONVERTTOEMITCPASS_H
+#define MLIR_CONVERSION_CONVERTTOEMITC_CONVERTTOEMITCPASS_H
+
+#include <memory>
+
+namespace mlir {
+class Pass;
+
+#define GEN_PASS_DECL_CONVERTTOEMITCPASS
+#include "mlir/Conversion/Passes.h.inc"
+
+} // namespace mlir
+
+#endif // MLIR_CONVERSION_CONVERTTOEMITC_CONVERTTOEMITCPASS_H
diff --git a/mlir/include/mlir/Conversion/Passes.h b/mlir/include/mlir/Conversion/Passes.h
index 2ab32836c80b1c..c9698a9985aca4 100644
--- a/mlir/include/mlir/Conversion/Passes.h
+++ b/mlir/include/mlir/Conversion/Passes.h
@@ -29,6 +29,7 @@
 #include "mlir/Conversion/ControlFlowToSCF/ControlFlowToSCF.h"
 #include "mlir/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRV.h"
 #include "mlir/Conversion/ControlFlowToSPIRV/ControlFlowToSPIRVPass.h"
+#include "mlir/Conversion/ConvertToEmitC/ConvertToEmitCPass.h"
 #include "mlir/Conversion/ConvertToLLVM/ToLLVMPass.h"
 #include "mlir/Conversion/ConvertToSPIRV/ConvertToSPIRVPass.h"
 #include "mlir/Conversion/FuncToEmitC/FuncToEmitCPass.h"
diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td
index 4d272ba219c6f1..167b78a683501a 100644
--- a/mlir/include/mlir/Conversion/Passes.td
+++ b/mlir/include/mlir/Conversion/Passes.td
@@ -12,6 +12,20 @@
 include "mlir/Pass/PassBase.td"
 
 
+//===----------------------------------------------------------------------===//
+// ToEmitC
+//===----------------------------------------------------------------------===//
+
+def ConvertToEmitCPass : Pass<"convert-to-emitc"> {
+  let summary = "Convert to EmitC dialect";
+  let description = [{
+    This is a generic pass to convert to the EmitC dialect.
+  }];
+  let dependentDialects = [
+    "emitc::EmitCDialect",
+  ];
+}
+
 //===----------------------------------------------------------------------===//
 // ToLLVM
 //===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Conversion/CMakeLists.txt b/mlir/lib/Conversion/CMakeLists.txt
index 6651d87162257f..bfee78a9624cb6 100644
--- a/mlir/lib/Conversion/CMakeLists.txt
+++ b/mlir/lib/Conversion/CMakeLists.txt
@@ -18,6 +18,7 @@ add_subdirectory(ComplexToStandard)
 add_subdirectory(ControlFlowToLLVM)
 add_subdirectory(ControlFlowToSCF)
 add_subdirectory(ControlFlowToSPIRV)
+add_subdirectory(ConvertToEmitC)
 add_subdirectory(ConvertToLLVM)
 add_subdirectory(ConvertToSPIRV)
 add_subdirectory(FuncToEmitC)
diff --git a/mlir/lib/Conversion/ConvertToEmitC/CMakeLists.txt b/mlir/lib/Conversion/ConvertToEmitC/CMakeLists.txt
new file mode 100644
index 00000000000000..3846f5a279a8a2
--- /dev/null
+++ b/mlir/lib/Conversion/ConvertToEmitC/CMakeLists.txt
@@ -0,0 +1,25 @@
+set(LLVM_OPTIONAL_SOURCES
+  ConvertToEmitCPass.cpp
+)
+
+add_mlir_conversion_library(MLIRConvertToEmitCPass
+  ConvertToEmitCPass.cpp
+
+  ADDITIONAL_HEADER_DIRS
+  ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/ConvertToEmitC
+
+  DEPENDS
+  MLIRConversionPassIncGen
+
+  LINK_LIBS PUBLIC
+  MLIRArithToEmitC
+  MLIRFuncToEmitC
+  MLIRIR
+  MLIRMemRefToEmitC
+  MLIRPass
+  MLIRRewrite
+  MLIRSCFToEmitC
+  MLIRSupport
+  MLIRTransforms
+  MLIRTransformUtils
+  )
diff --git a/mlir/lib/Conversion/ConvertToEmitC/ConvertToEmitCPass.cpp b/mlir/lib/Conversion/ConvertToEmitC/ConvertToEmitCPass.cpp
new file mode 100644
index 00000000000000..aeadb63e5faa2d
--- /dev/null
+++ b/mlir/lib/Conversion/ConvertToEmitC/ConvertToEmitCPass.cpp
@@ -0,0 +1,77 @@
+//===- ConvertToEmitCPass.cpp - MLIR EmitC Conversion ---------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Conversion/ConvertToEmitC/ConvertToEmitCPass.h"
+#include "mlir/Conversion/ArithToEmitC/ArithToEmitC.h"
+#include "mlir/Conversion/FuncToEmitC/FuncToEmitC.h"
+#include "mlir/Conversion/MemRefToEmitC/MemRefToEmitC.h"
+#include "mlir/Conversion/SCFToEmitC/SCFToEmitC.h"
+#include "mlir/Dialect/Arith/IR/Arith.h"
+#include "mlir/Dialect/EmitC/IR/EmitC.h"
+#include "mlir/Dialect/Func/IR/FuncOps.h"
+#include "mlir/Dialect/MemRef/IR/MemRef.h"
+#include "mlir/Dialect/SCF/IR/SCF.h"
+#include "mlir/IR/PatternMatch.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Rewrite/FrozenRewritePatternSet.h"
+#include "mlir/Transforms/DialectConversion.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+
+#define DEBUG_TYPE "convert-to-emitc"
+
+namespace mlir {
+#define GEN_PASS_DEF_CONVERTTOEMITCPASS
+#include "mlir/Conversion/Passes.h.inc"
+} // namespace mlir
+
+using namespace mlir;
+
+namespace {
+
+/// Populate patterns for each dialect.
+void populateConvertToEmitCPatterns(TypeConverter &typeConverter,
+                                    RewritePatternSet &patterns) {
+  populateArithToEmitCPatterns(typeConverter, patterns);
+  populateFuncToEmitCPatterns(patterns);
+  populateMemRefToEmitCTypeConversion(typeConverter);
+  populateMemRefToEmitCConversionPatterns(patterns, typeConverter);
+  populateSCFToEmitCConversionPatterns(patterns);
+  populateFunctionOpInterfaceTypeConversionPattern<emitc::FuncOp>(
+      patterns, typeConverter);
+}
+
+/// A pass to perform the SPIR-V conversion.
+struct ConvertToEmitCPass final
+    : impl::ConvertToEmitCPassBase<ConvertToEmitCPass> {
+  using ConvertToEmitCPassBase::ConvertToEmitCPassBase;
+
+  void runOnOperation() override {
+    Operation *op = getOperation();
+    MLIRContext *context = &getContext();
+
+    RewritePatternSet patterns(context);
+    TypeConverter typeConverter;
+    typeConverter.addConversion([](Type type) { return type; });
+
+    ConversionTarget target(*context);
+    target.addIllegalDialect<arith::ArithDialect, func::FuncDialect,
+                             memref::MemRefDialect, scf::SCFDialect>();
+    target.addLegalDialect<emitc::EmitCDialect>();
+    target.addDynamicallyLegalOp<emitc::FuncOp>(
+        [&typeConverter](emitc::FuncOp op) {
+          return typeConverter.isSignatureLegal(op.getFunctionType());
+        });
+
+    populateConvertToEmitCPatterns(typeConverter, patterns);
+    if (failed(applyPartialConversion(op, target, std::move(patterns))))
+      return signalPassFailure();
+    return;
+  }
+};
+
+} // namespace
diff --git a/mlir/test/Conversion/ConvertToEmitC/func-signature.mlir b/mlir/test/Conversion/ConvertToEmitC/func-signature.mlir
new file mode 100644
index 00000000000000..40b898919a7c22
--- /dev/null
+++ b/mlir/test/Conversion/ConvertToEmitC/func-signature.mlir
@@ -0,0 +1,19 @@
+// RUN: mlir-opt -convert-to-emitc %s | FileCheck %s
+
+// CHECK-LABEL emitc.func @int(%[[ARG:.*]]: i32)
+func.func @int(%arg0: i32) {
+    // CHECK: return
+    return
+}
+
+// CHECK-LABEL emitc.func @index(%[[ARG:.*]]: !emitc.size_t)
+func.func @index(%arg0: index) {
+    // CHECK: return
+    return
+}
+
+// CHECK-LABEL emitc.func @memref(%[[ARG:.*]]: !emitc.array<1xf32>)
+func.func @memref(%arg0: memref<1xf32>) {
+    // CHECK: return
+    return
+}
diff --git a/mlir/test/Conversion/ConvertToEmitC/tosa.mlir b/mlir/test/Conversion/ConvertToEmitC/tosa.mlir
new file mode 100644
index 00000000000000..4a7466bd04ba8b
--- /dev/null
+++ b/mlir/test/Conversion/ConvertToEmitC/tosa.mlir
@@ -0,0 +1,46 @@
+// DEFINE: %{pipeline} = "builtin.module(\
+// DEFINE:   func.func(\
+// DEFINE:     tosa-to-linalg\
+// DEFINE:   ),\
+// DEFINE:   one-shot-bufferize{\
+// DEFINE:     bufferize-function-boundaries\
+// DEFINE:     function-boundary-type-conversion=identity-layout-map\
+// DEFINE:     buffer-alignment=0\
+// DEFINE:   },\
+// DEFINE:   buffer-results-to-out-params{\
+// DEFINE:     hoist-static-allocs=true\
+// DEFINE:   },\
+// DEFINE:   func.func(\
+// DEFINE:     convert-linalg-to-loops\
+// DEFINE:   ),\
+// DEFINE:   canonicalize,\
+// DEFINE:   convert-to-emitc\
+// DEFINE: )"
+
+// RUN: mlir-opt --pass-pipeline=%{pipeline} %s | FileCheck %s
+
+// -----
+
+//      CHECK: emitc.func @main(%[[ARG0:.*]]: !emitc.array<2xf32>, %[[ARG1:.*]]: !emitc.array<2xf32>, %[[RES:.*]]: !emitc.array<2xf32>) {
+//  CHECK-DAG:   %[[C0:.*]] = "emitc.constant"() <{value = 0 : index}> : () -> !emitc.size_t
+//  CHECK-DAG:   %[[C1:.*]] = "emitc.constant"() <{value = 1 : index}> : () -> !emitc.size_t
+//  CHECK-DAG:   %[[C2:.*]] = "emitc.constant"() <{value = 2 : index}> : () -> !emitc.size_t
+//  CHECK-DAG:   %[[I0:.*]] = builtin.unrealized_conversion_cast %[[C0]] : !emitc.size_t to index
+//  CHECK-DAG:   %[[I1:.*]] = builtin.unrealized_conversion_cast %[[C1]] : !emitc.size_t to index
+//  CHECK-DAG:   %[[I2:.*]] = builtin.unrealized_conversion_cast %[[C2]] : !emitc.size_t to index
+// CHECK-NEXT:   for %[[INDEX:.*]] = %[[I0]] to %[[I2]] step %[[I1]] {
+// CHECK-NEXT:     %[[INDEX_S:.*]] = builtin.unrealized_conversion_cast %[[INDEX]] : index to !emitc.size_t
+// CHECK-NEXT:     %[[V0_LVALUE:.*]] = emitc.subscript %[[ARG0]][%[[INDEX_S]]] : (!emitc.array<2xf32>, !emitc.size_t) -> !emitc.lvalue<f32>
+// CHECK-NEXT:     %[[V0:.*]] = emitc.load %[[V0_LVALUE]] : <f32>
+// CHECK-NEXT:     %[[V1_LVALUE:.*]] = emitc.subscript %[[ARG1]][%[[INDEX_S]]] : (!emitc.array<2xf32>, !emitc.size_t) -> !emitc.lvalue<f32>
+// CHECK-NEXT:     %[[V1:.*]] = emitc.load %[[V1_LVALUE]] : <f32>
+// CHECK-NEXT:     %[[VADD:.*]] = emitc.add %[[V0]], %[[V1]] : (f32, f32) -> f32
+// CHECK-NEXT:     %[[RES_LVALUE:.*]] = emitc.subscript %[[RES]][%[[INDEX_S]]] : (!emitc.array<2xf32>, !emitc.size_t) -> !emitc.lvalue<f32>
+// CHECK-NEXT:     emitc.assign %[[VADD]] : f32 to %[[RES_LVALUE]] : <f32>
+// CHECK-NEXT:   }
+// CHECK-NEXT:   return
+// CHECK-NEXT: }
+func.func @main(%arg0: tensor<2xf32>, %arg1: tensor<2xf32>) -> tensor<2xf32> {
+  %0 = tosa.add %arg0, %arg1 : (tensor<2xf32>, tensor<2xf32>) -> tensor<2xf32>
+  return %0 : tensor<2xf32>
+}

func.func @memref(%arg0: memref<1xf32>) {
// CHECK: return
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also add one test each for the arith and scf dialects?

Copy link
Member

@marbre marbre left a comment

Choose a reason for hiding this comment

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

Nice! Some NITs.

Copy link

github-actions bot commented Nov 26, 2024

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

@@ -16,7 +16,7 @@ include "mlir/Pass/PassBase.td"
// ToEmitC
//===----------------------------------------------------------------------===//

def ConvertToEmitCPass : Pass<"convert-to-emitc"> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm confused because this PR says "Add pass ...." but here you're just using an existing pass?

Can you update the PR title and provide a description explaining the changes?

@ilovepi
Copy link
Contributor

ilovepi commented Jan 9, 2025

@simon-camp , now that #118940 is landed, are there any blockers to rebasing this work and following up w/ @joker-eph's suggestion?

@marbre
Copy link
Member

marbre commented Jan 22, 2025

@simon-camp , now that #118940 is landed, are there any blockers to rebasing this work and following up w/ @joker-eph's suggestion?

I think this is a private contribution now and I am not sure about resources on Simon's side.

@ilovepi
Copy link
Contributor

ilovepi commented Jan 22, 2025

@simon-camp , now that #118940 is landed, are there any blockers to rebasing this work and following up w/ @joker-eph's suggestion?

I think this is a private contribution now and I am not sure about resources on Simon's side.

Then it would be good to get clarity on if @simon-camp intends to continue this work, or if we should find someone who can take over, and if there are any remaining patches required before that work could continue.

@simon-camp
Copy link
Contributor Author

Hi, I will continue working in this next week.

@ilovepi
Copy link
Contributor

ilovepi commented Jan 22, 2025

@simon-camp Thanks for the clarification. Let me know if you want/need any help.

@ilovepi
Copy link
Contributor

ilovepi commented Feb 6, 2025

@simon-camp any progress to report?

@simon-camp
Copy link
Contributor Author

I have something partly working modelled Like the LLVM interface. I will push it tomorrow.

@ilovepi
Copy link
Contributor

ilovepi commented Feb 21, 2025

@simon-camp it seems like there are some issues with this patch, based on the test failures. I'm afraid I'm not familiar enough here to offer much advice, but it seems like some of the tests, like func.mlir expect some additional transform to happen to the function.

mlir-opt -convert-to-emitc mlir/test/Conversion/ConvertToEmitC/func.mlir 
|`FileCheck mlir/test/Conversion/ConvertToEmitC/func.mlir mlir/test/Conversion/ConvertToEmitC/func.mlir:18:5: error: 'emitc.return' op expects parent op 'emitc.func'
    return
    ^
mlir/test/Conversion/ConvertToEmitC/func.mlir:18:5: note: see current operation: "emitc.return"() : () -> ()
FileCheck error: '<stdin>' is empty.
FileCheck command line:  FileCheck mlir/test/Conversion/ConvertToEmitC/func.mlir

I've also looked at the EmitC output for the TOSA model. While the TOSA to EmitC test seems to be able to generate C code after being passed through mlir-translate, I'm a bit confused as to why it has a custom pass-pipeline? I thought that when this patch introduced --convert-to-emitc the other bits in the custom pipeline would no longer be necessary. If that's the case, then would the next step after this patch be to create a specialized pipeline for TOSA->EmitC, so that users don't need to specify a custom pipeline?

@marbre
Copy link
Member

marbre commented Feb 21, 2025

I've also looked at the EmitC output for the TOSA model. While the TOSA to EmitC test seems to be able to generate C code after being passed through mlir-translate, I'm a bit confused as to why it has a custom pass-pipeline? I thought that when this patch introduced --convert-to-emitc the other bits in the custom pipeline would no longer be necessary. If that's the case, then would the next step after this patch be to create a specialized pipeline for TOSA->EmitC, so that users don't need to specify a custom pipeline?

I assume with TOSA to EmitC you refer to what we provided with iml130/mlir-emitc (Public archive
)
? While that was a 1:1 conversion, there is such direct conversion from TOSA to EmitC upstream. One would rather need to convert TOSA to multiple upstream dialects. Those dialects (scf, memref, ...) can be converted to EmitC afterwards and that allows to translate to C. What this patch introduces is to convert all supported dialects to EmitC, however, a user would need to translate from TOSA (or any other dialerct) to those first. This is done in the mlir/test/Conversion/ConvertToEmitC/tosa.mlir test but such a pipeline is always custom and I would say beyond what is implemented here.

@simon-camp
Copy link
Contributor Author

@simon-camp it seems like there are some issues with this patch, based on the test failures. I'm afraid I'm not familiar enough here to offer much advice, but it seems like some of the tests, like func.mlir expect some additional transform to happen to the function.

mlir-opt -convert-to-emitc mlir/test/Conversion/ConvertToEmitC/func.mlir 
|`FileCheck mlir/test/Conversion/ConvertToEmitC/func.mlir mlir/test/Conversion/ConvertToEmitC/func.mlir:18:5: error: 'emitc.return' op expects parent op 'emitc.func'
    return
    ^
mlir/test/Conversion/ConvertToEmitC/func.mlir:18:5: note: see current operation: "emitc.return"() : () -> ()
FileCheck error: '<stdin>' is empty.
FileCheck command line:  FileCheck mlir/test/Conversion/ConvertToEmitC/func.mlir

This seems to be a layering issue. The memref->emitc type conversion is only available when the memref dialect is loaded. And that dialect is not loaded for the test. Nonetheless there are more failing tests I need to fix.

Copy link
Collaborator

@joker-eph joker-eph left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@joker-eph joker-eph requested a review from aniragil April 3, 2025 09:30
@joker-eph
Copy link
Collaborator

@marbre should probably also have another look here?

@marbre
Copy link
Member

marbre commented Apr 3, 2025

@marbre should probably also have another look here?

Sure, I free up some time to review latest early next week.

@mtrofin
Copy link
Member

mtrofin commented Apr 29, 2025

@marbre should probably also have another look here?

Sure, I free up some time to review latest early next week.

@marbre, others - would you terribly mind if I merged this PR - I want to build on it and it would be easier if it were merged. From the comments so far, I'm assuming you wouldn't have strong pushbacks on the PR, and we could address additional feedback after it merged, which I'm happy to take on. WDYT?

@joker-eph joker-eph requested a review from marbre April 30, 2025 12:40
Copy link
Member

@marbre marbre left a comment

Choose a reason for hiding this comment

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

Please excuse the delayed review. I am not familiar with all the details using the interface but looks overall pretty good to me. Just minor nits but feel free to land without further review.

@@ -73,6 +74,7 @@ void SCFDialect::initialize() {
#include "mlir/Dialect/SCF/IR/SCFOps.cpp.inc"
>();
addInterfaces<SCFInlinerInterface>();
declarePromisedInterface<ConvertToEmitCPatternInterface, SCFDialect>();
Copy link
Member

Choose a reason for hiding this comment

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

Might want to move this down before declarePromisedInterface<ValueBoundsOpInterface, ForOp>();?

Co-authored-by: Marius Brehler <[email protected]>
Copy link
Member

@jpienaar jpienaar left a comment

Choose a reason for hiding this comment

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

Nice, thanks!

@mtrofin
Copy link
Member

mtrofin commented May 1, 2025

Please excuse the delayed review. I am not familiar with all the details using the interface but looks overall pretty good to me. Just minor nits but feel free to land without further review.

Thanks! I'll go ahead and push the button, and follow up with a patch for bazel and any other cleanup. Very excited to build on EmitC!

@mtrofin mtrofin merged commit 0009a17 into llvm:main May 1, 2025
7 of 10 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented May 1, 2025

LLVM Buildbot has detected a new failure on builder flang-arm64-windows-msvc running on linaro-armv8-windows-msvc-01 while building mlir at step 5 "build-unified-tree".

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

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
  359 |       return {APFloat(*smt, value.real()), APFloat(*smt, value.imag())};
      |              ^
c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\complex(1302,5): note: 'complex' has been explicitly marked deprecated here
 1302 |     _DEPRECATE_NONFLOATING_COMPLEX
      |     ^
c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\yvals_core.h(1408,7): note: expanded from macro '_DEPRECATE_NONFLOATING_COMPLEX'
 1408 |     [[deprecated("warning STL4037: "                                                   \
      |       ^
1 warning generated.
4554.605 [1228/10/5998] Building CXX object tools\mlir\lib\Conversion\ConvertToEmitC\CMakeFiles\obj.MLIRConvertToEmitC.dir\ConvertToEmitCPass.cpp.obj
FAILED: tools/mlir/lib/Conversion/ConvertToEmitC/CMakeFiles/obj.MLIRConvertToEmitC.dir/ConvertToEmitCPass.cpp.obj 
ccache C:\Users\tcwg\scoop\apps\llvm-arm64\current\bin\clang-cl.exe  /nologo -TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\tools\mlir\lib\Conversion\ConvertToEmitC -IC:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\lib\Conversion\ConvertToEmitC -IC:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\tools\mlir\include -IC:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\include -IC:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\include -IC:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\llvm\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:__cplusplus /Oi /Brepro /bigobj /permissive- -Werror=unguarded-availability-new /W4  -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported /Gw -Wundef -Werror=mismatched-tags -Werror=global-constructors /O2 /Ob2  -std:c++17 -MD  /EHs-c- /GR- -UNDEBUG /showIncludes /Fotools\mlir\lib\Conversion\ConvertToEmitC\CMakeFiles\obj.MLIRConvertToEmitC.dir\ConvertToEmitCPass.cpp.obj /Fdtools\mlir\lib\Conversion\ConvertToEmitC\CMakeFiles\obj.MLIRConvertToEmitC.dir\ -c -- C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\lib\Conversion\ConvertToEmitC\ConvertToEmitCPass.cpp
In file included from C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\lib\Conversion\ConvertToEmitC\ConvertToEmitCPass.cpp:9:
In file included from C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\include\mlir/Conversion/ConvertToEmitC/ConvertToEmitCPass.h:20:
C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\build\tools\mlir\include\mlir/Conversion/Passes.h.inc(4285,28): error: no member named 'string' in namespace 'std'
 4285 |   ::llvm::SmallVector<std::string> filterDialects;
      |                       ~~~~~^
In file included from C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\lib\Conversion\ConvertToEmitC\ConvertToEmitCPass.cpp:11:
In file included from C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\include\mlir/Conversion/ConvertToEmitC/ToEmitCInterface.h:14:
In file included from C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\include\mlir/IR/OpDefinition.h:22:
In file included from C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\include\mlir/IR/Dialect.h:17:
In file included from C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\include\mlir/IR/OperationSupport.h:19:
C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\include\mlir/IR/BuiltinAttributes.h(359,14): warning: 'complex' is deprecated: warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning. [-Wdeprecated-declarations]
  359 |       return {APFloat(*smt, value.real()), APFloat(*smt, value.imag())};
      |              ^
c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\complex(1302,5): note: 'complex' has been explicitly marked deprecated here
 1302 |     _DEPRECATE_NONFLOATING_COMPLEX
      |     ^
c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\yvals_core.h(1408,7): note: expanded from macro '_DEPRECATE_NONFLOATING_COMPLEX'
 1408 |     [[deprecated("warning STL4037: "                                                   \
      |       ^
1 warning and 1 error generated.
4555.256 [1228/9/5999] Building CXX object tools\mlir\lib\Conversion\ControlFlowToSCF\CMakeFiles\obj.MLIRControlFlowToSCF.dir\ControlFlowToSCF.cpp.obj
In file included from C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\lib\Conversion\ControlFlowToSCF\ControlFlowToSCF.cpp:13:
In file included from C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\include\mlir/Conversion/ControlFlowToSCF/ControlFlowToSCF.h:18:
In file included from C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\include\mlir/Transforms/CFGToSCF.h:18:
In file included from C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\include\mlir/IR/Builders.h:12:
In file included from C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\include\mlir/IR/OpDefinition.h:22:
In file included from C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\include\mlir/IR/Dialect.h:17:
In file included from C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\include\mlir/IR/OperationSupport.h:19:
C:\Users\tcwg\llvm-worker\flang-arm64-windows-msvc\llvm-project\mlir\include\mlir/IR/BuiltinAttributes.h(359,14): warning: 'complex' is deprecated: warning STL4037: The effect of instantiating the template std::complex for any type other than float, double, or long double is unspecified. You can define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING to suppress this warning. [-Wdeprecated-declarations]
  359 |       return {APFloat(*smt, value.real()), APFloat(*smt, value.imag())};
      |              ^
c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\complex(1302,5): note: 'complex' has been explicitly marked deprecated here
 1302 |     _DEPRECATE_NONFLOATING_COMPLEX
      |     ^
c:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.37.32822\include\yvals_core.h(1408,7): note: expanded from macro '_DEPRECATE_NONFLOATING_COMPLEX'
 1408 |     [[deprecated("warning STL4037: "                                                   \
      |       ^

mtrofin added a commit that referenced this pull request May 1, 2025
Follow-up from #117549

tested by:

```
cd utils/bazel
bazelisk build --config=generic_clang @llvm-project//mlir:all
bazelisk test --config=generic_clang @llvm-project//mlir/test:all
```
@kazutakahirata
Copy link
Contributor

@simon-camp @mtrofin I've landed 514b853 to fix the mlir build under -DCMAKE_CXX_FLAGS="-stdlib=libc++". Thanks!

@marbre
Copy link
Member

marbre commented May 2, 2025

@simon-camp @mtrofin I've landed 514b853 to fix the mlir build under -DCMAKE_CXX_FLAGS="-stdlib=libc++". Thanks!

Thanks!

IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Follow-up from llvm#117549

tested by:

```
cd utils/bazel
bazelisk build --config=generic_clang @llvm-project//mlir:all
bazelisk test --config=generic_clang @llvm-project//mlir/test:all
```
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Follow-up from llvm#117549

tested by:

```
cd utils/bazel
bazelisk build --config=generic_clang @llvm-project//mlir:all
bazelisk test --config=generic_clang @llvm-project//mlir/test:all
```
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Follow-up from llvm#117549

tested by:

```
cd utils/bazel
bazelisk build --config=generic_clang @llvm-project//mlir:all
bazelisk test --config=generic_clang @llvm-project//mlir/test:all
```
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
Follow-up from llvm#117549

tested by:

```
cd utils/bazel
bazelisk build --config=generic_clang @llvm-project//mlir:all
bazelisk test --config=generic_clang @llvm-project//mlir/test:all
```
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 2025
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 2025
Follow-up from llvm#117549

tested by:

```
cd utils/bazel
bazelisk build --config=generic_clang @llvm-project//mlir:all
bazelisk test --config=generic_clang @llvm-project//mlir/test:all
```
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.