This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Presburger] Disambiguate call to floor
ClosedPublic

Authored by ro on Feb 9 2022, 3:49 AM.

Details

Summary

While testing LLVM 14.0.0 rc1 on Solaris, compilation of FAILed with

/var/llvm/llvm-14.0.0-rc1/rc1/llvm-project/mlir/lib/Analysis/Presburger/Utils.cpp: In lambda function:
/var/llvm/llvm-14.0.0-rc1/rc1/llvm-project/mlir/lib/Analysis/Presburger/Utils.cpp:48:58: error: call of overloaded ‘floor(int64_t)’ is ambiguous
   48 |                  [gcd](int64_t &n) { return floor(n / gcd); });
      |                                                          ^
...
/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.3.0/include-fixed/iso/math_iso.h:201:21: note: candidate: ‘long double std::floor(long double)’
  201 |  inline long double floor(long double __X) { return __floorl(__X); }
      |                     ^~~~~
/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.3.0/include-fixed/iso/math_iso.h:165:15: note: candidate: ‘float std::floor(float)’
  165 |  inline float floor(float __X) { return __floorf(__X); }
      |               ^~~~~
/usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.3.0/include-fixed/iso/math_iso.h:78:15: note: candidate: ‘double std::floor(double)’
   78 | extern double floor __P((double));
      |               ^~~~~

The same issue had already occured in the past, cf. D108750, and the solution is the same: cast the floor arg to double.

Tested on amd64-pc-solaris2.11 and sparcv9-sun-solaris2.11.

Obviously this should also be backported to the release/14.x branch.

Diff Detail

Event Timeline

ro created this revision.Feb 9 2022, 3:49 AM
ro requested review of this revision.Feb 9 2022, 3:49 AM
arjunp accepted this revision.Feb 9 2022, 10:05 AM
arjunp added inline comments.
mlir/lib/Analysis/Presburger/Utils.cpp
48

This code should have used floorDiv to floor divide n by gcd. That also resolves the ambiguity issue, I think. If you would like to go ahead with the patch as-is for fixing the build, I'm also happy to fix the logic later in another patch.

This revision is now accepted and ready to land.Feb 9 2022, 10:05 AM
This revision was automatically updated to reflect the committed changes.
ro added inline comments.Feb 9 2022, 1:03 PM
mlir/lib/Analysis/Presburger/Utils.cpp
48

I've decided to install the patch as is to quickly restore the build.