mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 11:02:59 +02:00
avoid a completely unneeded linear walk.
llvm-svn: 92221
This commit is contained in:
parent
9229f79945
commit
8c6fbdc63e
@ -102,7 +102,7 @@ class MDNode : public MetadataBase, public FoldingSetNode {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Replace each instance of F from the element list of this node with T.
|
// Replace each instance of F from the element list of this node with T.
|
||||||
void replaceElement(Value *F, Value *T);
|
void replaceElement(MDNodeElement *Op, Value *NewVal);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
|
explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
|
||||||
|
@ -76,11 +76,11 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
void MDNodeElement::deleted() {
|
void MDNodeElement::deleted() {
|
||||||
Parent->replaceElement(this->operator Value*(), 0);
|
Parent->replaceElement(this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MDNodeElement::allUsesReplacedWith(Value *NV) {
|
void MDNodeElement::allUsesReplacedWith(Value *NV) {
|
||||||
Parent->replaceElement(this->operator Value*(), NV);
|
Parent->replaceElement(this, NV);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -142,8 +142,10 @@ Value *MDNode::getElement(unsigned i) const {
|
|||||||
|
|
||||||
|
|
||||||
// Replace value from this node's element list.
|
// Replace value from this node's element list.
|
||||||
void MDNode::replaceElement(Value *From, Value *To) {
|
void MDNode::replaceElement(MDNodeElement *Op, Value *To) {
|
||||||
if (From == To || !getType())
|
Value *From = *Op;
|
||||||
|
|
||||||
|
if (From == To)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LLVMContextImpl *pImpl = getType()->getContext().pImpl;
|
LLVMContextImpl *pImpl = getType()->getContext().pImpl;
|
||||||
@ -151,14 +153,9 @@ void MDNode::replaceElement(Value *From, Value *To) {
|
|||||||
// Remove "this" from the context map. FoldingSet doesn't have to reprofile
|
// Remove "this" from the context map. FoldingSet doesn't have to reprofile
|
||||||
// this node to remove it, so we don't care what state the operands are in.
|
// this node to remove it, so we don't care what state the operands are in.
|
||||||
pImpl->MDNodeSet.RemoveNode(this);
|
pImpl->MDNodeSet.RemoveNode(this);
|
||||||
|
|
||||||
// Find value. This is a linear search, do something if it consumes
|
// Update the operand.
|
||||||
// lot of time. It is possible that to have multiple instances of
|
Op->set(To, this);
|
||||||
// From in this MDNode's element list.
|
|
||||||
for (unsigned i = 0, e = getNumElements(); i != e; ++i) {
|
|
||||||
if (Operands[i] == From)
|
|
||||||
Operands[i].set(To, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert updated "this" into the context's folding node set.
|
// Insert updated "this" into the context's folding node set.
|
||||||
// If a node with same element list already exist then before inserting
|
// If a node with same element list already exist then before inserting
|
||||||
|
Loading…
Reference in New Issue
Block a user