mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Utils: Extract cloneMDNode(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225917 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9b68f1ce3b
commit
df7a3b3789
@ -203,6 +203,21 @@ static Metadata *cloneMDLocation(const MDLocation *Node, ValueToValueMapTy &VM,
|
||||
mapMetadataOp(Node->getInlinedAt(), VM, Flags, TypeMapper, Materializer));
|
||||
}
|
||||
|
||||
static Metadata *cloneMDNode(const UniquableMDNode *Node, ValueToValueMapTy &VM,
|
||||
RemapFlags Flags, ValueMapTypeRemapper *TypeMapper,
|
||||
ValueMaterializer *Materializer) {
|
||||
switch (Node->getMetadataID()) {
|
||||
default:
|
||||
llvm_unreachable("Invalid UniquableMDNode subclass");
|
||||
#define HANDLE_UNIQUABLE_LEAF(CLASS) \
|
||||
case Metadata::CLASS##Kind: \
|
||||
return clone##CLASS(cast<CLASS>(Node), VM, Flags, TypeMapper, \
|
||||
Materializer); \
|
||||
break;
|
||||
#include "llvm/IR/Metadata.def"
|
||||
}
|
||||
}
|
||||
|
||||
/// \brief Map a distinct MDNode.
|
||||
///
|
||||
/// Distinct nodes are not uniqued, so they must always recreated.
|
||||
@ -264,17 +279,7 @@ static Metadata *mapUniquedNode(const UniquableMDNode *Node,
|
||||
}
|
||||
|
||||
// At least one operand needs remapping.
|
||||
Metadata *NewMD;
|
||||
switch (Node->getMetadataID()) {
|
||||
default:
|
||||
llvm_unreachable("Invalid UniquableMDNode subclass");
|
||||
#define HANDLE_UNIQUABLE_LEAF(CLASS) \
|
||||
case Metadata::CLASS##Kind: \
|
||||
NewMD = \
|
||||
clone##CLASS(cast<CLASS>(Node), VM, Flags, TypeMapper, Materializer); \
|
||||
break;
|
||||
#include "llvm/IR/Metadata.def"
|
||||
}
|
||||
Metadata *NewMD = cloneMDNode(Node, VM, Flags, TypeMapper, Materializer);
|
||||
Dummy->replaceAllUsesWith(NewMD);
|
||||
MDNode::deleteTemporary(Dummy);
|
||||
return mapToMetadata(VM, Node, NewMD);
|
||||
|
Loading…
Reference in New Issue
Block a user