[llvm] r315151 - [TableGen] Avoid repeated find calls in CodeGenDAGPatterns getters. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 7 07:34:24 PDT 2017
Author: rksimon
Date: Sat Oct 7 07:34:24 2017
New Revision: 315151
URL: http://llvm.org/viewvc/llvm-project?rev=315151&view=rev
Log:
[TableGen] Avoid repeated find calls in CodeGenDAGPatterns getters. NFCI.
The assertion tests were using count() instead of testing the find result, resulting in double the number of searches in debug/assert builds.
Instead, call find once (like the release builds do) and assert the result against end().
Modified:
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h
Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h?rev=315151&r1=315150&r2=315151&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h Sat Oct 7 07:34:24 2017
@@ -998,15 +998,17 @@ public:
Record *getSDNodeNamed(StringRef Name) const;
const SDNodeInfo &getSDNodeInfo(Record *R) const {
- assert(SDNodes.count(R) && "Unknown node!");
- return SDNodes.find(R)->second;
+ auto F = SDNodes.find(R);
+ assert(F != SDNodes.end() && "Unknown node!");
+ return F->second;
}
// Node transformation lookups.
typedef std::pair<Record*, std::string> NodeXForm;
const NodeXForm &getSDNodeTransform(Record *R) const {
- assert(SDNodeXForms.count(R) && "Invalid transform!");
- return SDNodeXForms.find(R)->second;
+ auto F = SDNodeXForms.find(R);
+ assert(F != SDNodeXForms.end() && "Invalid transform!");
+ return F->second;
}
typedef std::map<Record*, NodeXForm, LessRecordByID>::const_iterator
@@ -1016,8 +1018,9 @@ public:
const ComplexPattern &getComplexPattern(Record *R) const {
- assert(ComplexPatterns.count(R) && "Unknown addressing mode!");
- return ComplexPatterns.find(R)->second;
+ auto F = ComplexPatterns.find(R);
+ assert(F != ComplexPatterns.end() && "Unknown addressing mode!");
+ return F->second;
}
const CodeGenIntrinsic &getIntrinsic(Record *R) const {
@@ -1045,19 +1048,22 @@ public:
}
const DAGDefaultOperand &getDefaultOperand(Record *R) const {
- assert(DefaultOperands.count(R) &&"Isn't an analyzed default operand!");
- return DefaultOperands.find(R)->second;
+ auto F = DefaultOperands.find(R);
+ assert(F != DefaultOperands.end() &&"Isn't an analyzed default operand!");
+ return F->second;
}
// Pattern Fragment information.
TreePattern *getPatternFragment(Record *R) const {
- assert(PatternFragments.count(R) && "Invalid pattern fragment request!");
- return PatternFragments.find(R)->second.get();
+ auto F = PatternFragments.find(R);
+ assert(F != PatternFragments.end() && "Invalid pattern fragment request!");
+ return F->second.get();
}
TreePattern *getPatternFragmentIfRead(Record *R) const {
- if (!PatternFragments.count(R))
+ auto F = PatternFragments.find(R);
+ if (F == PatternFragments.end())
return nullptr;
- return PatternFragments.find(R)->second.get();
+ return F->second.get();
}
typedef std::map<Record *, std::unique_ptr<TreePattern>,
@@ -1079,8 +1085,9 @@ public:
DAGInstMap &DAGInsts);
const DAGInstruction &getInstruction(Record *R) const {
- assert(Instructions.count(R) && "Unknown instruction!");
- return Instructions.find(R)->second;
+ auto F = Instructions.find(R);
+ assert(F != Instructions.end() && "Unknown instruction!");
+ return F->second;
}
Record *get_intrinsic_void_sdnode() const {
More information about the llvm-commits
mailing list