From b241b370313588837f9960b3ec3de4dcfb8aee4e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 28 Dec 2009 09:07:21 +0000 Subject: 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 --- lib/VMCore/Metadata.cpp | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'lib/VMCore/Metadata.cpp') diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp index 01b47d6767..c1213a3d3a 100644 --- a/lib/VMCore/Metadata.cpp +++ b/lib/VMCore/Metadata.cpp @@ -188,46 +188,6 @@ void MDNode::replaceElement(Value *From, Value *To) { } } -// 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 MDNode::getLocalFunction(Function *LocalFunction, - SmallPtrSet *VisitedMDNodes) { - if (!isFunctionLocal()) - return true; - - if (!VisitedMDNodes) - VisitedMDNodes = new SmallPtrSet(); - - if (!VisitedMDNodes->insert(this)) - // MDNode has already been visited, nothing to do. - return true; - - for (unsigned i = 0, e = getNumElements(); i != e; ++i) { - Value *V = getElement(i); - if (!V) continue; - - Function *LocalFunctionTemp = NULL; - if (Instruction *I = dyn_cast(V)) - LocalFunctionTemp = I->getParent()->getParent(); - else if (MDNode *MD = dyn_cast(V)) - if (!MD->getLocalFunction(LocalFunctionTemp, VisitedMDNodes)) - // This MDNode's operand is function-locally invalid or local to a - // different function. - return false; - - if (LocalFunctionTemp) { - if (!LocalFunction) - LocalFunction = LocalFunctionTemp; - else if (LocalFunction != LocalFunctionTemp) - // This MDNode contains operands that are local to different functions. - return false; - } - } - - return true; -} - //===----------------------------------------------------------------------===// // NamedMDNode implementation. // -- cgit v1.2.3-70-g09d2