Page MenuHomePhabricator

[Polly] Fix lib/Transform/ScheduleOptimizer.cpp compilation on Solaris
ClosedPublic

Authored by ro on Sep 11 2019, 6:06 AM.

Details

Summary

lib/Transform/ScheduleOptimizer.cpp fails to compile on Solaris, both on the 9.x
branch (first noticed when running test-release.sh without -no-polly) and on trunk:

/var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp: In function ‘MicroKernelParamsTy getMicroKernelParams(const llvm::TargetTransformInfo*, polly::MatMulInfoTy)’:
/var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp:914:62: error: call of overloaded ‘sqrt(long unsigned int)’ is ambiguous
  914 |       ceil(sqrt(Nvec * LatencyVectorFma * ThroughputVectorFma) / Nvec) * Nvec;
      |                                                              ^
In file included from /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/math.h:24,
                 from /usr/gcc/9/include/c++/9.1.0/cmath:45,
                 from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm-c/DataTypes.h:28,
                 from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/Support/DataTypes.h:16,
                 from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/ADT/Hashing.h:47,
                 from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/ADT/ArrayRef.h:12,
                 from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/include/polly/ScheduleOptimizer.h:12,
                 from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp:48:
/usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:220:21: note: candidate: ‘long double std::sqrt(long double)’
  220 |  inline long double sqrt(long double __X) { return __sqrtl(__X); }
      |                     ^~~~
/usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:186:15: note: candidate: ‘float std::sqrt(float)’
  186 |  inline float sqrt(float __X) { return __sqrtf(__X); }
      |               ^~~~
/usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:74:15: note: candidate: ‘double std::sqrt(double)’
   74 | extern double sqrt __P((double));
      |               ^~~~
/var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp:915:67: error: call of overloaded ‘ceil(long unsigned int)’ is ambiguous
  915 |   int Mr = ceil(Nvec * LatencyVectorFma * ThroughputVectorFma / Nr);
      |                                                                   ^
In file included from /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/math.h:24,
                 from /usr/gcc/9/include/c++/9.1.0/cmath:45,
                 from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm-c/DataTypes.h:28,
                 from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/Support/DataTypes.h:16,
                 from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/ADT/Hashing.h:47,
                 from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/ADT/ArrayRef.h:12,
                 from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/include/polly/ScheduleOptimizer.h:12,
                 from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp:48:
/usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:196:21: note: candidate: ‘long double std::ceil(long double)’
  196 |  inline long double ceil(long double __X) { return __ceill(__X); }
      |                     ^~~~
/usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:160:15: note: candidate: ‘float std::ceil(float)’
  160 |  inline float ceil(float __X) { return __ceilf(__X); }
      |               ^~~~
/usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:76:15: note: candidate: ‘double std::ceil(double)’
   76 | extern double ceil __P((double));
      |               ^~~~

Fixed by adding casts to disambiguate, checked that it now compiles on both
amd64-pc-solaris2.11 and sparcv9-sun-solaris2.11 and on x86_64-pc-linux-gnu.

Ok for trunk?

Diff Detail

Repository
rL LLVM

Event Timeline

ro created this revision.Sep 11 2019, 6:06 AM
Meinersbur accepted this revision.Sep 12 2019, 7:37 PM
Meinersbur added a subscriber: Meinersbur.

According to https://en.cppreference.com/w/cpp/numeric/math/sqrt. there should be long overloads of sqrt/ceil. However, there only case the argument to double, so this patch is a NFC compile fix.

If you need someone to commit this patch please add a comment saying so.

This revision is now accepted and ready to land.Sep 12 2019, 7:37 PM
This revision was automatically updated to reflect the committed changes.