[PATCH] D98427: Fix util/benchmark build or less mainstream architectures, like Alpha, HPPA, IA64, ...

René Rebe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 11 07:28:16 PST 2021


rener created this revision.
Herald added subscribers: lebedev.ri, atanasyan, arichardson, sdardis.
Herald added a reviewer: lebedev.ri.
rener requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Currently utils/benchmark/src/cycleclock.h timing defines error out for unsupported architectures. However, some Linux distributions like T2 (https://t2sde.org) still somewhat support, and even cross compile Alpha, HPPA, IA64, Motorola 68k, and llvm is needed for Mesa 3d, BPF, etc.

Simply fix the build by moving the MIPS gettimeofday fallback to the last else case to fix building for most non mainstream architecture where the C++ codebase otherwise just compiles fine, too ;-)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98427

Files:
  llvm-12.0.0rc3.src/utils/benchmark/src/cycleclock.h


Index: llvm-12.0.0rc3.src/utils/benchmark/src/cycleclock.h
===================================================================
--- llvm-12.0.0rc3.src/utils/benchmark/src/cycleclock.h
+++ llvm-12.0.0rc3.src/utils/benchmark/src/cycleclock.h
@@ -161,12 +161,6 @@
   struct timeval tv;
   gettimeofday(&tv, nullptr);
   return static_cast<int64_t>(tv.tv_sec) * 1000000 + tv.tv_usec;
-#elif defined(__mips__) || defined(__m68k__)
-  // mips apparently only allows rdtsc for superusers, so we fall
-  // back to gettimeofday.  It's possible clock_gettime would be better.
-  struct timeval tv;
-  gettimeofday(&tv, nullptr);
-  return static_cast<int64_t>(tv.tv_sec) * 1000000 + tv.tv_usec;
 #elif defined(__s390__) // Covers both s390 and s390x.
   // Return the CPU clock.
   uint64_t tsc;
@@ -194,10 +188,14 @@
   return cycles;
 #endif
 #else
-// The soft failover to a generic implementation is automatic only for ARM.
-// For other platforms the developer is expected to make an attempt to create
-// a fast implementation and use generic version if nothing better is available.
-#error You need to define CycleTimer for your OS and CPU
+  // The soft failover to a generic implementation is automatic only for ARM.
+  // For other platforms the developer is expected to make an attempt to create
+  // a fast implementation and use generic version if nothing better is available.
+  // MIPS apparently only allows rdtsc for superusers, so for it and other
+  // fall back to gettimeofday. It's possible clock_gettime would be better.
+  struct timeval tv;
+  gettimeofday(&tv, nullptr);
+  return static_cast<int64_t>(tv.tv_sec) * 1000000 + tv.tv_usec;
 #endif
 }
 }  // end namespace cycleclock


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98427.329963.patch
Type: text/x-patch
Size: 1697 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210311/90cbb135/attachment.bin>


More information about the llvm-commits mailing list