[llvm] 5b1592b - [NFC][llvm-exegesis] LLVMState: only store references to reg/op names
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 17 06:11:02 PST 2022
Author: Roman Lebedev
Date: 2022-12-17T17:10:48+03:00
New Revision: 5b1592b5c50e71d54382a400264f3539a4aad9a1
URL: https://github.com/llvm/llvm-project/commit/5b1592b5c50e71d54382a400264f3539a4aad9a1
DIFF: https://github.com/llvm/llvm-project/commit/5b1592b5c50e71d54382a400264f3539a4aad9a1.diff
LOG: [NFC][llvm-exegesis] LLVMState: only store references to reg/op names
We know that the original reference from which we've built these maps
will persist, so we do not need to copy the names.
Added:
Modified:
llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
llvm/tools/llvm-exegesis/lib/LlvmState.cpp
llvm/tools/llvm-exegesis/lib/LlvmState.h
Removed:
################################################################################
diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
index 3972bb3e2a103..593b41eb70df7 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
@@ -152,8 +152,8 @@ struct YamlContext {
const exegesis::LLVMState *State;
std::string LastError;
raw_string_ostream ErrorStream;
- const StringMap<unsigned> &OpcodeNameToOpcodeIdx;
- const StringMap<unsigned> &RegNameToRegNo;
+ const DenseMap<StringRef, unsigned> &OpcodeNameToOpcodeIdx;
+ const DenseMap<StringRef, unsigned> &RegNameToRegNo;
};
} // namespace
diff --git a/llvm/tools/llvm-exegesis/lib/LlvmState.cpp b/llvm/tools/llvm-exegesis/lib/LlvmState.cpp
index 363ef82858f45..d7940ce367569 100644
--- a/llvm/tools/llvm-exegesis/lib/LlvmState.cpp
+++ b/llvm/tools/llvm-exegesis/lib/LlvmState.cpp
@@ -100,20 +100,22 @@ std::unique_ptr<LLVMTargetMachine> LLVMState::createTargetMachine() const {
Reloc::Model::Static)));
}
-std::unique_ptr<const StringMap<unsigned>>
+std::unique_ptr<const DenseMap<StringRef, unsigned>>
LLVMState::createOpcodeNameToOpcodeIdxMapping() const {
const MCInstrInfo &InstrInfo = getInstrInfo();
- auto Map = std::make_unique<StringMap<unsigned>>(InstrInfo.getNumOpcodes());
+ auto Map = std::make_unique<DenseMap<StringRef, unsigned>>(
+ InstrInfo.getNumOpcodes());
for (unsigned I = 0, E = InstrInfo.getNumOpcodes(); I < E; ++I)
(*Map)[InstrInfo.getName(I)] = I;
assert(Map->size() == InstrInfo.getNumOpcodes() && "Size prediction failed");
return std::move(Map);
}
-std::unique_ptr<const StringMap<unsigned>>
+std::unique_ptr<const DenseMap<StringRef, unsigned>>
LLVMState::createRegNameToRegNoMapping() const {
const MCRegisterInfo &RegInfo = getRegInfo();
- auto Map = std::make_unique<StringMap<unsigned>>(RegInfo.getNumRegs());
+ auto Map =
+ std::make_unique<DenseMap<StringRef, unsigned>>(RegInfo.getNumRegs());
// Special-case RegNo 0, which would otherwise be spelled as ''.
(*Map)[kNoRegister] = 0;
for (unsigned I = 1, E = RegInfo.getNumRegs(); I < E; ++I)
diff --git a/llvm/tools/llvm-exegesis/lib/LlvmState.h b/llvm/tools/llvm-exegesis/lib/LlvmState.h
index f504e025772b8..6039bdb658de4 100644
--- a/llvm/tools/llvm-exegesis/lib/LlvmState.h
+++ b/llvm/tools/llvm-exegesis/lib/LlvmState.h
@@ -68,21 +68,21 @@ class LLVMState {
const PfmCountersInfo &getPfmCounters() const { return *PfmCounters; }
- const StringMap<unsigned> &getOpcodeNameToOpcodeIdxMapping() const {
+ const DenseMap<StringRef, unsigned> &getOpcodeNameToOpcodeIdxMapping() const {
assert(OpcodeNameToOpcodeIdxMapping);
return *OpcodeNameToOpcodeIdxMapping;
};
- const StringMap<unsigned> &getRegNameToRegNoMapping() const {
+ const DenseMap<StringRef, unsigned> &getRegNameToRegNoMapping() const {
assert(RegNameToRegNoMapping);
return *RegNameToRegNoMapping;
}
private:
- std::unique_ptr<const StringMap<unsigned>>
+ std::unique_ptr<const DenseMap<StringRef, unsigned>>
createOpcodeNameToOpcodeIdxMapping() const;
- std::unique_ptr<const StringMap<unsigned>>
+ std::unique_ptr<const DenseMap<StringRef, unsigned>>
createRegNameToRegNoMapping() const;
LLVMState(std::unique_ptr<const TargetMachine> TM, const ExegesisTarget *ET,
@@ -93,8 +93,9 @@ class LLVMState {
std::unique_ptr<const RegisterAliasingTrackerCache> RATC;
std::unique_ptr<const InstructionsCache> IC;
const PfmCountersInfo *PfmCounters;
- std::unique_ptr<const StringMap<unsigned>> OpcodeNameToOpcodeIdxMapping;
- std::unique_ptr<const StringMap<unsigned>> RegNameToRegNoMapping;
+ std::unique_ptr<const DenseMap<StringRef, unsigned>>
+ OpcodeNameToOpcodeIdxMapping;
+ std::unique_ptr<const DenseMap<StringRef, unsigned>> RegNameToRegNoMapping;
};
} // namespace exegesis
More information about the llvm-commits
mailing list