From c3f89973863fdbe2ae896fabd9ce29b593d0bc12 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Thu, 9 Jun 2016 20:46:33 +0000 Subject: [PATCH] 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). llvm-svn: 272306 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 0c2895007b91..3bba0250af56 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1238,9 +1238,9 @@ Metadata *BitcodeReaderMetadataList::upgradeTypeRefArray(Metadata *MaybeTuple) { // 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(); }