[llvm] e128f9c - Revert "[llvm-exegesis] Save target state before running the benchmark."

Clement Courbet via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 06:12:02 PST 2020


Author: Clement Courbet
Date: 2020-11-02T15:11:45+01:00
New Revision: e128f9cafca4e72b089fcd1381af5a1ec656d987

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

LOG: Revert "[llvm-exegesis] Save target state before running the benchmark."

_fxsave64 is not available on some buildbots.

This reverts commit 274de447fe9621082a523a7227157aeb84702a7d.

Added: 
    

Modified: 
    llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
    llvm/tools/llvm-exegesis/lib/Target.cpp
    llvm/tools/llvm-exegesis/lib/Target.h
    llvm/tools/llvm-exegesis/lib/X86/Target.cpp

Removed: 
    llvm/test/tools/llvm-exegesis/X86/uops-FLDENVm.s


################################################################################
diff  --git a/llvm/test/tools/llvm-exegesis/X86/uops-FLDENVm.s b/llvm/test/tools/llvm-exegesis/X86/uops-FLDENVm.s
deleted file mode 100644
index be182d8fcf5b..000000000000
--- a/llvm/test/tools/llvm-exegesis/X86/uops-FLDENVm.s
+++ /dev/null
@@ -1,6 +0,0 @@
-# RUN: llvm-exegesis -mode=uops -opcode-name=FLDENVm,FLDL2E -repetition-mode=duplicate | FileCheck %s
-
-CHECK:      mode:            uops
-CHECK-NEXT: key:
-CHECK-NEXT:   instructions:
-CHECK-NEXT:     FLDENVm

diff  --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index 2304e91b8b32..1bbad207a27e 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -71,10 +71,10 @@ class FunctionExecutorImpl : public BenchmarkRunner::FunctionExecutor {
     SmallVector<StringRef, 2> CounterNames;
     StringRef(Counters).split(CounterNames, '+');
     char *const ScratchPtr = Scratch->ptr();
-    const ExegesisTarget &ET = State.getExegesisTarget();
     for (auto &CounterName : CounterNames) {
       CounterName = CounterName.trim();
-      auto CounterOrError = ET.createCounter(CounterName, State);
+      auto CounterOrError =
+          State.getExegesisTarget().createCounter(CounterName, State);
 
       if (!CounterOrError)
         return CounterOrError.takeError();
@@ -93,7 +93,6 @@ class FunctionExecutorImpl : public BenchmarkRunner::FunctionExecutor {
                 .concat(std::to_string(Reserved)));
       Scratch->clear();
       {
-        auto PS = ET.withSavedState();
         CrashRecoveryContext CRC;
         CrashRecoveryContext::Enable();
         const bool Crashed = !CRC.RunSafely([this, Counter, ScratchPtr]() {
@@ -102,7 +101,6 @@ class FunctionExecutorImpl : public BenchmarkRunner::FunctionExecutor {
           Counter->stop();
         });
         CrashRecoveryContext::Disable();
-        PS.reset();
         if (Crashed) {
           std::string Msg = "snippet crashed while running";
 #ifdef LLVM_ON_UNIX

diff  --git a/llvm/tools/llvm-exegesis/lib/Target.cpp b/llvm/tools/llvm-exegesis/lib/Target.cpp
index 85180a1d6614..ad26c1678c78 100644
--- a/llvm/tools/llvm-exegesis/lib/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Target.cpp
@@ -147,8 +147,6 @@ const PfmCountersInfo &ExegesisTarget::getPfmCounters(StringRef CpuName) const {
   return *Found->PCI;
 }
 
-ExegesisTarget::SavedState::~SavedState() {} // anchor.
-
 namespace {
 
 // Default implementation.

diff  --git a/llvm/tools/llvm-exegesis/lib/Target.h b/llvm/tools/llvm-exegesis/lib/Target.h
index 28c103aa1948..8a5624b42803 100644
--- a/llvm/tools/llvm-exegesis/lib/Target.h
+++ b/llvm/tools/llvm-exegesis/lib/Target.h
@@ -172,16 +172,6 @@ class ExegesisTarget {
   // counters are defined for this CPU).
   const PfmCountersInfo &getPfmCounters(StringRef CpuName) const;
 
-  // Saves the CPU state that needs to be preserved when running a benchmark,
-  // and returns and RAII object that restores the state on destruction.
-  // By default no state is preserved.
-  struct SavedState {
-    virtual ~SavedState();
-  };
-  virtual std::unique_ptr<SavedState> withSavedState() const {
-    return std::make_unique<SavedState>();
-  }
-
 private:
   virtual bool matchesArch(Triple::ArchType Arch) const = 0;
 

diff  --git a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
index 6c1f4a31ab27..827e2e27a2f8 100644
--- a/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/X86/Target.cpp
@@ -23,7 +23,6 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
 
-#include <immintrin.h>
 #include <memory>
 #include <string>
 #include <vector>
@@ -595,25 +594,6 @@ void ConstantInliner::initStack(unsigned Bytes) {
 
 namespace {
 
-class X86SavedState : public ExegesisTarget::SavedState {
-public:
-  X86SavedState() { _fxsave64(FPState); }
-
-  ~X86SavedState() {
-    // Restoring the X87 state does not flush pending exceptions, make sure
-    // these exceptions are flushed now.
-#if defined(_MSC_VER)
-    _clearfp();
-#elif defined(__GNUC__)
-    asm volatile("fwait");
-#endif
-    _fxrstor64(FPState);
-  }
-
-private:
-  alignas(16) char FPState[512];
-};
-
 class ExegesisX86Target : public ExegesisTarget {
 public:
   ExegesisX86Target() : ExegesisTarget(X86CpuPfmCounters) {}
@@ -711,10 +691,6 @@ class ExegesisX86Target : public ExegesisTarget {
 #endif
   }
 
-  std::unique_ptr<SavedState> withSavedState() const override {
-    return std::make_unique<X86SavedState>();
-  }
-
   static const unsigned kUnavailableRegisters[4];
 };
 


        


More information about the llvm-commits mailing list