[llvm] r226504 - IR: Return unique_ptr from MDNode::getTemporary()

Duncan P. N. Exon Smith dexonsmith at apple.com
Tue Jan 20 10:20:22 PST 2015


> On 2015 Jan 20, at 09:15, David Blaikie <dblaikie at gmail.com> wrote:
> 
> 
> 
> On Mon, Jan 19, 2015 at 1:30 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
> Author: dexonsmith
> Date: Mon Jan 19 15:30:18 2015
> New Revision: 226504
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=226504&view=rev
> Log:
> IR: Return unique_ptr from MDNode::getTemporary()
> 
> Change `MDTuple::getTemporary()` and `MDLocation::getTemporary()` to
> return (effectively) `std::unique_ptr<T, MDNode::deleteTemporary>`, and
> clean up call sites.  (For now, `DIBuilder` call sites just call
> `release()` immediately.)
> 
> There's an accompanying change in each of clang and polly to use the new
> API.

[snip]

> I thought temporary MDNodes could just be "delete"d now? Why the custom deleter, then? (we discussed making getTemporary return unique_ptr a week or two ago)

(You're talking about r225689.)

> (I guess there's some more recent changes that have/will necessitate this?)

Yeah, see r226501 (and r226481).  Basically, when I introduced
`MDNodeFwdDecl` a couple of months ago, I thought we only used
temporaries as pure forward declarations without any data inside
them.  But `DIBuilder` actually puts data in them and uses the
concept to delay uniquing (see `DIBuilder::createReplaceable*()`).

The bottom line is we need temporary versions of each type of node.
But we shouldn't make each node type's destructor public, since
only temporaries should be deleted.  I think the `deleteTemporary()`
API makes more sense.



More information about the llvm-commits mailing list