[TableGen] Use map::try_emplace to construction DAGInstruction in the Instructions...
authorCraig Topper <craig.topper@sifive.com>
Sun, 9 Apr 2023 23:32:54 +0000 (16:32 -0700)
committerCraig Topper <craig.topper@sifive.com>
Sun, 9 Apr 2023 23:32:54 +0000 (16:32 -0700)
We add entries to the map in two places. One already used
std::piecewise_construct with map::emplace. The other was using
map::insert. Change both to map::try_emplace.

llvm/utils/TableGen/CodeGenDAGPatterns.cpp

index 56a18bd..4463fe5 100644 (file)
@@ -3938,9 +3938,8 @@ void CodeGenDAGPatterns::parseInstructionPattern(
   // Create and insert the instruction.
   // FIXME: InstImpResults should not be part of DAGInstruction.
   Record *R = I.getRecord();
-  DAGInsts.emplace(std::piecewise_construct, std::forward_as_tuple(R),
-                   std::forward_as_tuple(Results, Operands, InstImpResults,
-                                         SrcPattern, ResultPattern));
+  DAGInsts.try_emplace(R, Results, Operands, InstImpResults, SrcPattern,
+                       ResultPattern);
 
   LLVM_DEBUG(I.dump());
 }
@@ -3981,8 +3980,7 @@ void CodeGenDAGPatterns::ParseInstructions() {
 
       // Create and insert the instruction.
       std::vector<Record*> ImpResults;
-      Instructions.insert(std::make_pair(Instr,
-                            DAGInstruction(Results, Operands, ImpResults)));
+      Instructions.try_emplace(Instr, Results, Operands, ImpResults);
       continue;  // no pattern.
     }