Rename MapValue(Metadata*) to MapMetadata()

Instead of reusing the name `MapValue()` when mapping `Metadata`, use
`MapMetadata()`.  The old name doesn't make much sense after the
`Metadata`/`Value` split.

llvm-svn: 224566
This commit is contained in:
Duncan P. N. Exon Smith 2014-12-19 06:06:18 +00:00
parent c17d0bbfb3
commit 46d7af5729
5 changed files with 30 additions and 30 deletions

View File

@ -71,16 +71,16 @@ namespace llvm {
ValueMapTypeRemapper *TypeMapper = nullptr,
ValueMaterializer *Materializer = nullptr);
Metadata *MapValue(const Metadata *MD, ValueToValueMapTy &VM,
RemapFlags Flags = RF_None,
ValueMapTypeRemapper *TypeMapper = nullptr,
ValueMaterializer *Materializer = nullptr);
Metadata *MapMetadata(const Metadata *MD, ValueToValueMapTy &VM,
RemapFlags Flags = RF_None,
ValueMapTypeRemapper *TypeMapper = nullptr,
ValueMaterializer *Materializer = nullptr);
/// MapValue - provide versions that preserve type safety for MDNodes.
MDNode *MapValue(const MDNode *MD, ValueToValueMapTy &VM,
RemapFlags Flags = RF_None,
ValueMapTypeRemapper *TypeMapper = nullptr,
ValueMaterializer *Materializer = nullptr);
/// MapMetadata - provide versions that preserve type safety for MDNodes.
MDNode *MapMetadata(const MDNode *MD, ValueToValueMapTy &VM,
RemapFlags Flags = RF_None,
ValueMapTypeRemapper *TypeMapper = nullptr,
ValueMaterializer *Materializer = nullptr);
void RemapInstruction(Instruction *I, ValueToValueMapTy &VM,
RemapFlags Flags = RF_None,

View File

@ -1248,8 +1248,8 @@ void ModuleLinker::linkNamedMDNodes() {
NamedMDNode *DestNMD = DstM->getOrInsertNamedMetadata(I->getName());
// Add Src elements into Dest node.
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
DestNMD->addOperand(MapValue(I->getOperand(i), ValueMap,
RF_None, &TypeMap, &ValMaterializer));
DestNMD->addOperand(MapMetadata(I->getOperand(i), ValueMap, RF_None,
&TypeMap, &ValMaterializer));
}
}
@ -1257,7 +1257,7 @@ void ModuleLinker::linkNamedMDNodes() {
///
/// FIXME: this creates an asymmetric result: we strip losing subprograms from
/// DstM, but leave losing subprograms in SrcM. Instead we should also strip
/// losers from SrcM, but this requires extra plumbing in MapValue.
/// losers from SrcM, but this requires extra plumbing in MapMetadata.
void ModuleLinker::stripReplacedSubprograms() {
// Avoid quadratic runtime by returning early when there's nothing to do.
if (OverridingFunctions.empty())

View File

@ -186,7 +186,7 @@ static void CloneDebugInfoMetadata(Function *NewFunc, const Function *OldFunc,
// Ensure that OldFunc appears in the map.
// (if it's already there it must point to NewFunc anyway)
VMap[OldFunc] = NewFunc;
DISubprogram NewSubprogram(MapValue(OldSubprogramMDNode, VMap));
DISubprogram NewSubprogram(MapMetadata(OldSubprogramMDNode, VMap));
for (DICompileUnit CU : Finder.compile_units()) {
DIArray Subprograms(CU.getSubprograms());

View File

@ -118,7 +118,7 @@ Module *llvm::CloneModule(const Module *M, ValueToValueMapTy &VMap) {
const NamedMDNode &NMD = *I;
NamedMDNode *NewNMD = New->getOrInsertNamedMetadata(NMD.getName());
for (unsigned i = 0, e = NMD.getNumOperands(); i != e; ++i)
NewNMD->addOperand(MapValue(NMD.getOperand(i), VMap));
NewNMD->addOperand(MapMetadata(NMD.getOperand(i), VMap));
}
return New;

View File

@ -64,7 +64,7 @@ Value *llvm::MapValue(const Value *V, ValueToValueMapTy &VM, RemapFlags Flags,
if (!isa<LocalAsMetadata>(MD) && (Flags & RF_NoModuleLevelChanges))
return VM[V] = const_cast<Value *>(V);
auto *MappedMD = MapValue(MD, VM, Flags, TypeMapper, Materializer);
auto *MappedMD = MapMetadata(MD, VM, Flags, TypeMapper, Materializer);
if (MD == MappedMD || (!MappedMD && (Flags & RF_IgnoreMissingEntries)))
return VM[V] = const_cast<Value *>(V);
@ -154,10 +154,10 @@ static Metadata *mapToSelf(ValueToValueMapTy &VM, const Metadata *MD) {
return mapToMetadata(VM, MD, const_cast<Metadata *>(MD));
}
static Metadata *MapValueImpl(const Metadata *MD, ValueToValueMapTy &VM,
RemapFlags Flags,
ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
static Metadata *MapMetadataImpl(const Metadata *MD, ValueToValueMapTy &VM,
RemapFlags Flags,
ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
// If the value already exists in the map, use it.
if (Metadata *NewMD = VM.MD().lookup(MD).get())
return NewMD;
@ -193,7 +193,7 @@ static Metadata *MapValueImpl(const Metadata *MD, ValueToValueMapTy &VM,
if (!Op)
return nullptr;
if (Metadata *MappedOp =
MapValueImpl(Op, VM, Flags, TypeMapper, Materializer))
MapMetadataImpl(Op, VM, Flags, TypeMapper, Materializer))
return MappedOp;
// Use identity map if MappedOp is null and we can ignore missing entries.
if (Flags & RF_IgnoreMissingEntries)
@ -241,21 +241,21 @@ static Metadata *MapValueImpl(const Metadata *MD, ValueToValueMapTy &VM,
return const_cast<Metadata *>(MD);
}
Metadata *llvm::MapValue(const Metadata *MD, ValueToValueMapTy &VM,
RemapFlags Flags, ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
Metadata *NewMD = MapValueImpl(MD, VM, Flags, TypeMapper, Materializer);
Metadata *llvm::MapMetadata(const Metadata *MD, ValueToValueMapTy &VM,
RemapFlags Flags, ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
Metadata *NewMD = MapMetadataImpl(MD, VM, Flags, TypeMapper, Materializer);
if (NewMD && NewMD != MD)
if (auto *G = dyn_cast<GenericMDNode>(NewMD))
G->resolveCycles();
return NewMD;
}
MDNode *llvm::MapValue(const MDNode *MD, ValueToValueMapTy &VM,
RemapFlags Flags, ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
return cast<MDNode>(MapValue(static_cast<const Metadata *>(MD), VM, Flags,
TypeMapper, Materializer));
MDNode *llvm::MapMetadata(const MDNode *MD, ValueToValueMapTy &VM,
RemapFlags Flags, ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
return cast<MDNode>(MapMetadata(static_cast<const Metadata *>(MD), VM, Flags,
TypeMapper, Materializer));
}
/// RemapInstruction - Convert the instruction operands from referencing the
@ -296,7 +296,7 @@ void llvm::RemapInstruction(Instruction *I, ValueToValueMapTy &VMap,
ME = MDs.end();
MI != ME; ++MI) {
MDNode *Old = MI->second;
MDNode *New = MapValue(Old, VMap, Flags, TypeMapper, Materializer);
MDNode *New = MapMetadata(Old, VMap, Flags, TypeMapper, Materializer);
if (New != Old)
I->setMetadata(MI->first, New);
}