IR: Lazily create ReplaceableMetadataImpl on MDNode
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sun, 3 Apr 2016 21:23:52 +0000 (21:23 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sun, 3 Apr 2016 21:23:52 +0000 (21:23 +0000)
commitfef609f15e09b4c42334a8ff8c2de29af502ff56
treee2828f1845b49898b1aabb25d42b8bbdde52ac8c
parentbd088744be436e74af45ba76cc28fbe6dbe4402d
IR: Lazily create ReplaceableMetadataImpl on MDNode

RAUW support on MDNode usually requires an extra allocation for
ReplaceableMetadataImpl.  This is only strictly necessary if there are
tracking references to the MDNode.  Make the construction of
ReplaceableMetadataImpl lazy, so that we don't get allocations if we
don't need them.

Since MDNode::isResolved now checks MDNode::isTemporary and
MDNode::NumUnresolved instead of whether a ReplaceableMetadataImpl is
allocated, the internal changes are intrusive (at various internal
checkpoints, isResolved now has a different answer).

However, there should be no real functionality change here; just
slightly lazier allocation behaviour.  The external semantics should be
identical.

llvm-svn: 265279
llvm/include/llvm/IR/Metadata.h
llvm/lib/IR/Metadata.cpp