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

lonely eagle llvmlistbot at llvm.org
Wed Apr 29 02:09:23 PDT 2026


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

When `dynamicAPIntFromInt64` is passed as a function pointer to `llvm::transform`, it becomes an indirect call. This causes the compiler to fail to inline the function despite the `LLVM_ATTRIBUTE_ALWAYS_INLINE` annotation, resulting in a compilation error in debug builds: 
```
error: inlining failed in call to 'always_inline' 'llvm::DynamicAPInt llvm::dynamicAPIntFromInt64(int64_t)': indirect function call with a yet undetermined callee
  250 | LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt dynamicAPIntFromInt64(int64_t X) {
```

Fix this by wrapping `dynamicAPIntFromInt64` in a lambda, turning the indirect call into a direct call that the compiler can inline at the call site.

>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] 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



More information about the Mlir-commits mailing list