diff --git a/llvm/cmake/modules/FindLibpfm.cmake b/llvm/cmake/modules/FindLibpfm.cmake --- a/llvm/cmake/modules/FindLibpfm.cmake +++ b/llvm/cmake/modules/FindLibpfm.cmake @@ -7,6 +7,7 @@ include(CheckIncludeFile) include(CheckLibraryExists) +include(CheckStructHasMember) if (LLVM_ENABLE_LIBPFM) check_library_exists(pfm pfm_initialize "" HAVE_LIBPFM_INITIALIZE) @@ -16,6 +17,11 @@ 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 this version has `cycles` in `struct perf_branch_entry` + Check_struct_has_member("struct perf_branch_entry" cycles perfmon/perf_event.h HAS_CYCLES LANGUAGE C) + if(HAS_CYCLES) + set(LIBPFM_HAS_FIELD_CYCLES 1) + endif() endif() endif() endif()