[llvm] r267298 - BitcodeReader: Avoid non-moving std::piecewise_construct from r267296

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


I finally circled back in r272306.  Thanks again for pointing out what I'd missed.

Note that the .first here is *not* a std::unique_ptr; rather, it's a TrackingMDRef.  The motivation for emplace_back is that moving those is not free.

> On 2016-Apr-29, at 18:23, David Blaikie <dblaikie at gmail.com> wrote:
> 
> Fair enough - no worries. 
> 
> Another option would be just to:
> 
> push_back(make_pair(make_unique(Tuple), MDTuple::getTemporary(...)))
> 
> That should just move the pair into the container, which should do piecewise move. Depends whether you want to make_unique expicitly or not, I guess? I sort of favor it, personally (so it's clear that ownership is being taken, rather than not knowing without looking at the original container type declaration, etc)
> 
> On Fri, Apr 29, 2016 at 6:17 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
> 
> > On 2016-Apr-25, at 10:37, David Blaikie <dblaikie at gmail.com> wrote:
> >
> >
> >
> > On Sat, Apr 23, 2016 at 2:23 PM, Duncan P. N. Exon Smith via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> > Author: dexonsmith
> > Date: Sat Apr 23 16:23:41 2016
> > New Revision: 267298
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=267298&view=rev
> > Log:
> > BitcodeReader: Avoid non-moving std::piecewise_construct from r267296
> >
> > Not exactly sure why the host tries to use a copy constructor here, but
> > it's easy enough to work around it.
> >
> > http://lab.llvm.org:8011/builders/lldb-amd64-ninja-freebsd11/builds/6227
> >
> > 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=267298&r1=267297&r2=267298&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
> > +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Sat Apr 23 16:23:41 2016
> > @@ -1215,9 +1215,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(
> > -      std::piecewise_construct, std::make_tuple(Tuple),
> > -      std::make_tuple(MDTuple::getTemporary(Context, None)));
> >
> > make_tuple copies the contents, like make_pair
> >
> > Typically what you want to use with piecewise_construct is std::forward_as_tuple instead. This creates a tuple of references (of the right kind - rvalue or lvalue, etc). Try that?
> >
> 
> Somehow I missed this email until now :(.  That looks like what my
> problem was -- I'll try to come back to this early next week (don't have
> the opportunity just this minute, but wanted to acknowledge I'd received
> the review).
> 
> > +  OldTypeRefs.Arrays.emplace_back();
> > +  OldTypeRefs.Arrays.back().first.reset(Tuple);
> > +  OldTypeRefs.Arrays.back().second = MDTuple::getTemporary(Context, None);
> >    return OldTypeRefs.Arrays.back().second.get();
> >  }
> >
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> 
> 



More information about the llvm-commits mailing list