-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[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
[TableGen] Avoid repeated hash lookups (NFC) #122586
Conversation
@llvm/pr-subscribers-tablegen Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/122586.diff 1 Files Affected:
diff --git a/llvm/utils/TableGen/Common/CodeGenSchedule.cpp b/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
index 06d82daebac0d5..7f4230affca09c 100644
--- a/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenSchedule.cpp
@@ -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.");
@@ -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));
|
I've no idea what's going wrong but I noticed that the testcase If I then run
It fails like
|
The test is flaky. There have been several attempts to fix it, but apparently without success. |
…)" This partially reverts commit 07ff786. The hunk being reverted in this patch seems to break: tools/llvm-gsymutil/ARM_AArch64/macho-merged-funcs-dwarf.yaml under LLVM_ENABLE_EXPENSIVE_CHECKS.
@mikaelholmen I've reverted one of the two hunks to fix the failure. Honestly, I don't know how things break here. @s-barannikov Ack on the flakiness. Thanks! |
Ok, so the test is flaky and with that in mind I realize that it (sometimes) failed also before this patch. |
No description provided.