[llvm] b62928b - [TableGen] Avoid repeated TreePredicateFn::getCodeToRunOnSDNode() calls in MatcherTableEmitter::EmitNodePredicatesFunction loop. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 1 07:44:30 PST 2021
Author: Simon Pilgrim
Date: 2021-03-01T15:43:37Z
New Revision: b62928b21ec8c8c5f41c7b30adc14bbd027c908c
URL: https://github.com/llvm/llvm-project/commit/b62928b21ec8c8c5f41c7b30adc14bbd027c908c
DIFF: https://github.com/llvm/llvm-project/commit/b62928b21ec8c8c5f41c7b30adc14bbd027c908c.diff
LOG: [TableGen] Avoid repeated TreePredicateFn::getCodeToRunOnSDNode() calls in MatcherTableEmitter::EmitNodePredicatesFunction loop. NFCI.
Added:
Modified:
llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
index 4a81b4530048..411a98c3035b 100644
--- a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -898,14 +898,13 @@ void MatcherTableEmitter::EmitNodePredicatesFunction(
for (unsigned i = 0, e = Preds.size(); i != e; ++i) {
// Emit the predicate code corresponding to this pattern.
const TreePredicateFn PredFn = Preds[i];
-
assert(!PredFn.isAlwaysTrue() && "No code in this predicate");
- OS << " case " << i << ": {\n";
- for (auto *SimilarPred :
- NodePredicatesByCodeToRun[PredFn.getCodeToRunOnSDNode()])
- OS << " // " << TreePredicateFn(SimilarPred).getFnName() <<'\n';
+ std::string PredFnCodeStr = PredFn.getCodeToRunOnSDNode();
- OS << PredFn.getCodeToRunOnSDNode() << "\n }\n";
+ OS << " case " << i << ": {\n";
+ for (auto *SimilarPred : NodePredicatesByCodeToRun[PredFnCodeStr])
+ OS << " // " << TreePredicateFn(SimilarPred).getFnName() << '\n';
+ OS << PredFnCodeStr << "\n }\n";
}
OS << " }\n";
OS << "}\n";
More information about the llvm-commits
mailing list