<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/56850>56850</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            mlir/lib/Analysis/Presburger/Utils.cpp doesn't compile with GCC 11
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          rorth
      </td>
    </tr>
</table>

<pre>
    When building LLVM 15.0.0 rc1 on Solaris 11.4/sparcv9 (`sparcv9-sun-solaris2.11`), I ran into the following error:
```
In file included from /var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/mlir/include/mlir/Analysis/Presburger/Utils.h:16,
                 from /var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/mlir/lib/Analysis/Presburger/Utils.cpp:13:
/var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/mlir/include/mlir/Analysis/Presburger/MPInt.h: In function ‘llvm::SmallVector<long int, 8> mli
r::presburger::getInt64Vec(llvm::ArrayRef<mlir::presburger::MPInt>)’:
/var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/mlir/include/mlir/Analysis/Presburger/MPInt.h:260:47: error: inlining failed in call t
o ‘always_inline’ ‘int64_t mlir::presburger::int64FromMPInt(const mlir::presburger::MPInt&)’: indirect function call with a yet undetermined callee
  260 | LLVM_ATTRIBUTE_ALWAYS_INLINE int64_t int64FromMPInt(const MP
KInt &x) {
      |                                               ^~~~~~~~~~~~~~

In file included from /usr/gcc/11/include/c++/11.3.0/algorithm:62,
                 from /var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/llvm/include/llvm/ADT/Hashing.h:51,
                 from /var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/llvm/include/llvm/ADT/Optional.h:19,
                 from /var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/llvm/include/llvm/Support/Casting.h:17,
                 from /var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/mlir/include/mlir/Support/LLVM.h:24,
                 from /var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/mlir/include/mlir/Support/MathExtras.h:16,
                 from /var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/mlir/include/mlir/Analysis/Presburger/SlowMPInt.h:21,
                 from /var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/mlir/include/mlir/Analysis/Presburger/MPInt.h:19,
                 from /var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/mlir/include/mlir/Analysis/Presburger/Utils.h:16,
                 from /var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/mlir/lib/Analysis/Presburger/Utils.cpp:13:
/usr/gcc/11/include/c++/11.3.0/bits/stl_algo.h:4296:31: note: called from here
 4296 |         *__result = __unary_op(*__first);
      |                     ~~~~~~~~~~^~~~~~~~~~
```
This happens with the bundled GCC 11.3.0 as well as 12.1.0, but doesn't occur on Solaris 11.4/amd64 (`amd64-pc-solaris2.11`).

I hacked around the issue by replacing `LLVM_ATTRIBUTE_ALWAYS_INLINE` with `static inline`:
```--- /vol/llvm/src/llvm-project/dist-15.x.git/mlir/include/mlir/Analysis/Presburger/MPInt.h   2022-07-27 09:50:12.428119000 +0200
+++ mlir/include/mlir/Analysis/Presburger/MPInt.h       2022-07-31 11:03:19.950829015 +0200
@@ -257,7 +257,7 @@
 /// This just calls through to the operator int64_t, but it's useful when a
 /// function pointer is required. (Although this is marked inline, it is still
 /// possible to obtain and use a function pointer to this.)
-LLVM_ATTRIBUTE_ALWAYS_INLINE int64_t int64FromMPInt(const MPInt &x) {
+static inline int64_t int64FromMPInt(const MPInt &x) {
   return int64_t(x);
 }
 LLVM_ATTRIBUTE_ALWAYS_INLINE MPInt mpintFromInt64(int64_t x) {
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzdV9ly2zYU_R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