[Mlir-commits] [mlir] [mlir][capi] Fix non-portable int64_t printf formatting in greedy rewrite config test (PR #175487)
Alexandre Eberhardt
llvmlistbot at llvm.org
Sat Jan 17 08:54:48 PST 2026
https://github.com/alexandreeberhardt updated https://github.com/llvm/llvm-project/pull/175487
>From 8af049dff7dd2c24b3449d972f4cc19bec180ba7 Mon Sep 17 00:00:00 2001
From: alexandre <alexandre.eber07 at gmail.com>
Date: Mon, 12 Jan 2026 00:20:22 -0500
Subject: [PATCH 1/2] [mlir][capi] Fix non-portable int64_t printf formatting
in greedy rewrite config test
The C-API test prints int64_t values using %ld, which is not portable on LLP64
platforms (Windows or some MacOS configurations) where long is 32-bit. Use <inttypes.h> and PRId64 to
print int64_t portably.
Test: ninja check-mlir
---
mlir/test/CAPI/rewrite.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mlir/test/CAPI/rewrite.c b/mlir/test/CAPI/rewrite.c
index 0745eb496c1d7..5795646be544f 100644
--- a/mlir/test/CAPI/rewrite.c
+++ b/mlir/test/CAPI/rewrite.c
@@ -14,8 +14,10 @@
#include "mlir-c/IR.h"
#include <assert.h>
+#include <inttypes.h>
#include <stdio.h>
+
MlirOperation createOperationWithName(MlirContext ctx, const char *name) {
MlirStringRef nameRef = mlirStringRefCreateFromCString(name);
MlirLocation loc = mlirLocationUnknownGet(ctx);
@@ -554,10 +556,10 @@ void testGreedyRewriteDriverConfig(MlirContext ctx) {
// Test all configuration getters and verify values
// CHECK: MaxIterations: 5
- fprintf(stderr, "MaxIterations: %ld\n",
+ fprintf(stderr, "MaxIterations: %" PRId64 "\n",
mlirGreedyRewriteDriverConfigGetMaxIterations(config));
// CHECK: MaxNumRewrites: 100
- fprintf(stderr, "MaxNumRewrites: %ld\n",
+ fprintf(stderr, "MaxNumRewrites: %" PRId64 "\n",
mlirGreedyRewriteDriverConfigGetMaxNumRewrites(config));
// CHECK: UseTopDownTraversal: 1
fprintf(stderr, "UseTopDownTraversal: %d\n",
>From dca0aeb202700f59c470ceef65cbdc814356f0f8 Mon Sep 17 00:00:00 2001
From: alexandre <alexandre.eber07 at gmail.com>
Date: Mon, 12 Jan 2026 00:30:18 -0500
Subject: [PATCH 2/2] Remove extra newline
---
mlir/test/CAPI/rewrite.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/mlir/test/CAPI/rewrite.c b/mlir/test/CAPI/rewrite.c
index 5795646be544f..48d70579fa325 100644
--- a/mlir/test/CAPI/rewrite.c
+++ b/mlir/test/CAPI/rewrite.c
@@ -17,7 +17,6 @@
#include <inttypes.h>
#include <stdio.h>
-
MlirOperation createOperationWithName(MlirContext ctx, const char *name) {
MlirStringRef nameRef = mlirStringRefCreateFromCString(name);
MlirLocation loc = mlirLocationUnknownGet(ctx);
More information about the Mlir-commits
mailing list