mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-23 22:23:00 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226504 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -249,12 +249,11 @@ 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.
|
||||
MDTuple *Dummy = MDTuple::getTemporary(Node->getContext(), None);
|
||||
mapToMetadata(VM, Node, Dummy);
|
||||
auto Dummy = MDTuple::getTemporary(Node->getContext(), None);
|
||||
mapToMetadata(VM, Node, Dummy.get());
|
||||
Metadata *NewMD = cloneMDNode(Node, VM, Flags, TypeMapper, Materializer,
|
||||
/* IsDistinct */ true);
|
||||
Dummy->replaceAllUsesWith(NewMD);
|
||||
MDNode::deleteTemporary(Dummy);
|
||||
return mapToMetadata(VM, Node, NewMD);
|
||||
}
|
||||
|
||||
@@ -285,14 +284,13 @@ static Metadata *mapUniquedNode(const UniquableMDNode *Node,
|
||||
assert(Node->isUniqued() && "Expected uniqued node");
|
||||
|
||||
// Create a dummy node in case we have a metadata cycle.
|
||||
MDTuple *Dummy = MDTuple::getTemporary(Node->getContext(), None);
|
||||
mapToMetadata(VM, Node, Dummy);
|
||||
auto Dummy = MDTuple::getTemporary(Node->getContext(), None);
|
||||
mapToMetadata(VM, Node, Dummy.get());
|
||||
|
||||
// Check all operands to see if any need to be remapped.
|
||||
if (!shouldRemapUniquedNode(Node, VM, Flags, TypeMapper, Materializer)) {
|
||||
// Use an identity mapping.
|
||||
mapToSelf(VM, Node);
|
||||
MDNode::deleteTemporary(Dummy);
|
||||
return const_cast<Metadata *>(static_cast<const Metadata *>(Node));
|
||||
}
|
||||
|
||||
@@ -300,7 +298,6 @@ static Metadata *mapUniquedNode(const UniquableMDNode *Node,
|
||||
Metadata *NewMD = cloneMDNode(Node, VM, Flags, TypeMapper, Materializer,
|
||||
/* IsDistinct */ false);
|
||||
Dummy->replaceAllUsesWith(NewMD);
|
||||
MDNode::deleteTemporary(Dummy);
|
||||
return mapToMetadata(VM, Node, NewMD);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user