void setMetadata(Instruction *Inst, unsigned Kind, MDNode *Node);
- /// removeAllMetadata - Remove all metadata attached with an instruction.
+ /// removeAllMetadata - Remove all metadata attached to an instruction.
void removeAllMetadata(Instruction *Inst);
-
-
/// copyMD - If metadata is attached with Instruction In1 then attach
/// the same metadata to In2.
void copyMD(Instruction *In1, Instruction *In2);
-
-
- /// ValueIsDeleted - This handler is used to update metadata store
- /// when a value is deleted.
- void ValueIsDeleted(const Value *) {}
- void ValueIsDeleted(Instruction *Inst) {
- removeAllMetadata(Inst);
- }
- void ValueIsRAUWd(Value *V1, Value *V2);
-
- /// ValueIsCloned - This handler is used to update metadata store
- /// when In1 is cloned to create In2.
- void ValueIsCloned(const Instruction *In1, Instruction *In2);
};
}
// Handle the case when we're adding/updating metadata on an instruction.
if (Node) {
MDMapTy &Info = MetadataStore[Inst];
- assert(!Info.empty() == Inst->HasMetadata && "HasMetadata bit is wonked");
+ assert(!Info.empty() == Inst->hasMetadata() && "HasMetadata bit is wonked");
if (Info.empty()) {
- Inst->HasMetadata = true;
+ Inst->setHasMetadata(true);
} else {
// Handle replacement of an existing value.
for (unsigned i = 0, e = Info.size(); i != e; ++i)
}
// Otherwise, we're removing metadata from an instruction.
- assert(Inst->HasMetadata && MetadataStore.count(Inst) &&
+ assert(Inst->hasMetadata() && MetadataStore.count(Inst) &&
"HasMetadata bit out of date!");
MDMapTy &Info = MetadataStore[Inst];
// Common case is removing the only entry.
if (Info.size() == 1 && Info[0].first == Kind) {
MetadataStore.erase(Inst);
- Inst->HasMetadata = false;
+ Inst->setHasMetadata(false);
return;
}
/// removeAllMetadata - Remove all metadata attached with an instruction.
void MetadataContextImpl::removeAllMetadata(Instruction *Inst) {
MetadataStore.erase(Inst);
- Inst->HasMetadata = false;
+ Inst->setHasMetadata(false);
}
In2->setMetadata(I->first, I->second);
}
-/// ValueIsCloned - This handler is used to update metadata store
-/// when In1 is cloned to create In2.
-void MetadataContextImpl::ValueIsCloned(const Instruction *In1,
- Instruction *In2) {
- // Find Metadata handles for In1.
- MDStoreTy::iterator I = MetadataStore.find(In1);
- assert(I != MetadataStore.end() && "Invalid custom metadata info!");
-
- // FIXME: Give all metadata handlers a chance to adjust.
- MDMapTy &In1Info = I->second;
- for (MDMapTy::iterator I = In1Info.begin(), E = In1Info.end(); I != E; ++I)
- In2->setMetadata(I->first, I->second);
-}
-
-/// ValueIsRAUWd - This handler is used when V1's all uses are replaced by
-/// V2.
-void MetadataContextImpl::ValueIsRAUWd(Value *V1, Value *V2) {
- Instruction *I1 = dyn_cast<Instruction>(V1);
- Instruction *I2 = dyn_cast<Instruction>(V2);
- if (!I1 || !I2)
- return;
-
- // FIXME: Give custom handlers a chance to override this.
- ValueIsCloned(I1, I2);
-}
-
//===----------------------------------------------------------------------===//
// MetadataContext implementation.
//
pImpl->getMDKindNames(N);
}
-/// ValueIsDeleted - This handler is used to update metadata store
-/// when a value is deleted.
-void MetadataContext::ValueIsDeleted(Instruction *Inst) {
- pImpl->ValueIsDeleted(Inst);
-}
-void MetadataContext::ValueIsRAUWd(Value *V1, Value *V2) {
- pImpl->ValueIsRAUWd(V1, V2);
-}
-
-/// ValueIsCloned - This handler is used to update metadata store
-/// when In1 is cloned to create In2.
-void MetadataContext::ValueIsCloned(const Instruction *In1, Instruction *In2) {
- pImpl->ValueIsCloned(In1, In2);
-}
-
//===----------------------------------------------------------------------===//
// Instruction Metadata method implementations.
//
getContext().getMetadata().pImpl->getAllMetadata(this, Result);
}
+/// removeAllMetadata - Remove all metadata from this instruction.
+void Instruction::removeAllMetadata() {
+ assert(hasMetadata() && "Caller should check");
+ getContext().getMetadata().pImpl->removeAllMetadata(this);
+}
+