mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-11 23:38:05 +00:00
While cloning a module, clone metadata attached with instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106591 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c3d57b179c
commit
3bf329f495
@ -133,6 +133,21 @@ Module *llvm::CloneModule(const Module *M,
|
|||||||
NamedMDNode::Create(New->getContext(), NMD.getName(),
|
NamedMDNode::Create(New->getContext(), NMD.getName(),
|
||||||
MDs.data(), MDs.size(), New);
|
MDs.data(), MDs.size(), New);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update metadata attach with instructions.
|
||||||
|
for (Module::iterator MI = New->begin(), ME = New->end(); MI != ME; ++MI)
|
||||||
|
for (Function::iterator FI = MI->begin(), FE = MI->end();
|
||||||
|
FI != FE; ++FI)
|
||||||
|
for (BasicBlock::iterator BI = FI->begin(), BE = FI->end();
|
||||||
|
BI != BE; ++BI) {
|
||||||
|
SmallVector<std::pair<unsigned, MDNode *>, 4 > MDs;
|
||||||
|
BI->getAllMetadata(MDs);
|
||||||
|
for (SmallVector<std::pair<unsigned, MDNode *>, 4>::iterator
|
||||||
|
MDI = MDs.begin(), MDE = MDs.end(); MDI != MDE; ++MDI) {
|
||||||
|
Value *MappedValue = MapValue(MDI->second, ValueMap);
|
||||||
|
if (MDI->second != MappedValue && MappedValue)
|
||||||
|
BI->setMetadata(MDI->first, cast<MDNode>(MappedValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
return New;
|
return New;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user