Skip to content

Commit 8cfc872

Browse files
committed
Revert "Re-land "[llvm-exegesis] Save target state before running the benchmark."
Still issues on some architectures. This reverts commit fd13d7c.
1 parent fd13d7c commit 8cfc872

File tree

5 files changed

+2
-55
lines changed

5 files changed

+2
-55
lines changed

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

Lines changed: 0 additions & 6 deletions
This file was deleted.

llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ class FunctionExecutorImpl : public BenchmarkRunner::FunctionExecutor {
7171
SmallVector<StringRef, 2> CounterNames;
7272
StringRef(Counters).split(CounterNames, '+');
7373
char *const ScratchPtr = Scratch->ptr();
74-
const ExegesisTarget &ET = State.getExegesisTarget();
7574
for (auto &CounterName : CounterNames) {
7675
CounterName = CounterName.trim();
77-
auto CounterOrError = ET.createCounter(CounterName, State);
76+
auto CounterOrError =
77+
State.getExegesisTarget().createCounter(CounterName, State);
7878

7979
if (!CounterOrError)
8080
return CounterOrError.takeError();
@@ -93,7 +93,6 @@ class FunctionExecutorImpl : public BenchmarkRunner::FunctionExecutor {
9393
.concat(std::to_string(Reserved)));
9494
Scratch->clear();
9595
{
96-
auto PS = ET.withSavedState();
9796
CrashRecoveryContext CRC;
9897
CrashRecoveryContext::Enable();
9998
const bool Crashed = !CRC.RunSafely([this, Counter, ScratchPtr]() {
@@ -102,7 +101,6 @@ class FunctionExecutorImpl : public BenchmarkRunner::FunctionExecutor {
102101
Counter->stop();
103102
});
104103
CrashRecoveryContext::Disable();
105-
PS.reset();
106104
if (Crashed) {
107105
std::string Msg = "snippet crashed while running";
108106
#ifdef LLVM_ON_UNIX

llvm/tools/llvm-exegesis/lib/Target.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ const PfmCountersInfo &ExegesisTarget::getPfmCounters(StringRef CpuName) const {
147147
return *Found->PCI;
148148
}
149149

150-
ExegesisTarget::SavedState::~SavedState() {} // anchor.
151-
152150
namespace {
153151

154152
// Default implementation.

llvm/tools/llvm-exegesis/lib/Target.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,6 @@ class ExegesisTarget {
172172
// counters are defined for this CPU).
173173
const PfmCountersInfo &getPfmCounters(StringRef CpuName) const;
174174

175-
// Saves the CPU state that needs to be preserved when running a benchmark,
176-
// and returns and RAII object that restores the state on destruction.
177-
// By default no state is preserved.
178-
struct SavedState {
179-
virtual ~SavedState();
180-
};
181-
virtual std::unique_ptr<SavedState> withSavedState() const {
182-
return std::make_unique<SavedState>();
183-
}
184-
185175
private:
186176
virtual bool matchesArch(Triple::ArchType Arch) const = 0;
187177

llvm/tools/llvm-exegesis/lib/X86/Target.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
#include <memory>
2727
#include <string>
2828
#include <vector>
29-
#if defined(_MSC_VER)
30-
#include <immintrin.h>
31-
#endif
3229

3330
namespace llvm {
3431
namespace exegesis {
@@ -597,32 +594,6 @@ void ConstantInliner::initStack(unsigned Bytes) {
597594

598595
namespace {
599596

600-
class X86SavedState : public ExegesisTarget::SavedState {
601-
public:
602-
X86SavedState() {
603-
#if defined(_MSC_VER)
604-
_fxsave64(FPState);
605-
#elif defined(__GNUC__)
606-
__builtin_ia32_fxsave64(FPState);
607-
#endif
608-
}
609-
610-
~X86SavedState() {
611-
// Restoring the X87 state does not flush pending exceptions, make sure
612-
// these exceptions are flushed now.
613-
#if defined(_MSC_VER)
614-
_clearfp();
615-
_fxrstor64(FPState);
616-
#elif defined(__GNUC__)
617-
asm volatile("fwait");
618-
__builtin_ia32_fxrstor64(FPState);
619-
#endif
620-
}
621-
622-
private:
623-
alignas(16) char FPState[512];
624-
};
625-
626597
class ExegesisX86Target : public ExegesisTarget {
627598
public:
628599
ExegesisX86Target() : ExegesisTarget(X86CpuPfmCounters) {}
@@ -720,10 +691,6 @@ class ExegesisX86Target : public ExegesisTarget {
720691
#endif
721692
}
722693

723-
std::unique_ptr<SavedState> withSavedState() const override {
724-
return std::make_unique<X86SavedState>();
725-
}
726-
727694
static const unsigned kUnavailableRegisters[4];
728695
};
729696

0 commit comments

Comments
 (0)