summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp')
-rw-r--r--llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp53
1 files changed, 26 insertions, 27 deletions
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index da26bc458dc..452cebf0ce5 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -35,37 +35,36 @@ namespace {
class FunctionExecutorImpl : public BenchmarkRunner::FunctionExecutor {
public:
FunctionExecutorImpl(const LLVMState &State,
- llvm::object::OwningBinary<llvm::object::ObjectFile> Obj,
+ object::OwningBinary<object::ObjectFile> Obj,
BenchmarkRunner::ScratchSpace *Scratch)
: Function(State.createTargetMachine(), std::move(Obj)),
Scratch(Scratch) {}
private:
- llvm::Expected<int64_t> runAndMeasure(const char *Counters) const override {
+ Expected<int64_t> runAndMeasure(const char *Counters) const override {
// We sum counts when there are several counters for a single ProcRes
// (e.g. P23 on SandyBridge).
int64_t CounterValue = 0;
- llvm::SmallVector<llvm::StringRef, 2> CounterNames;
- llvm::StringRef(Counters).split(CounterNames, '+');
+ SmallVector<StringRef, 2> CounterNames;
+ StringRef(Counters).split(CounterNames, '+');
char *const ScratchPtr = Scratch->ptr();
for (auto &CounterName : CounterNames) {
CounterName = CounterName.trim();
pfm::PerfEvent PerfEvent(CounterName);
if (!PerfEvent.valid())
- llvm::report_fatal_error(llvm::Twine("invalid perf event '")
- .concat(CounterName)
- .concat("'"));
+ report_fatal_error(
+ Twine("invalid perf event '").concat(CounterName).concat("'"));
pfm::Counter Counter(PerfEvent);
Scratch->clear();
{
- llvm::CrashRecoveryContext CRC;
- llvm::CrashRecoveryContext::Enable();
+ CrashRecoveryContext CRC;
+ CrashRecoveryContext::Enable();
const bool Crashed = !CRC.RunSafely([this, &Counter, ScratchPtr]() {
Counter.start();
this->Function(ScratchPtr);
Counter.stop();
});
- llvm::CrashRecoveryContext::Disable();
+ CrashRecoveryContext::Disable();
// FIXME: Better diagnosis.
if (Crashed)
return make_error<Failure>("snippet crashed while running");
@@ -91,7 +90,7 @@ InstructionBenchmark BenchmarkRunner::runConfiguration(
InstrBenchmark.NumRepetitions = NumRepetitions;
InstrBenchmark.Info = BC.Info;
- const std::vector<llvm::MCInst> &Instructions = BC.Key.Instructions;
+ const std::vector<MCInst> &Instructions = BC.Key.Instructions;
InstrBenchmark.Key = BC.Key;
@@ -100,8 +99,8 @@ InstructionBenchmark BenchmarkRunner::runConfiguration(
// that the inside instructions are repeated.
constexpr const int kMinInstructionsForSnippet = 16;
{
- llvm::SmallString<0> Buffer;
- llvm::raw_svector_ostream OS(Buffer);
+ SmallString<0> Buffer;
+ raw_svector_ostream OS(Buffer);
assembleToStream(State.getExegesisTarget(), State.createTargetMachine(),
BC.LiveIns, BC.Key.RegisterInitialValues,
Repetitor.Repeat(Instructions, kMinInstructionsForSnippet),
@@ -117,19 +116,19 @@ InstructionBenchmark BenchmarkRunner::runConfiguration(
const auto Filler =
Repetitor.Repeat(Instructions, InstrBenchmark.NumRepetitions);
- llvm::object::OwningBinary<llvm::object::ObjectFile> ObjectFile;
+ object::OwningBinary<object::ObjectFile> ObjectFile;
if (DumpObjectToDisk) {
auto ObjectFilePath = writeObjectFile(BC, Filler);
- if (llvm::Error E = ObjectFilePath.takeError()) {
- InstrBenchmark.Error = llvm::toString(std::move(E));
+ if (Error E = ObjectFilePath.takeError()) {
+ InstrBenchmark.Error = toString(std::move(E));
return InstrBenchmark;
}
- llvm::outs() << "Check generated assembly with: /usr/bin/objdump -d "
- << *ObjectFilePath << "\n";
+ outs() << "Check generated assembly with: /usr/bin/objdump -d "
+ << *ObjectFilePath << "\n";
ObjectFile = getObjectFromFile(*ObjectFilePath);
} else {
- llvm::SmallString<0> Buffer;
- llvm::raw_svector_ostream OS(Buffer);
+ SmallString<0> Buffer;
+ raw_svector_ostream OS(Buffer);
assembleToStream(State.getExegesisTarget(), State.createTargetMachine(),
BC.LiveIns, BC.Key.RegisterInitialValues, Filler, OS);
ObjectFile = getObjectFromBuffer(OS.str());
@@ -138,8 +137,8 @@ InstructionBenchmark BenchmarkRunner::runConfiguration(
const FunctionExecutorImpl Executor(State, std::move(ObjectFile),
Scratch.get());
auto Measurements = runMeasurements(Executor);
- if (llvm::Error E = Measurements.takeError()) {
- InstrBenchmark.Error = llvm::toString(std::move(E));
+ if (Error E = Measurements.takeError()) {
+ InstrBenchmark.Error = toString(std::move(E));
return InstrBenchmark;
}
InstrBenchmark.Measurements = std::move(*Measurements);
@@ -155,15 +154,15 @@ InstructionBenchmark BenchmarkRunner::runConfiguration(
return InstrBenchmark;
}
-llvm::Expected<std::string>
+Expected<std::string>
BenchmarkRunner::writeObjectFile(const BenchmarkCode &BC,
const FillFunction &FillFunction) const {
int ResultFD = 0;
- llvm::SmallString<256> ResultPath;
- if (llvm::Error E = llvm::errorCodeToError(llvm::sys::fs::createTemporaryFile(
- "snippet", "o", ResultFD, ResultPath)))
+ SmallString<256> ResultPath;
+ if (Error E = errorCodeToError(
+ sys::fs::createTemporaryFile("snippet", "o", ResultFD, ResultPath)))
return std::move(E);
- llvm::raw_fd_ostream OFS(ResultFD, true /*ShouldClose*/);
+ raw_fd_ostream OFS(ResultFD, true /*ShouldClose*/);
assembleToStream(State.getExegesisTarget(), State.createTargetMachine(),
BC.LiveIns, BC.Key.RegisterInitialValues, FillFunction, OFS);
return ResultPath.str();
OpenPOWER on IntegriCloud