Revert "Re-land "[llvm-exegesis] Save target state before running the benchmark."
authorClement Courbet <courbet@google.com>
Wed, 4 Nov 2020 07:48:44 +0000 (08:48 +0100)
committerClement Courbet <courbet@google.com>
Wed, 4 Nov 2020 07:48:44 +0000 (08:48 +0100)
Still issues on some architectures.

This reverts commit fd13d7ce09af2bcad6976b8f5207874992bdd908.

llvm/test/tools/llvm-exegesis/X86/uops-FLDENVm.s [deleted file]
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

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 (file)
index be182d8..0000000
+++ /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
index 2304e91..1bbad20 100644 (file)
@@ -71,10 +71,10 @@ private:
     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 @@ private:
                 .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 @@ private:
           Counter->stop();
         });
         CrashRecoveryContext::Disable();
-        PS.reset();
         if (Crashed) {
           std::string Msg = "snippet crashed while running";
 #ifdef LLVM_ON_UNIX
index 85180a1..ad26c16 100644 (file)
@@ -147,8 +147,6 @@ const PfmCountersInfo &ExegesisTarget::getPfmCounters(StringRef CpuName) const {
   return *Found->PCI;
 }
 
-ExegesisTarget::SavedState::~SavedState() {} // anchor.
-
 namespace {
 
 // Default implementation.
index 28c103a..8a5624b 100644 (file)
@@ -172,16 +172,6 @@ public:
   // 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;
 
index 8610afd..827e2e2 100644 (file)
@@ -26,9 +26,6 @@
 #include <memory>
 #include <string>
 #include <vector>
-#if defined(_MSC_VER)
-#include <immintrin.h>
-#endif
 
 namespace llvm {
 namespace exegesis {
@@ -597,32 +594,6 @@ void ConstantInliner::initStack(unsigned Bytes) {
 
 namespace {
 
-class X86SavedState : public ExegesisTarget::SavedState {
-public:
-  X86SavedState() {
-#if defined(_MSC_VER)
-    _fxsave64(FPState);
-#elif defined(__GNUC__)
-    __builtin_ia32_fxsave64(FPState);
-#endif
-  }
-
-  ~X86SavedState() {
-    // Restoring the X87 state does not flush pending exceptions, make sure
-    // these exceptions are flushed now.
-#if defined(_MSC_VER)
-    _clearfp();
-    _fxrstor64(FPState);
-#elif defined(__GNUC__)
-    asm volatile("fwait");
-    __builtin_ia32_fxrstor64(FPState);
-#endif
-  }
-
-private:
-  alignas(16) char FPState[512];
-};
-
 class ExegesisX86Target : public ExegesisTarget {
 public:
   ExegesisX86Target() : ExegesisTarget(X86CpuPfmCounters) {}
@@ -720,10 +691,6 @@ private:
 #endif
   }
 
-  std::unique_ptr<SavedState> withSavedState() const override {
-    return std::make_unique<X86SavedState>();
-  }
-
   static const unsigned kUnavailableRegisters[4];
 };