mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
Utils: Add mapping for uniqued MDLocations
Still doesn't handle distinct ones. Part of PR21433. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225914 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -219,8 +219,8 @@ static bool shouldRemapUniquedNode(const UniquableMDNode *Node,
|
||||
return false;
|
||||
}
|
||||
|
||||
static Metadata *cloneMDTuple(const UniquableMDNode *Node,
|
||||
ValueToValueMapTy &VM, RemapFlags Flags,
|
||||
static Metadata *cloneMDTuple(const MDTuple *Node, ValueToValueMapTy &VM,
|
||||
RemapFlags Flags,
|
||||
ValueMapTypeRemapper *TypeMapper,
|
||||
ValueMaterializer *Materializer) {
|
||||
SmallVector<Metadata *, 4> Elts;
|
||||
@ -232,6 +232,16 @@ static Metadata *cloneMDTuple(const UniquableMDNode *Node,
|
||||
return MDTuple::get(Node->getContext(), Elts);
|
||||
}
|
||||
|
||||
static Metadata *cloneMDLocation(const MDLocation *Node, ValueToValueMapTy &VM,
|
||||
RemapFlags Flags,
|
||||
ValueMapTypeRemapper *TypeMapper,
|
||||
ValueMaterializer *Materializer) {
|
||||
return MDLocation::get(
|
||||
Node->getContext(), Node->getLine(), Node->getColumn(),
|
||||
mapMetadataOp(Node->getScope(), VM, Flags, TypeMapper, Materializer),
|
||||
mapMetadataOp(Node->getInlinedAt(), VM, Flags, TypeMapper, Materializer));
|
||||
}
|
||||
|
||||
/// \brief Map a uniqued MDNode.
|
||||
///
|
||||
/// Uniqued nodes may not need to be recreated (they may map to themselves).
|
||||
@ -254,7 +264,17 @@ static Metadata *mapUniquedNode(const UniquableMDNode *Node,
|
||||
}
|
||||
|
||||
// At least one operand needs remapping.
|
||||
Metadata *NewMD = cloneMDTuple(Node, VM, Flags, TypeMapper, Materializer);
|
||||
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"
|
||||
}
|
||||
Dummy->replaceAllUsesWith(NewMD);
|
||||
MDNode::deleteTemporary(Dummy);
|
||||
return mapToMetadata(VM, Node, NewMD);
|
||||
|
Reference in New Issue
Block a user