[llvm] 48c948a - [llvm-exegesis] Check perf_branch_entry for field cycles

Vy Nguyen via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 27 08:32:13 PDT 2020


Author: Vy Nguyen
Date: 2020-07-27T11:31:13-04:00
New Revision: 48c948abeb7dd8a2d022749d1cc1561ddc45d8dc

URL: https://github.com/llvm/llvm-project/commit/48c948abeb7dd8a2d022749d1cc1561ddc45d8dc
DIFF: https://github.com/llvm/llvm-project/commit/48c948abeb7dd8a2d022749d1cc1561ddc45d8dc.diff

LOG: [llvm-exegesis] Check perf_branch_entry for field cycles

Summary: Follow up to breakages reported in D77422

Reviewers: ondrasej, gchatelet

Tags: #llvm

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

Added: 
    

Modified: 
    llvm/cmake/modules/FindLibpfm.cmake
    llvm/include/llvm/Config/config.h.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/FindLibpfm.cmake b/llvm/cmake/modules/FindLibpfm.cmake
index 202bb030e380..38cf3af3953d 100644
--- a/llvm/cmake/modules/FindLibpfm.cmake
+++ b/llvm/cmake/modules/FindLibpfm.cmake
@@ -7,6 +7,7 @@
 
 include(CheckIncludeFile)
 include(CheckLibraryExists)
+include(CheckCXXSourceCompiles)
 
 if (LLVM_ENABLE_LIBPFM)
   check_library_exists(pfm pfm_initialize "" HAVE_LIBPFM_INITIALIZE)
@@ -16,6 +17,19 @@ if (LLVM_ENABLE_LIBPFM)
     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)
+      # Check to see if perf_branch_entry has the field 'cycles'.
+      # We couldn't use CheckStructHasMember here because 'cycles' is a bit field which is not
+      # supported by CheckStructHasMember.
+      CHECK_CXX_SOURCE_COMPILES("
+        #include <perfmon/perf_event.h>
+        int main() {
+          perf_branch_entry entry;
+          entry.cycles = 2;
+          return 0;
+        }" COMPILE_WITH_CYCLES)
+      if(COMPILE_WITH_CYCLES)
+        set(LIBPFM_HAS_FIELD_CYCLES 1)
+      endif()
     endif()
   endif()
 endif()

diff  --git a/llvm/include/llvm/Config/config.h.cmake b/llvm/include/llvm/Config/config.h.cmake
index 298fab318c10..4d76b27df6b6 100644
--- a/llvm/include/llvm/Config/config.h.cmake
+++ b/llvm/include/llvm/Config/config.h.cmake
@@ -97,6 +97,9 @@
 /* Define to 1 if you have the `pfm' library (-lpfm). */
 #cmakedefine HAVE_LIBPFM ${HAVE_LIBPFM}
 
+/* Define to 1 if the `perf_branch_entry' struct has field cycles. */
+#cmakedefine LIBPFM_HAS_FIELD_CYCLES ${LIBPFM_HAS_FIELD_CYCLES}
+
 /* Define to 1 if you have the `psapi' library (-lpsapi). */
 #cmakedefine HAVE_LIBPSAPI ${HAVE_LIBPSAPI}
 


        


More information about the llvm-commits mailing list