[STATS] Properly guard the tick_time() function and its uses

llvm-svn: 255910
GitOrigin-RevId: 8b524597efcef4ff37f667195516e468be66da6f
diff --git a/runtime/src/kmp_os.h b/runtime/src/kmp_os.h
index 2c330fc..4f89c73 100644
--- a/runtime/src/kmp_os.h
+++ b/runtime/src/kmp_os.h
@@ -703,6 +703,11 @@
 # define KMP_USE_ADAPTIVE_LOCKS KMP_USE_TSX
 #endif
 
+// Enable tick time conversion of ticks to seconds
+#if KMP_STATS_ENABLED
+# define KMP_HAVE_TICK_TIME (KMP_OS_LINUX && (KMP_MIC || KMP_ARCH_X86 || KMP_ARCH_X86_64))
+#endif
+
 // Warning levels
 enum kmp_warnings_level {
     kmp_warnings_off = 0,		/* No warnings */
diff --git a/runtime/src/kmp_stats_timing.cpp b/runtime/src/kmp_stats_timing.cpp
index 2b5049a..40e29eb 100644
--- a/runtime/src/kmp_stats_timing.cpp
+++ b/runtime/src/kmp_stats_timing.cpp
@@ -25,14 +25,14 @@
 
 using namespace std;
 
-#if KMP_OS_LINUX
+#if KMP_HAVE_TICK_TIME
 # if KMP_MIC
 double tsc_tick_count::tick_time()
 {
     // pretty bad assumption of 1GHz clock for MIC
     return 1/((double)1000*1.e6);
 }
-# else
+# elif KMP_ARCH_X86 || KMP_ARCH_X86_64
 #  include <string.h>
 // Extract the value from the CPUID information
 double tsc_tick_count::tick_time()
diff --git a/runtime/src/kmp_stats_timing.h b/runtime/src/kmp_stats_timing.h
index 2bdfdea..83fb85b 100644
--- a/runtime/src/kmp_stats_timing.h
+++ b/runtime/src/kmp_stats_timing.h
@@ -32,7 +32,9 @@
         explicit tsc_interval_t(int64_t _value) : value(_value) {}
      public:
         tsc_interval_t() : value(0) {}; // Construct 0 time duration
+#if KMP_HAVE_TICK_TIME
         double seconds() const; // Return the length of a time interval in seconds
+#endif
         double ticks() const { return double(value); }
         int64_t getValue() const { return value; }
 
@@ -51,7 +53,9 @@
     tsc_tick_count earlier(tsc_tick_count const other) const { 
         return my_count < other.my_count ? (*this) : other; 
     }
+#if KMP_HAVE_TICK_TIME
     static double tick_time(); // returns seconds per cycle (period) of clock
+#endif
     static tsc_tick_count now() { return tsc_tick_count(); } // returns the rdtsc register value
     friend tsc_tick_count::tsc_interval_t operator-(const tsc_tick_count t1, const tsc_tick_count t0);
 };
@@ -61,10 +65,12 @@
     return tsc_tick_count::tsc_interval_t( t1.my_count-t0.my_count );
 }
 
+#if KMP_HAVE_TICK_TIME
 inline double tsc_tick_count::tsc_interval_t::seconds() const 
 {
     return value*tick_time();
 }
+#endif
 
 extern std::string formatSI(double interval, int width, char unit);