diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-19 20:36:39 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-01-19 20:36:39 +0000 |
commit | 946fdcc50cbda9cc30bb78f6c71aa49f3c3ae7ae (patch) | |
tree | 0e036a4f09e4072d6ae5ab6faac355df0b5862b5 /llvm/lib/Transforms/Utils | |
parent | 0ee02fc9fea7107898390680d925238fa5cc0924 (diff) | |
download | bcm5719-llvm-946fdcc50cbda9cc30bb78f6c71aa49f3c3ae7ae.tar.gz bcm5719-llvm-946fdcc50cbda9cc30bb78f6c71aa49f3c3ae7ae.zip |
IR: Remove MDNodeFwdDecl
Remove `MDNodeFwdDecl` (as promised in r226481). Aside from API
changes, there's no real functionality change here.
`MDNode::getTemporary()` now forwards to `MDTuple::getTemporary()`,
which returns a tuple with `isTemporary()` equal to true.
The main point is that we can now add temporaries of other `MDNode`
subclasses, needed for PR22235 (I introduced `MDNodeFwdDecl` in the
first place because I didn't recognize this need, and thought they were
only needed to handle forward references).
A few things left out of (or highlighted by) this commit:
- I've had to remove the (few) uses of `std::unique_ptr<>` to deal
with temporaries, since the destructor is no longer public.
`getTemporary()` should probably return the equivalent of
`std::unique_ptr<T, MDNode::deleteTemporary>`.
- `MDLocation::getTemporary()` doesn't exist yet (worse, it actually
does exist, but does the wrong thing: `MDNode::getTemporary()` is
inherited and returns an `MDTuple`).
- `MDNode` now only has one subclass, `UniquableMDNode`, and the
distinction between them is actually somewhat confusing.
I'll fix those up next.
llvm-svn: 226501
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/ValueMapper.cpp | 8 |
2 files changed, 8 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 2a86eb598d4..3cebd232984 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -319,11 +319,11 @@ static void CloneAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap) { // Now we have a complete set of all metadata in the chains used to specify // the noalias scopes and the lists of those scopes. - SmallVector<MDNode *, 16> DummyNodes; + SmallVector<MDTuple *, 16> DummyNodes; DenseMap<const MDNode *, TrackingMDNodeRef> MDMap; for (SetVector<const MDNode *>::iterator I = MD.begin(), IE = MD.end(); I != IE; ++I) { - MDNode *Dummy = MDNode::getTemporary(CalledFunc->getContext(), None); + MDTuple *Dummy = MDTuple::getTemporary(CalledFunc->getContext(), None); DummyNodes.push_back(Dummy); MDMap[*I].reset(Dummy); } @@ -343,7 +343,8 @@ static void CloneAliasScopeMetadata(CallSite CS, ValueToValueMapTy &VMap) { } MDNode *NewM = MDNode::get(CalledFunc->getContext(), NewOps); - MDNodeFwdDecl *TempM = cast<MDNodeFwdDecl>(MDMap[*I]); + MDTuple *TempM = cast<MDTuple>(MDMap[*I]); + assert(TempM->isTemporary() && "Expected temporary node"); TempM->replaceAllUsesWith(NewM); } diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index 5d89858e527..b195c6349b7 100644 --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -249,12 +249,12 @@ static Metadata *mapDistinctNode(const UniquableMDNode *Node, // In general we need a dummy node, since whether the operands are null can // affect the size of the node. - std::unique_ptr<MDNodeFwdDecl> Dummy( - MDNode::getTemporary(Node->getContext(), None)); - mapToMetadata(VM, Node, Dummy.get()); + MDTuple *Dummy = MDTuple::getTemporary(Node->getContext(), None); + mapToMetadata(VM, Node, Dummy); Metadata *NewMD = cloneMDNode(Node, VM, Flags, TypeMapper, Materializer, /* IsDistinct */ true); Dummy->replaceAllUsesWith(NewMD); + MDNode::deleteTemporary(Dummy); return mapToMetadata(VM, Node, NewMD); } @@ -285,7 +285,7 @@ static Metadata *mapUniquedNode(const UniquableMDNode *Node, assert(Node->isUniqued() && "Expected uniqued node"); // Create a dummy node in case we have a metadata cycle. - MDNodeFwdDecl *Dummy = MDNode::getTemporary(Node->getContext(), None); + MDTuple *Dummy = MDTuple::getTemporary(Node->getContext(), None); mapToMetadata(VM, Node, Dummy); // Check all operands to see if any need to be remapped. |