Rewrite the function-local validation logic for MDNodes (most of r91708).

Among other benefits, this doesn't leak the SmallPtrSet, has the verifier
code in the verifier pass, actually does the verification at the end,
and is considerably simpler.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92217 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-12-28 09:07:21 +00:00
parent dfdb5dcf56
commit b241b37031
3 changed files with 48 additions and 60 deletions
+9 -14
View File
@@ -27,7 +27,6 @@ class LLVMContext;
class Module;
class MetadataContextImpl;
template <typename T> class SmallVectorImpl;
template<class PtrType, unsigned SmallSize> class SmallPtrSet;
//===----------------------------------------------------------------------===//
// MetadataBase - A base class for MDNode, MDString and NamedMDNode.
@@ -91,16 +90,19 @@ class MDNodeElement;
/// MDNode is always unnamed.
class MDNode : public MetadataBase, public FoldingSetNode {
MDNode(const MDNode &); // DO NOT IMPLEMENT
void operator=(const MDNode &); // DO NOT IMPLEMENT
friend class MDNodeElement;
static const unsigned short FunctionLocalBit = 1;
// Replace each instance of F from the element list of this node with T.
void replaceElement(Value *F, Value *T);
MDNodeElement *Operands;
unsigned NumOperands;
// Subclass data enums.
enum {
FunctionLocalBit = 1
};
// Replace each instance of F from the element list of this node with T.
void replaceElement(Value *F, Value *T);
protected:
explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
@@ -125,13 +127,6 @@ public:
/// refer to function-local IR.
bool isFunctionLocal() const { return SubclassData & FunctionLocalBit; }
/// getLocalFunction - Return false if MDNode's recursive function-localness
/// is invalid (local to more than one function). Return true otherwise.
/// If MDNode has one function to which it is local, set LocalFunction to that
/// function.
bool getLocalFunction(Function *LocalFunction,
SmallPtrSet<MDNode *, 32> *VisitedMDNodes = NULL);
/// Profile - calculate a unique identifier for this MDNode to collapse
/// duplicates
void Profile(FoldingSetNodeID &ID) const;