[PATCH] D34969: [tablegen] Avoid creating a temporary vector in getInstructionCase

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 3 17:23:58 PDT 2017


alexshap created this revision.

Record::getValues returns ArrayRef which has a cast operator to std::vector,
as a result a temporary is created if the type of the variable is const std::vector & .

Test plan: make check-all


Repository:
  rL LLVM

https://reviews.llvm.org/D34969

Files:
  utils/TableGen/CodeEmitterGen.cpp


Index: utils/TableGen/CodeEmitterGen.cpp
===================================================================
--- utils/TableGen/CodeEmitterGen.cpp
+++ utils/TableGen/CodeEmitterGen.cpp
@@ -189,7 +189,7 @@
   std::string Case;
   
   BitsInit *BI = R->getValueAsBitsInit("Inst");
-  const std::vector<RecordVal> &Vals = R->getValues();
+  ArrayRef<RecordVal> Vals = R->getValues();
   unsigned NumberedOp = 0;
 
   std::set<unsigned> NamedOpIndices;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34969.105125.patch
Type: text/x-patch
Size: 449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170704/9c24ed67/attachment.bin>


More information about the llvm-commits mailing list