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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224566 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2014-12-19 06:06:18 +00:00
parent 15067a64a9
commit 33ed2ef4ff
5 changed files with 30 additions and 30 deletions

View File

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

View File

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

View File

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

View File

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