Skip to content

Commit

Permalink
[llvm-exegesis] Remove llvm prefix where unnecessary (llvm#79802)
Browse files Browse the repository at this point in the history
This patch removes the llvm:: prefix within llvm-exegesis where it is
not necessary. This is most occurrences of the prefix within exegesis as
exegesis is within the llvm namespace. This patch makes things more
consistent as the vast majority of the code did not use the llvm::
prefix for anything.
  • Loading branch information
boomanaiden154 authored Jan 29, 2024
1 parent 0039a2f commit faf675c
Show file tree
Hide file tree
Showing 19 changed files with 123 additions and 135 deletions.
13 changes: 6 additions & 7 deletions llvm/tools/llvm-exegesis/lib/Analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,7 @@ static void writeLatencySnippetHtml(raw_ostream &OS,
}
}

void Analysis::printPointHtml(const Benchmark &Point,
llvm::raw_ostream &OS) const {
void Analysis::printPointHtml(const Benchmark &Point, raw_ostream &OS) const {
OS << "<li><span class=\"mono\" title=\"";
writeSnippet<EscapeTag, kEscapeHtmlString>(OS, Point.AssembledSnippet, "\n");
OS << "\">";
Expand Down Expand Up @@ -410,9 +409,9 @@ void Analysis::printSchedClassDescHtml(const ResolvedSchedClass &RSC,
OS << "</table>";
}

void Analysis::printClusterRawHtml(
const BenchmarkClustering::ClusterId &Id, StringRef display_name,
llvm::raw_ostream &OS) const {
void Analysis::printClusterRawHtml(const BenchmarkClustering::ClusterId &Id,
StringRef display_name,
raw_ostream &OS) const {
const auto &Points = Clustering_.getPoints();
const auto &Cluster = Clustering_.getCluster(Id);
if (Cluster.PointIndices.empty())
Expand Down Expand Up @@ -538,8 +537,8 @@ Error Analysis::run<Analysis::PrintSchedClassInconsistencies>(
continue; // Ignore noise and errors. FIXME: take noise into account ?
if (ClusterId.isUnstable() ^ AnalysisDisplayUnstableOpcodes_)
continue; // Either display stable or unstable clusters only.
auto SchedClassClusterIt = llvm::find_if(
SchedClassClusters, [ClusterId](const SchedClassCluster &C) {
auto SchedClassClusterIt =
find_if(SchedClassClusters, [ClusterId](const SchedClassCluster &C) {
return C.id() == ClusterId;
});
if (SchedClassClusterIt == SchedClassClusters.end()) {
Expand Down
5 changes: 2 additions & 3 deletions llvm/tools/llvm-exegesis/lib/Analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ class Analysis {
void printInstructionRowCsv(size_t PointId, raw_ostream &OS) const;

void printClusterRawHtml(const BenchmarkClustering::ClusterId &Id,
StringRef display_name, llvm::raw_ostream &OS) const;
StringRef display_name, raw_ostream &OS) const;

void printPointHtml(const Benchmark &Point,
llvm::raw_ostream &OS) const;
void printPointHtml(const Benchmark &Point, raw_ostream &OS) const;

void
printSchedClassClustersHtml(const std::vector<SchedClassCluster> &Clusters,
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/llvm-exegesis/lib/Assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,14 @@ Expected<ExecutableFunction> ExecutableFunction::create(
auto SymbolSizes = object::computeSymbolSizes(*ObjectFileHolder.getBinary());
// Get the size of the function that we want to call into (with the name of
// FunctionID).
auto SymbolIt = llvm::find_if(SymbolSizes, [&](const auto &Pair) {
auto SymbolIt = find_if(SymbolSizes, [&](const auto &Pair) {
auto SymbolName = Pair.first.getName();
if (SymbolName)
return *SymbolName == FunctionID;
// We should always succeed in finding the FunctionID, hence we suppress
// the error here and assert later on the search result, rather than
// propagating the Expected<> error back to the caller.
llvm::consumeError(SymbolName.takeError());
consumeError(SymbolName.takeError());
return false;
});
assert(SymbolIt != SymbolSizes.end() &&
Expand Down
19 changes: 9 additions & 10 deletions llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ BenchmarkRunner::BenchmarkRunner(const LLVMState &State, Benchmark::ModeE Mode,
BenchmarkRunner::~BenchmarkRunner() = default;

void BenchmarkRunner::FunctionExecutor::accumulateCounterValues(
const llvm::SmallVectorImpl<int64_t> &NewValues,
llvm::SmallVectorImpl<int64_t> *Result) {
const SmallVectorImpl<int64_t> &NewValues,
SmallVectorImpl<int64_t> *Result) {
const size_t NumValues = std::max(NewValues.size(), Result->size());
if (NumValues > Result->size())
Result->resize(NumValues, 0);
for (size_t I = 0, End = NewValues.size(); I < End; ++I)
(*Result)[I] += NewValues[I];
}

Expected<llvm::SmallVector<int64_t, 4>>
Expected<SmallVector<int64_t, 4>>
BenchmarkRunner::FunctionExecutor::runAndSample(
const char *Counters, ArrayRef<const char *> ValidationCounters,
SmallVectorImpl<int64_t> &ValidationCounterValues) const {
// We sum counts when there are several counters for a single ProcRes
// (e.g. P23 on SandyBridge).
llvm::SmallVector<int64_t, 4> CounterValues;
SmallVector<int64_t, 4> CounterValues;
SmallVector<StringRef, 2> CounterNames;
StringRef(Counters).split(CounterNames, '+');
for (auto &CounterName : CounterNames) {
Expand Down Expand Up @@ -114,17 +114,16 @@ class InProcessFunctionExecutorImpl : public BenchmarkRunner::FunctionExecutor {
BenchmarkRunner::ScratchSpace *Scratch)
: State(State), Function(std::move(Function)), Scratch(Scratch) {}

static void
accumulateCounterValues(const llvm::SmallVector<int64_t, 4> &NewValues,
llvm::SmallVector<int64_t, 4> *Result) {
static void accumulateCounterValues(const SmallVector<int64_t, 4> &NewValues,
SmallVector<int64_t, 4> *Result) {
const size_t NumValues = std::max(NewValues.size(), Result->size());
if (NumValues > Result->size())
Result->resize(NumValues, 0);
for (size_t I = 0, End = NewValues.size(); I < End; ++I)
(*Result)[I] += NewValues[I];
}

Expected<llvm::SmallVector<int64_t, 4>> runWithCounter(
Expected<SmallVector<int64_t, 4>> runWithCounter(
StringRef CounterName, ArrayRef<const char *> ValidationCounters,
SmallVectorImpl<int64_t> &ValidationCounterValues) const override {
const ExegesisTarget &ET = State.getExegesisTarget();
Expand Down Expand Up @@ -314,7 +313,7 @@ class SubProcessFunctionExecutorImpl
close(PipeFiles[1]);
// Unregister handlers, signal handling is now handled through ptrace in
// the host process
llvm::sys::unregisterHandlers();
sys::unregisterHandlers();
prepareAndRunBenchmark(PipeFiles[0], Key);
// The child process terminates in the above function, so we should never
// get to this point.
Expand Down Expand Up @@ -484,7 +483,7 @@ class SubProcessFunctionExecutorImpl
exit(0);
}

Expected<llvm::SmallVector<int64_t, 4>> runWithCounter(
Expected<SmallVector<int64_t, 4>> runWithCounter(
StringRef CounterName, ArrayRef<const char *> ValidationCounters,
SmallVectorImpl<int64_t> &ValidationCounterValues) const override {
SmallVector<int64_t, 4> Value(1, 0);
Expand Down
8 changes: 4 additions & 4 deletions llvm/tools/llvm-exegesis/lib/BenchmarkRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ class BenchmarkRunner {
public:
virtual ~FunctionExecutor();

Expected<llvm::SmallVector<int64_t, 4>>
Expected<SmallVector<int64_t, 4>>
runAndSample(const char *Counters,
ArrayRef<const char *> ValidationCounters,
SmallVectorImpl<int64_t> &ValidationCounterValues) const;

protected:
static void
accumulateCounterValues(const llvm::SmallVectorImpl<int64_t> &NewValues,
llvm::SmallVectorImpl<int64_t> *Result);
virtual Expected<llvm::SmallVector<int64_t, 4>>
accumulateCounterValues(const SmallVectorImpl<int64_t> &NewValues,
SmallVectorImpl<int64_t> *Result);
virtual Expected<SmallVector<int64_t, 4>>
runWithCounter(StringRef CounterName,
ArrayRef<const char *> ValidationCounters,
SmallVectorImpl<int64_t> &ValidationCounterValues) const = 0;
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-exegesis/lib/Clustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ void BenchmarkClustering::stabilize(unsigned NumOpcodes) {
assert(std::distance(it, OldCluster.PointIndices.end()) > 0 &&
"Should have found at least one bad point");
// Mark to-be-moved points as belonging to the new cluster.
for (size_t P : llvm::make_range(it, OldCluster.PointIndices.end()))
for (size_t P : make_range(it, OldCluster.PointIndices.end()))
ClusterIdForPoint_[P] = UnstableCluster.Id;
// Actually append to-be-moved points to the new cluster.
UnstableCluster.PointIndices.insert(UnstableCluster.PointIndices.end(),
Expand Down
22 changes: 11 additions & 11 deletions llvm/tools/llvm-exegesis/lib/LatencyBenchmarkRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LatencyBenchmarkRunner::LatencyBenchmarkRunner(

LatencyBenchmarkRunner::~LatencyBenchmarkRunner() = default;

static double computeVariance(const llvm::SmallVector<int64_t, 4> &Values) {
static double computeVariance(const SmallVector<int64_t, 4> &Values) {
if (Values.empty())
return 0.0;
double Sum = std::accumulate(Values.begin(), Values.end(), 0.0);
Expand All @@ -47,19 +47,19 @@ static double computeVariance(const llvm::SmallVector<int64_t, 4> &Values) {
return Ret / Values.size();
}

static int64_t findMin(const llvm::SmallVector<int64_t, 4> &Values) {
static int64_t findMin(const SmallVector<int64_t, 4> &Values) {
if (Values.empty())
return 0;
return *std::min_element(Values.begin(), Values.end());
}

static int64_t findMax(const llvm::SmallVector<int64_t, 4> &Values) {
static int64_t findMax(const SmallVector<int64_t, 4> &Values) {
if (Values.empty())
return 0;
return *std::max_element(Values.begin(), Values.end());
}

static int64_t findMean(const llvm::SmallVector<int64_t, 4> &Values) {
static int64_t findMean(const SmallVector<int64_t, 4> &Values) {
if (Values.empty())
return 0;
return std::accumulate(Values.begin(), Values.end(), 0.0) /
Expand All @@ -71,7 +71,7 @@ Expected<std::vector<BenchmarkMeasure>> LatencyBenchmarkRunner::runMeasurements(
// Cycle measurements include some overhead from the kernel. Repeat the
// measure several times and return the aggregated value, as specified by
// ResultAggMode.
llvm::SmallVector<int64_t, 4> AccumulatedValues;
SmallVector<int64_t, 4> AccumulatedValues;
double MinVariance = std::numeric_limits<double>::infinity();
const PfmCountersInfo &PCI = State.getPfmCounters();
const char *CounterName = PCI.CycleCounter;
Expand Down Expand Up @@ -125,8 +125,8 @@ Expected<std::vector<BenchmarkMeasure>> LatencyBenchmarkRunner::runMeasurements(
switch (ResultAggMode) {
case Benchmark::MinVariance: {
if (ValuesCount == 1)
llvm::errs() << "Each sample only has one value. result-aggregation-mode "
"of min-variance is probably non-sensical\n";
errs() << "Each sample only has one value. result-aggregation-mode "
"of min-variance is probably non-sensical\n";
std::vector<BenchmarkMeasure> Result;
Result.reserve(AccumulatedValues.size());
for (const int64_t Value : AccumulatedValues)
Expand All @@ -153,10 +153,10 @@ Expected<std::vector<BenchmarkMeasure>> LatencyBenchmarkRunner::runMeasurements(
return std::move(Result);
}
}
return llvm::make_error<Failure>(llvm::Twine("Unexpected benchmark mode(")
.concat(std::to_string(Mode))
.concat(" and unexpected ResultAggMode ")
.concat(std::to_string(ResultAggMode)));
return make_error<Failure>(Twine("Unexpected benchmark mode(")
.concat(std::to_string(Mode))
.concat(" and unexpected ResultAggMode ")
.concat(std::to_string(ResultAggMode)));
}

} // namespace exegesis
Expand Down
27 changes: 13 additions & 14 deletions llvm/tools/llvm-exegesis/lib/LlvmState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,43 +35,42 @@ Expected<LLVMState> LLVMState::Create(std::string TripleName,
const Target *TheTarget =
TargetRegistry::lookupTarget(/*MArch=*/"", TheTriple, Error);
if (!TheTarget) {
return llvm::make_error<llvm::StringError>("no LLVM target for triple " +
TripleName,
llvm::inconvertibleErrorCode());
return make_error<StringError>("no LLVM target for triple " + TripleName,
inconvertibleErrorCode());
}

// Update Triple with the updated triple from the target lookup.
TripleName = TheTriple.str();

if (CpuName == "native")
CpuName = std::string(llvm::sys::getHostCPUName());
CpuName = std::string(sys::getHostCPUName());

std::unique_ptr<MCSubtargetInfo> STI(
TheTarget->createMCSubtargetInfo(TripleName, CpuName, ""));
assert(STI && "Unable to create subtarget info!");
if (!STI->isCPUStringValid(CpuName)) {
return llvm::make_error<llvm::StringError>(Twine("invalid CPU name (")
.concat(CpuName)
.concat(") for triple ")
.concat(TripleName),
llvm::inconvertibleErrorCode());
return make_error<StringError>(Twine("invalid CPU name (")
.concat(CpuName)
.concat(") for triple ")
.concat(TripleName),
inconvertibleErrorCode());
}
const TargetOptions Options;
std::unique_ptr<const TargetMachine> TM(
static_cast<LLVMTargetMachine *>(TheTarget->createTargetMachine(
TripleName, CpuName, Features, Options, Reloc::Model::Static)));
if (!TM) {
return llvm::make_error<llvm::StringError>(
"unable to create target machine", llvm::inconvertibleErrorCode());
return make_error<StringError>("unable to create target machine",
inconvertibleErrorCode());
}

const ExegesisTarget *ET =
TripleName.empty() ? &ExegesisTarget::getDefault()
: ExegesisTarget::lookup(TM->getTargetTriple());
if (!ET) {
return llvm::make_error<llvm::StringError>(
"no Exegesis target for triple " + TripleName,
llvm::inconvertibleErrorCode());
return make_error<StringError>("no Exegesis target for triple " +
TripleName,
inconvertibleErrorCode());
}
const PfmCountersInfo &PCI = UseDummyPerfCounters
? ET->getDummyPfmCounters()
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-exegesis/lib/MCInstrDescView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ std::unique_ptr<Instruction>
Instruction::create(const MCInstrInfo &InstrInfo,
const RegisterAliasingTrackerCache &RATC,
const BitVectorCache &BVC, unsigned Opcode) {
const llvm::MCInstrDesc *const Description = &InstrInfo.get(Opcode);
const MCInstrDesc *const Description = &InstrInfo.get(Opcode);
unsigned OpIndex = 0;
SmallVector<Operand, 8> Operands;
SmallVector<Variable, 4> Variables;
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-exegesis/lib/Mips/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ExegesisMipsTarget : public ExegesisTarget {
: ExegesisTarget(MipsCpuPfmCounters, Mips_MC::isOpcodeAvailable) {}

private:
unsigned getScratchMemoryRegister(const llvm::Triple &TT) const override;
unsigned getScratchMemoryRegister(const Triple &TT) const override;
unsigned getMaxMemoryAccessSize() const override { return 64; }
void fillMemoryOperands(InstructionTemplate &IT, unsigned Reg,
unsigned Offset) const override;
Expand Down
19 changes: 9 additions & 10 deletions llvm/tools/llvm-exegesis/lib/PerfHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ ConfiguredEvent::readOrError(StringRef /*unused*/) const {
ssize_t ReadSize = ::read(FileDescriptor, &Count, sizeof(Count));

if (ReadSize != sizeof(Count))
return llvm::make_error<llvm::StringError>("Failed to read event counter",
llvm::errc::io_error);
return make_error<StringError>("Failed to read event counter",
errc::io_error);

SmallVector<int64_t, 1> Result;
Result.push_back(Count);
Expand Down Expand Up @@ -187,17 +187,17 @@ void CounterGroup::stop() {
ioctl(getFileDescriptor(), PERF_EVENT_IOC_DISABLE, PERF_IOC_FLAG_GROUP);
}

llvm::Expected<llvm::SmallVector<int64_t, 4>>
Expected<SmallVector<int64_t, 4>>
CounterGroup::readOrError(StringRef FunctionBytes) const {
if (!IsDummyEvent)
return EventCounter.readOrError(FunctionBytes);
else
return SmallVector<int64_t, 1>(1, 42);
}

llvm::Expected<llvm::SmallVector<int64_t>>
Expected<SmallVector<int64_t>>
CounterGroup::readValidationCountersOrError() const {
llvm::SmallVector<int64_t, 4> Result;
SmallVector<int64_t, 4> Result;
for (const auto &ValCounter : ValidationEventCounters) {
Expected<SmallVector<int64_t>> ValueOrError =
ValCounter.readOrError(StringRef());
Expand All @@ -223,18 +223,17 @@ void CounterGroup::start() {}

void CounterGroup::stop() {}

llvm::Expected<llvm::SmallVector<int64_t, 4>>
Expected<SmallVector<int64_t, 4>>
CounterGroup::readOrError(StringRef /*unused*/) const {
if (IsDummyEvent) {
llvm::SmallVector<int64_t, 4> Result;
SmallVector<int64_t, 4> Result;
Result.push_back(42);
return Result;
}
return llvm::make_error<llvm::StringError>("Not implemented",
llvm::errc::io_error);
return make_error<StringError>("Not implemented", errc::io_error);
}

llvm::Expected<llvm::SmallVector<int64_t>>
Expected<SmallVector<int64_t>>
CounterGroup::readValidationCountersOrError() const {
return SmallVector<int64_t>(0);
}
Expand Down
5 changes: 2 additions & 3 deletions llvm/tools/llvm-exegesis/lib/PerfHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,10 @@ class CounterGroup {
/// within the benchmarked code.
/// If empty (or not specified), then no filtering will be done.
/// Not all counters choose to use this.
virtual llvm::Expected<llvm::SmallVector<int64_t, 4>>
virtual Expected<SmallVector<int64_t, 4>>
readOrError(StringRef FunctionBytes = StringRef()) const;

virtual llvm::Expected<llvm::SmallVector<int64_t>>
readValidationCountersOrError() const;
virtual Expected<SmallVector<int64_t>> readValidationCountersOrError() const;

virtual int numValues() const;

Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-exegesis/lib/ProgressMeter.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ProgressMeter {
ProgressMeterStep &operator=(ProgressMeterStep &&) = delete;
};

ProgressMeter(int NumStepsTotal_, raw_ostream &out_ = llvm::errs())
ProgressMeter(int NumStepsTotal_, raw_ostream &out_ = errs())
: Out(out_), NumStepsTotal(NumStepsTotal_) {
assert(NumStepsTotal > 0 && "No steps are planned?");
}
Expand Down
Loading

0 comments on commit faf675c

Please sign in to comment.