OSDN Git Service

[llvm-exegesis] Add a flag to disable libpfm even if present.
authorClement Courbet <courbet@google.com>
Wed, 11 Apr 2018 07:32:43 +0000 (07:32 +0000)
committerClement Courbet <courbet@google.com>
Wed, 11 Apr 2018 07:32:43 +0000 (07:32 +0000)
Summary: Fixes PR37053.

Reviewers: uabelho, gchatelet

Subscribers: mgorny, tschuett, llvm-commits

Differential Revision: https://reviews.llvm.org/D45436

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329781 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt
cmake/config-ix.cmake
docs/CMake.rst
tools/llvm-exegesis/CMakeLists.txt
unittests/tools/llvm-exegesis/CMakeLists.txt

index 087a563..48915c7 100644 (file)
@@ -366,6 +366,8 @@ set(LLVM_ENABLE_LIBXML2 "ON" CACHE STRING "Use libxml2 if available. Can be ON,
 
 option(LLVM_ENABLE_LIBEDIT "Use libedit if available." ON)
 
+option(LLVM_ENABLE_LIBPFM "Use libpfm for performance counters if available." ON)
+
 option(LLVM_ENABLE_THREADS "Use threads if available." ON)
 
 option(LLVM_ENABLE_ZLIB "Use zlib for compression/decompression if available." ON)
index ff71ad3..d717d5f 100644 (file)
@@ -90,13 +90,15 @@ if( NOT PURE_WINDOWS )
 endif()
 
 # Check for libpfm.
-check_library_exists(pfm pfm_initialize "" HAVE_LIBPFM_INITIALIZE)
-if(HAVE_LIBPFM_INITIALIZE)
-  check_include_file(perfmon/perf_event.h HAVE_PERFMON_PERF_EVENT_H)
-  check_include_file(perfmon/pfmlib.h HAVE_PERFMON_PFMLIB_H)
-  check_include_file(perfmon/pfmlib_perf_event.h HAVE_PERFMON_PFMLIB_PERF_EVENT_H)
-  if(HAVE_PERFMON_PERF_EVENT_H AND HAVE_PERFMON_PFMLIB_H AND HAVE_PERFMON_PFMLIB_PERF_EVENT_H)
-    set(HAVE_LIBPFM 1)
+if (LLVM_ENABLE_LIBPFM)
+  check_library_exists(pfm pfm_initialize "" HAVE_LIBPFM_INITIALIZE)
+  if(HAVE_LIBPFM_INITIALIZE)
+    check_include_file(perfmon/perf_event.h HAVE_PERFMON_PERF_EVENT_H)
+    check_include_file(perfmon/pfmlib.h HAVE_PERFMON_PFMLIB_H)
+    check_include_file(perfmon/pfmlib_perf_event.h HAVE_PERFMON_PFMLIB_PERF_EVENT_H)
+    if(HAVE_PERFMON_PERF_EVENT_H AND HAVE_PERFMON_PFMLIB_H AND HAVE_PERFMON_PFMLIB_PERF_EVENT_H)
+      set(HAVE_LIBPFM 1)
+    endif()
   endif()
 endif()
 
index b3fa4b4..e4da0a6 100644 (file)
@@ -374,6 +374,11 @@ LLVM-specific variables
 **LLVM_USE_INTEL_JITEVENTS**:BOOL
   Enable building support for Intel JIT Events API. Defaults to OFF.
 
+**LLVM_ENABLE_LIBPFM**:BOOL
+  Enable building with libpfm to support hardware counter measurements in LLVM
+  tools.
+  Defaults to ON.
+
 **LLVM_ENABLE_ZLIB**:BOOL
   Enable building with zlib to support compression/uncompression in LLVM tools.
   Defaults to ON.
index 9d6b0c3..def182b 100644 (file)
@@ -10,7 +10,6 @@ add_llvm_tool(llvm-exegesis
 add_subdirectory(lib)
 target_link_libraries(llvm-exegesis PRIVATE LLVMExegesis)
 
-if(HAVE_LIBPFM)
+if(LLVM_ENABLE_LIBPFM AND HAVE_LIBPFM)
   target_link_libraries(llvm-exegesis PRIVATE pfm)
 endif()
-
index bc376e0..a6b1d87 100644 (file)
@@ -22,7 +22,6 @@ add_llvm_unittest(LLVMExegesisTests
   )
 target_link_libraries(LLVMExegesisTests PRIVATE LLVMExegesis)
 
-if(HAVE_LIBPFM)
+if(LLVM_ENABLE_LIBPFM AND HAVE_LIBPFM)
   target_link_libraries(LLVMExegesisTests PRIVATE pfm)
 endif()
-