mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-02 07:30:52 +00:00
move ElementVH out of the MDNode class into the MDNode.cpp file. Among
other things, this avoids vtable and rtti data for it being splatted in every translation unit that uses it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92207 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0b86a6f049
commit
c5e08a9639
@ -84,6 +84,9 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class MDNodeElement;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
/// MDNode - a tuple of other values.
|
/// MDNode - a tuple of other values.
|
||||||
/// These contain a list of the values that represent the metadata.
|
/// These contain a list of the values that represent the metadata.
|
||||||
@ -91,29 +94,14 @@ public:
|
|||||||
class MDNode : public MetadataBase, public FoldingSetNode {
|
class MDNode : public MetadataBase, public FoldingSetNode {
|
||||||
MDNode(const MDNode &); // DO NOT IMPLEMENT
|
MDNode(const MDNode &); // DO NOT IMPLEMENT
|
||||||
|
|
||||||
friend class ElementVH;
|
friend class MDNodeElement;
|
||||||
// Use CallbackVH to hold MDNode elements.
|
|
||||||
struct ElementVH : public CallbackVH {
|
|
||||||
MDNode *Parent;
|
|
||||||
ElementVH() {}
|
|
||||||
ElementVH(Value *V, MDNode *P) : CallbackVH(V), Parent(P) {}
|
|
||||||
~ElementVH() {}
|
|
||||||
|
|
||||||
virtual void deleted() {
|
|
||||||
Parent->replaceElement(this->operator Value*(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void allUsesReplacedWith(Value *NV) {
|
|
||||||
Parent->replaceElement(this->operator Value*(), NV);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static const unsigned short FunctionLocalBit = 1;
|
static const unsigned short FunctionLocalBit = 1;
|
||||||
|
|
||||||
// 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(Value *F, Value *T);
|
||||||
|
|
||||||
ElementVH *Node;
|
MDNodeElement *Node;
|
||||||
unsigned NodeSize;
|
unsigned NodeSize;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -128,11 +116,8 @@ public:
|
|||||||
~MDNode();
|
~MDNode();
|
||||||
|
|
||||||
/// getElement - Return specified element.
|
/// getElement - Return specified element.
|
||||||
Value *getElement(unsigned i) const {
|
Value *getElement(unsigned i) const;
|
||||||
assert(i < getNumElements() && "Invalid element number!");
|
|
||||||
return Node[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
/// getNumElements - Return number of MDNode elements.
|
/// getNumElements - Return number of MDNode elements.
|
||||||
unsigned getNumElements() const { return NodeSize; }
|
unsigned getNumElements() const { return NodeSize; }
|
||||||
|
|
||||||
|
@ -46,17 +46,47 @@ MDString *MDString::get(LLVMContext &Context, const char *Str) {
|
|||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
// MDNodeElement implementation.
|
||||||
|
//
|
||||||
|
|
||||||
|
// Use CallbackVH to hold MDNode elements.
|
||||||
|
namespace llvm {
|
||||||
|
class MDNodeElement : public CallbackVH {
|
||||||
|
MDNode *Parent;
|
||||||
|
public:
|
||||||
|
MDNodeElement() {}
|
||||||
|
MDNodeElement(Value *V, MDNode *P) : CallbackVH(V), Parent(P) {}
|
||||||
|
~MDNodeElement() {}
|
||||||
|
|
||||||
|
virtual void deleted();
|
||||||
|
virtual void allUsesReplacedWith(Value *NV);
|
||||||
|
};
|
||||||
|
} // end namespace llvm.
|
||||||
|
|
||||||
|
|
||||||
|
void MDNodeElement::deleted() {
|
||||||
|
Parent->replaceElement(this->operator Value*(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MDNodeElement::allUsesReplacedWith(Value *NV) {
|
||||||
|
Parent->replaceElement(this->operator Value*(), NV);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// MDNode implementation.
|
// MDNode implementation.
|
||||||
//
|
//
|
||||||
|
|
||||||
MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
|
MDNode::MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
|
||||||
bool isFunctionLocal)
|
bool isFunctionLocal)
|
||||||
: MetadataBase(Type::getMetadataTy(C), Value::MDNodeVal) {
|
: MetadataBase(Type::getMetadataTy(C), Value::MDNodeVal) {
|
||||||
NodeSize = NumVals;
|
NodeSize = NumVals;
|
||||||
Node = new ElementVH[NodeSize];
|
Node = new MDNodeElement[NodeSize];
|
||||||
ElementVH *Ptr = Node;
|
MDNodeElement *Ptr = Node;
|
||||||
for (unsigned i = 0; i != NumVals; ++i)
|
for (unsigned i = 0; i != NumVals; ++i)
|
||||||
*Ptr++ = ElementVH(Vals[i], this);
|
*Ptr++ = MDNodeElement(Vals[i], this);
|
||||||
if (isFunctionLocal)
|
if (isFunctionLocal)
|
||||||
SubclassData |= FunctionLocalBit;
|
SubclassData |= FunctionLocalBit;
|
||||||
}
|
}
|
||||||
@ -91,6 +121,14 @@ MDNode::~MDNode() {
|
|||||||
Node = NULL;
|
Node = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getElement - Return specified element.
|
||||||
|
Value *MDNode::getElement(unsigned i) const {
|
||||||
|
assert(i < getNumElements() && "Invalid element number!");
|
||||||
|
return Node[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 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(Value *From, Value *To) {
|
||||||
if (From == To || !getType())
|
if (From == To || !getType())
|
||||||
@ -119,7 +157,7 @@ void MDNode::replaceElement(Value *From, Value *To) {
|
|||||||
for (SmallVector<unsigned, 4>::iterator I = Indexes.begin(), E = Indexes.end();
|
for (SmallVector<unsigned, 4>::iterator I = Indexes.begin(), E = Indexes.end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
unsigned Index = *I;
|
unsigned Index = *I;
|
||||||
Node[Index] = ElementVH(To, this);
|
Node[Index] = MDNodeElement(To, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert updated "this" into the context's folding node set.
|
// Insert updated "this" into the context's folding node set.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user