OSDN Git Service

[TableGen] Make better use of std::map::emplace and emplace construct the object...
authorCraig Topper <craig.topper@intel.com>
Sun, 10 Jun 2018 23:15:49 +0000 (23:15 +0000)
committerCraig Topper <craig.topper@intel.com>
Sun, 10 Jun 2018 23:15:49 +0000 (23:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334380 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/CodeGenDAGPatterns.cpp

index 0a571bd..7365953 100644 (file)
@@ -3572,21 +3572,22 @@ const DAGInstruction &CodeGenDAGPatterns::parseInstructionPattern(
 
   // 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