Skip to content

MLIR Mesh dialect badly broke MLIR and Flang on Solaris #69310

@rorth

Description

@rorth

Between 20231006 and 20231016, 1800+ test failures appeared on Solaris (both amd64 and sparcv9) in the MLIR and Flang testsuites. The failure mode is always the same:

FAIL: Flang :: Driver/bbc-openmp-version-macro.f90 (21590 of 79241)

expected:

{{.*}} = arith.constant 199911 : i32

found:

%c199911_i32 = arith.constant32199911 : i32

i.e. where a ' ' is expected, and integer (32) is printed.

A reghunt identified this patch

commit 08545e85167a105b8147d76a48a2fa1eac0f9e9a
Author: Chengji Yao <[email protected]>
Date:   Tue Oct 10 11:35:40 2023 -0700

    [MLIR] Add a new Mesh dialect (#68007)

as the culprit. Clearly this snippet makes unwarranted assumptions and causes the breakage:

diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpIm
plementation.h
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -366,6 +367,17 @@ operator<<(AsmPrinterT &p, bool value) {
   return p << (value ? StringRef("true") : "false");
 }
 
+/// Specialization for 8-bit integers to ensure values are printed as integers
+// and not characters.
+template <
+    typename AsmPrinterT, typename T,
+    std::enable_if_t<llvm::is_one_of<T, int8_t, uint8_t>::value, T> * = nullptr>
+inline std::enable_if_t<std::is_base_of<AsmPrinter, AsmPrinterT>::value,
+                        AsmPrinterT &>
+operator<<(AsmPrinterT &p, T value) {
+  return p << static_cast<int16_t>(value);
+}

However, char is signed on Solaris, so every character is printed as integer!

For some reason, I'm not able to assign this Issue to the author, so I'm trying this here: @yaochengji

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions