[LLVMdev] unique_ptr and llvm cast machinery

David Chisnall David.Chisnall at cl.cam.ac.uk
Wed Apr 16 08:24:21 PDT 2014


On 15 Apr 2014, at 15:38, Duncan Exon Smith <dexonsmith at apple.com> wrote:

>> That said, it might be useful to have variants of dyn_cast<> that would take a unique_ptr and return another unique_ptr to the cast type, complete with ownership transfer, or leave the original unique_ptr intact if the cast failed.
> 
> I suppose the name would be dyn_move<> or something?

Yup.

>  How often is this useful?

I've used this pattern a few times in non-LLVM code (collect a vector unique pointers to some superclass, then pop them off the vector and dispatch them to some handlers as unique pointers to something else.  I don't know how useful it would be in LLVM code.

On a semi-related note, we've noticed that with transparent superpage support, we get a big speedup with GCC, but not with LLVM, implying that LLVM fragments its heap a lot more (resulting in more TLB churn, even with large pages).  If anyone is interested in memory management stuff in LLVM, improving this could likely give a noticeable speedup...

David





More information about the llvm-dev mailing list