Skip to content

[TableGen] Avoid repeated hash lookups (NFC) #122586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions llvm/utils/TableGen/Common/CodeGenSchedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,9 @@ void CodeGenSchedModels::checkSTIPredicates() const {
// There cannot be multiple declarations with the same name.
for (const Record *R : Records.getAllDerivedDefinitions("STIPredicateDecl")) {
StringRef Name = R->getValueAsString("Name");
const auto It = Declarations.find(Name);
if (It == Declarations.end()) {
Declarations[Name] = R;
const auto [It, Inserted] = Declarations.try_emplace(Name, R);
if (Inserted)
continue;
}

PrintError(R->getLoc(), "STIPredicate " + Name + " multiply declared.");
PrintFatalNote(It->second->getLoc(), "Previous declaration was here.");
Expand Down Expand Up @@ -417,9 +415,9 @@ void CodeGenSchedModels::collectSTIPredicates() {
for (const Record *R : Records.getAllDerivedDefinitions("STIPredicate")) {
const Record *Decl = R->getValueAsDef("Declaration");

const auto It = Decl2Index.find(Decl);
if (It == Decl2Index.end()) {
Decl2Index[Decl] = STIPredicates.size();
const auto [It, Inserted] =
Decl2Index.try_emplace(Decl, STIPredicates.size());
if (Inserted) {
STIPredicateFunction Predicate(Decl);
Predicate.addDefinition(R);
STIPredicates.emplace_back(std::move(Predicate));
Expand Down
Loading