[llvm] r211595 - Pass a unique_ptr<MemoryBuffer> to the constructors in the Binary hierarchy.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Jul 4 17:19:08 PDT 2014


> Agree, we don't need to refcount in many cases where a reference or pointer
> will do. delete/unique_ptr continues to work in those cases, like the
> snippet in my previous mail.

You started this thread saying it was a problem to use unique_ptr. I
am confused.

Lets be clear, if the only case that needs reference counting are some
files in clang, only those should get a reference count. Why not just
use a shared_ptr in there? I *really* don't want to see reference
counting being force into users that don't need it.

>> Is there a case where we copy the buffer that is used for an ObjectFile?
>
>
> materializeAllPermanently() is called right now to avoid the copy. It avoids
> memory duplication, but at a high cost of having to do lots of work early on
> regardless of whether it's going to be used.
>
> The new scheme will get rid of that early materialization so construction
> becomes a trivial operation, and any materialization can happen on-demand,
> for instance in a in a separate compilation/linking phase.
>
> You know the details better, but I imagine in some cases the materialization
> can probably be avoided completely for LTO.

Not with ld64. That was added because of an specific optimation, it
has nothing to do with avoid copies.

Cheers,
Rafael



More information about the llvm-commits mailing list