mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Add removeMD().
llvm-svn: 83107
This commit is contained in:
parent
292bcd8ca1
commit
39b5b72d74
@ -345,6 +345,12 @@ public:
|
|||||||
/// addMD - Attach the metadata of given kind with an Instruction.
|
/// addMD - Attach the metadata of given kind with an Instruction.
|
||||||
void addMD(unsigned Kind, MDNode *Node, Instruction *Inst);
|
void addMD(unsigned Kind, MDNode *Node, Instruction *Inst);
|
||||||
|
|
||||||
|
/// removeMD - Remove metadata of given kind attached with an instuction.
|
||||||
|
void removeMD(unsigned Kind, Instruction *Inst);
|
||||||
|
|
||||||
|
/// removeMDs - Remove all metadata attached with an instruction.
|
||||||
|
void removeMDs(const Instruction *Inst);
|
||||||
|
|
||||||
/// getHandlerNames - Get handler names. This is used by bitcode
|
/// getHandlerNames - Get handler names. This is used by bitcode
|
||||||
/// writer.
|
/// writer.
|
||||||
const StringMap<unsigned> *getHandlerNames();
|
const StringMap<unsigned> *getHandlerNames();
|
||||||
@ -352,7 +358,9 @@ public:
|
|||||||
/// ValueIsDeleted - This handler is used to update metadata store
|
/// ValueIsDeleted - This handler is used to update metadata store
|
||||||
/// when a value is deleted.
|
/// when a value is deleted.
|
||||||
void ValueIsDeleted(const Value *V) {}
|
void ValueIsDeleted(const Value *V) {}
|
||||||
void ValueIsDeleted(const Instruction *Inst);
|
void ValueIsDeleted(const Instruction *Inst) {
|
||||||
|
removeMDs(Inst);
|
||||||
|
}
|
||||||
|
|
||||||
/// ValueIsCloned - This handler is used to update metadata store
|
/// ValueIsCloned - This handler is used to update metadata store
|
||||||
/// when In1 is cloned to create In2.
|
/// when In1 is cloned to create In2.
|
||||||
|
@ -327,6 +327,39 @@ void MetadataContext::addMD(unsigned MDKind, MDNode *Node, Instruction *Inst) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// removeMD - Remove metadata of given kind attached with an instuction.
|
||||||
|
void MetadataContext::removeMD(unsigned Kind, Instruction *Inst) {
|
||||||
|
MDStoreTy::iterator I = MetadataStore.find(Inst);
|
||||||
|
if (I == MetadataStore.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
MDMapTy &Info = I->second;
|
||||||
|
for (MDMapTy::iterator MI = Info.begin(), ME = Info.end(); MI != ME; ++MI) {
|
||||||
|
MDPairTy &P = *MI;
|
||||||
|
if (P.first == Kind) {
|
||||||
|
Info.erase(MI);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// removeMDs - Remove all metadata attached with an instruction.
|
||||||
|
void MetadataContext::removeMDs(const Instruction *Inst) {
|
||||||
|
// Find Metadata handles for this instruction.
|
||||||
|
MDStoreTy::iterator I = MetadataStore.find(Inst);
|
||||||
|
assert (I != MetadataStore.end() && "Invalid custom metadata info!");
|
||||||
|
MDMapTy &Info = I->second;
|
||||||
|
|
||||||
|
// FIXME : Give all metadata handlers a chance to adjust.
|
||||||
|
|
||||||
|
// Remove the entries for this instruction.
|
||||||
|
Info.clear();
|
||||||
|
MetadataStore.erase(I);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// getMD - Get the metadata of given kind attached with an Instruction.
|
/// getMD - Get the metadata of given kind attached with an Instruction.
|
||||||
/// If the metadata is not found then return 0.
|
/// If the metadata is not found then return 0.
|
||||||
MDNode *MetadataContext::getMD(unsigned MDKind, const Instruction *Inst) {
|
MDNode *MetadataContext::getMD(unsigned MDKind, const Instruction *Inst) {
|
||||||
@ -356,21 +389,6 @@ const StringMap<unsigned> *MetadataContext::getHandlerNames() {
|
|||||||
return &MDHandlerNames;
|
return &MDHandlerNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ValueIsDeleted - This handler is used to update metadata store
|
|
||||||
/// when a value is deleted.
|
|
||||||
void MetadataContext::ValueIsDeleted(const Instruction *Inst) {
|
|
||||||
// Find Metadata handles for this instruction.
|
|
||||||
MDStoreTy::iterator I = MetadataStore.find(Inst);
|
|
||||||
assert (I != MetadataStore.end() && "Invalid custom metadata info!");
|
|
||||||
MDMapTy &Info = I->second;
|
|
||||||
|
|
||||||
// FIXME : Give all metadata handlers a chance to adjust.
|
|
||||||
|
|
||||||
// Remove the entries for this instruction.
|
|
||||||
Info.clear();
|
|
||||||
MetadataStore.erase(I);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// ValueIsCloned - This handler is used to update metadata store
|
/// ValueIsCloned - This handler is used to update metadata store
|
||||||
/// when In1 is cloned to create In2.
|
/// when In1 is cloned to create In2.
|
||||||
void MetadataContext::ValueIsCloned(const Instruction *In1, Instruction *In2) {
|
void MetadataContext::ValueIsCloned(const Instruction *In1, Instruction *In2) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user