IR: Move creation logic down to MDTuple, NFC

Move creation logic for `MDTuple`s down where it belongs.  Once there
are a few more subclasses, these functions really won't make much sense
here (the `friend` relationship was already awkward).  For now, leave
the `MDNode` versions around, but have it forward down.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225685 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-01-12 20:13:56 +00:00
parent 0196561697
commit dc6a335d3d
2 changed files with 36 additions and 22 deletions

View File

@@ -581,15 +581,15 @@ void UniquableMDNode::handleChangedOperand(void *Ref, Metadata *New) {
storeDistinctInContext();
}
MDNode *MDNode::getMDNode(LLVMContext &Context, ArrayRef<Metadata *> MDs,
bool Insert) {
auto &Store = Context.pImpl->MDTuples;
MDTuple *MDTuple::getImpl(LLVMContext &Context, ArrayRef<Metadata *> MDs,
bool ShouldCreate) {
MDTupleInfo::KeyTy Key(MDs);
auto &Store = Context.pImpl->MDTuples;
auto I = Store.find_as(Key);
if (I != Store.end())
return *I;
if (!Insert)
if (!ShouldCreate)
return nullptr;
// Coallocate space for the node and Operands together, then placement new.
@@ -599,7 +599,7 @@ MDNode *MDNode::getMDNode(LLVMContext &Context, ArrayRef<Metadata *> MDs,
return N;
}
MDNode *MDNode::getDistinct(LLVMContext &Context, ArrayRef<Metadata *> MDs) {
MDTuple *MDTuple::getDistinct(LLVMContext &Context, ArrayRef<Metadata *> MDs) {
auto *N = new (MDs.size()) MDTuple(Context, MDs, /* AllowRAUW */ false);
N->storeDistinctInContext();
return N;