[llvm] r272306 - BitcodeReader: Use std:::piecewise_construct when upgrading type refs

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 9 13:46:33 PDT 2016


Author: dexonsmith
Date: Thu Jun  9 15:46:33 2016
New Revision: 272306

URL: http://llvm.org/viewvc/llvm-project?rev=272306&view=rev
Log:
BitcodeReader: Use std:::piecewise_construct when upgrading type refs

r267296 used std::piecewise_construct without using
std::forward_as_tuple, and r267298 hacked it out (using an emplace_back
followed by a couple of reset() calls) because of a problem on a bot.
I'm finally circling back to call forward_as_tuple as I should have to
begin with (thanks to David Blaikie for pointing out the missing piece).

Note that this code uses emplace_back() instead of
push_back(make_pair()) because the move constructor for TrackingMDRef is
expensive (cheaper than a copy, but still expensive).

Modified:
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=272306&r1=272305&r2=272306&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Thu Jun  9 15:46:33 2016
@@ -1238,9 +1238,9 @@ Metadata *BitcodeReaderMetadataList::upg
 
   // Create and return a placeholder to use for now.  Eventually
   // resolveTypeRefArrays() will be resolve this forward reference.
-  OldTypeRefs.Arrays.emplace_back();
-  OldTypeRefs.Arrays.back().first.reset(Tuple);
-  OldTypeRefs.Arrays.back().second = MDTuple::getTemporary(Context, None);
+  OldTypeRefs.Arrays.emplace_back(
+      std::piecewise_construct, std::forward_as_tuple(Tuple),
+      std::forward_as_tuple(MDTuple::getTemporary(Context, None)));
   return OldTypeRefs.Arrays.back().second.get();
 }
 




More information about the llvm-commits mailing list