diff --git a/llvm/tools/llvm-exegesis/lib/Target.h b/llvm/tools/llvm-exegesis/lib/Target.h --- a/llvm/tools/llvm-exegesis/lib/Target.h +++ b/llvm/tools/llvm-exegesis/lib/Target.h @@ -145,7 +145,9 @@ // Checks hardware and software support for current benchmark mode. // Returns an error if the target host does not have support to run the // benchmark. - virtual Error checkFeatureSupport() const { return Error::success(); } + virtual Error checkFeatureSupport(const LLVMState &) const { + return Error::success(); + } // Creates a snippet generator for the given mode. std::unique_ptr diff --git a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp --- a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp +++ b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp @@ -719,7 +719,7 @@ return Arch == Triple::x86_64 || Arch == Triple::x86; } - Error checkFeatureSupport() const override { + Error checkFeatureSupport(const LLVMState &state) const override { // LBR is the only feature we conditionally support now. // So if LBR is not requested, then we should be able to run the benchmarks. if (LbrSamplingPeriod == 0) @@ -727,13 +727,18 @@ #if defined(__linux__) && defined(HAVE_LIBPFM) && \ defined(LIBPFM_HAS_FIELD_CYCLES) - // If the kernel supports it, the hardware still may not have it. - return X86LbrCounter::checkLbrSupport(); -#else + // FIXME: Fix this. + // https://bugs.llvm.org/show_bug.cgi?id=48918 + // For now, don't do the check if we see an AMD machine because + // the counter uses some intel-specific magic and it could + // be confuse and think the AMD machine actually has LBR support. + if (state.getSubtargetInfo().getCPU().compare_lower("amd") != 0) + // If the kernel supports it, the hardware still may not have it. + return X86LbrCounter::checkLbrSupport(); +#endif return llvm::make_error( "LBR not supported on this kernel and/or platform", llvm::errc::not_supported); -#endif } std::unique_ptr withSavedState() const override { diff --git a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp --- a/llvm/tools/llvm-exegesis/llvm-exegesis.cpp +++ b/llvm/tools/llvm-exegesis/llvm-exegesis.cpp @@ -299,7 +299,7 @@ // Preliminary check to ensure features needed for requested // benchmark mode are present on target CPU and/or OS. - ExitOnErr(State.getExegesisTarget().checkFeatureSupport()); + ExitOnErr(State.getExegesisTarget().checkFeatureSupport(State)); const std::unique_ptr Runner = ExitOnErr(State.getExegesisTarget().createBenchmarkRunner(