[Mlir-commits] [mlir] [mlir][Presburger] Fix inlining failure for dynamicAPIntFromInt64 in debug builds (PR #194820)

lonely eagle llvmlistbot at llvm.org
Wed Apr 29 03:13:07 PDT 2026


https://github.com/linuxlonelyeagle updated https://github.com/llvm/llvm-project/pull/194820

>From 841b6a067b58505b8fd23d6c21cc3362b4a536fc Mon Sep 17 00:00:00 2001
From: linuxlonelyeagle <2020382038 at qq.com>
Date: Wed, 29 Apr 2026 09:04:43 +0000
Subject: [PATCH 1/2] fix llvm debug build.

---
 mlir/lib/Analysis/Presburger/Utils.cpp     | 4 +++-
 mlir/unittests/Analysis/Presburger/Utils.h | 6 +++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/mlir/lib/Analysis/Presburger/Utils.cpp b/mlir/lib/Analysis/Presburger/Utils.cpp
index b06a8a1b9ccf8..493dcdadc727c 100644
--- a/mlir/lib/Analysis/Presburger/Utils.cpp
+++ b/mlir/lib/Analysis/Presburger/Utils.cpp
@@ -521,7 +521,9 @@ void DivisionRepr::dump() const { print(llvm::errs()); }
 SmallVector<DynamicAPInt, 8>
 presburger::getDynamicAPIntVec(ArrayRef<int64_t> range) {
   SmallVector<DynamicAPInt, 8> result(range.size());
-  llvm::transform(range, result.begin(), dynamicAPIntFromInt64);
+  // llvm::transform(range, result.begin(), dynamicAPIntFromInt64);
+  llvm::transform(range, result.begin(),
+                  [](int64_t x) { return dynamicAPIntFromInt64(x); });
   return result;
 }
 
diff --git a/mlir/unittests/Analysis/Presburger/Utils.h b/mlir/unittests/Analysis/Presburger/Utils.h
index 58b9267168540..d92819119278a 100644
--- a/mlir/unittests/Analysis/Presburger/Utils.h
+++ b/mlir/unittests/Analysis/Presburger/Utils.h
@@ -153,10 +153,10 @@ inline void expectComputedVolumeIsValidOverapprox(
 inline void expectComputedVolumeIsValidOverapprox(
     const std::optional<DynamicAPInt> &computedVolume,
     std::optional<int64_t> trueVolume, std::optional<int64_t> resultBound) {
+  auto getDynamicAPInt = [](int64_t x) { return dynamicAPIntFromInt64(x); };
   expectComputedVolumeIsValidOverapprox(
-      computedVolume,
-      llvm::transformOptional(trueVolume, dynamicAPIntFromInt64),
-      llvm::transformOptional(resultBound, dynamicAPIntFromInt64));
+      computedVolume, llvm::transformOptional(trueVolume, getDynamicAPInt),
+      llvm::transformOptional(resultBound, getDynamicAPInt));
 }
 
 } // namespace presburger

>From c1c463bf0b5acb5fabbee4122b106e2d26f3c1fc Mon Sep 17 00:00:00 2001
From: linuxlonelyeagle <2020382038 at qq.com>
Date: Wed, 29 Apr 2026 10:12:52 +0000
Subject: [PATCH 2/2] add comment.

---
 mlir/lib/Analysis/Presburger/Utils.cpp     | 3 ++-
 mlir/unittests/Analysis/Presburger/Utils.h | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/mlir/lib/Analysis/Presburger/Utils.cpp b/mlir/lib/Analysis/Presburger/Utils.cpp
index 493dcdadc727c..a06a854fd1426 100644
--- a/mlir/lib/Analysis/Presburger/Utils.cpp
+++ b/mlir/lib/Analysis/Presburger/Utils.cpp
@@ -521,7 +521,8 @@ void DivisionRepr::dump() const { print(llvm::errs()); }
 SmallVector<DynamicAPInt, 8>
 presburger::getDynamicAPIntVec(ArrayRef<int64_t> range) {
   SmallVector<DynamicAPInt, 8> result(range.size());
-  // llvm::transform(range, result.begin(), dynamicAPIntFromInt64);
+  // Wrapping dynamicAPIntFromInt64 in a lambda, turning the indirect call into
+  // a direct call that the compiler can inline at the call site.
   llvm::transform(range, result.begin(),
                   [](int64_t x) { return dynamicAPIntFromInt64(x); });
   return result;
diff --git a/mlir/unittests/Analysis/Presburger/Utils.h b/mlir/unittests/Analysis/Presburger/Utils.h
index d92819119278a..ef4355f9e3805 100644
--- a/mlir/unittests/Analysis/Presburger/Utils.h
+++ b/mlir/unittests/Analysis/Presburger/Utils.h
@@ -153,6 +153,8 @@ inline void expectComputedVolumeIsValidOverapprox(
 inline void expectComputedVolumeIsValidOverapprox(
     const std::optional<DynamicAPInt> &computedVolume,
     std::optional<int64_t> trueVolume, std::optional<int64_t> resultBound) {
+  // Wrapping dynamicAPIntFromInt64 in a lambda, turning the indirect call into
+  // a direct call that the compiler can inline at the call site.
   auto getDynamicAPInt = [](int64_t x) { return dynamicAPIntFromInt64(x); };
   expectComputedVolumeIsValidOverapprox(
       computedVolume, llvm::transformOptional(trueVolume, getDynamicAPInt),



More information about the Mlir-commits mailing list