[llvm] r334380 - [TableGen] Make better use of std::map::emplace and emplace construct the object in the map rather than moving it into it. Remove a use std::map::find by remembering the return from emplace.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 10 16:15:49 PDT 2018
Author: ctopper
Date: Sun Jun 10 16:15:49 2018
New Revision: 334380
URL: http://llvm.org/viewvc/llvm-project?rev=334380&view=rev
Log:
[TableGen] Make better use of std::map::emplace and emplace construct the object in the map rather than moving it into it. Remove a use std::map::find by remembering the return from emplace.
Modified:
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=334380&r1=334379&r2=334380&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Sun Jun 10 16:15:49 2018
@@ -3572,21 +3572,22 @@ const DAGInstruction &CodeGenDAGPatterns
// Create and insert the instruction.
// FIXME: InstImpResults should not be part of DAGInstruction.
- TreePattern *InstPattern = I.get();
- DAGInstruction TheInst(std::move(I), Results, Operands, InstImpResults);
- DAGInsts.emplace(InstPattern->getRecord(), std::move(TheInst));
+ Record *R = I->getRecord();
+ DAGInstruction &TheInst =
+ DAGInsts.emplace(std::piecewise_construct, std::forward_as_tuple(R),
+ std::forward_as_tuple(std::move(I), Results, Operands,
+ InstImpResults)).first->second;
// Use a temporary tree pattern to infer all types and make sure that the
// constructed result is correct. This depends on the instruction already
// being inserted into the DAGInsts map.
- TreePattern Temp(InstPattern->getRecord(), ResultPattern, false, *this);
- Temp.InferAllTypes(&InstPattern->getNamedNodesMap());
+ TreePattern Temp(TheInst.getPattern()->getRecord(), ResultPattern, false,
+ *this);
+ Temp.InferAllTypes(&TheInst.getPattern()->getNamedNodesMap());
- DAGInstruction &TheInsertedInst =
- DAGInsts.find(InstPattern->getRecord())->second;
- TheInsertedInst.setResultPattern(Temp.getOnlyTree());
+ TheInst.setResultPattern(Temp.getOnlyTree());
- return TheInsertedInst;
+ return TheInst;
}
/// ParseInstructions - Parse all of the instructions, inlining and resolving
More information about the llvm-commits
mailing list