Skip to content

Commit 6f4cc13

Browse files
[llvm-exegesis] Remove unused Counter::read method (#76651)
This method was simply a wrapper around readOrError. All users within the llvm-exegesis code base should have been processing an actual error rather than using the wrapper. This patch removes the wrapper and rewrites the users (just 1) to use the readOrError method.
1 parent dcdb4a3 commit 6f4cc13

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,11 @@ class SubProcessFunctionExecutorImpl
356356
if (ChildExitCode == 0) {
357357
// The child exited succesfully, read counter values and return
358358
// success
359-
CounterValues[0] = Counter->read();
359+
auto CounterValueOrErr = Counter->readOrError();
360+
if (!CounterValueOrErr)
361+
return CounterValueOrErr.takeError();
362+
CounterValues = std::move(*CounterValueOrErr);
363+
360364
return Error::success();
361365
}
362366
// The child exited, but not successfully

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,6 @@ void Counter::stop() {
148148
ioctl(FileDescriptor, PERF_EVENT_IOC_DISABLE, 0);
149149
}
150150

151-
int64_t Counter::read() const {
152-
auto ValueOrError = readOrError();
153-
if (ValueOrError) {
154-
if (!ValueOrError.get().empty())
155-
return ValueOrError.get()[0];
156-
errs() << "Counter has no reading\n";
157-
} else
158-
errs() << ValueOrError.takeError() << "\n";
159-
return -1;
160-
}
161-
162151
llvm::Expected<llvm::SmallVector<int64_t, 4>>
163152
Counter::readOrError(StringRef /*unused*/) const {
164153
int64_t Count = 0;
@@ -187,8 +176,6 @@ void Counter::start() {}
187176

188177
void Counter::stop() {}
189178

190-
int64_t Counter::read() const { return 42; }
191-
192179
llvm::Expected<llvm::SmallVector<int64_t, 4>>
193180
Counter::readOrError(StringRef /*unused*/) const {
194181
if (IsDummyEvent) {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ class Counter {
9595
/// Stops the measurement of the event.
9696
void stop();
9797

98-
/// Returns the current value of the counter or -1 if it cannot be read.
99-
int64_t read() const;
100-
10198
/// Returns the current value of the counter or error if it cannot be read.
10299
/// FunctionBytes: The benchmark function being executed.
103100
/// This is used to filter out the measurements to ensure they are only

0 commit comments

Comments
 (0)