From: Nick Lewycky Date: Sun, 7 Jun 2009 04:03:01 +0000 (+0000) Subject: Remove cyclic MDNode detection. Any attempt to create a cyclic MDNode will X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=dcef849ab0f1f8deec2f9bad0a8f0371e88dc713;p=oota-llvm.git Remove cyclic MDNode detection. Any attempt to create a cyclic MDNode will crash LLVM first. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73011 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index b047d0c9fb6..b1297ff2256 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -280,7 +280,6 @@ namespace { bool isReturnValue, const Value *V); void VerifyFunctionAttrs(const FunctionType *FT, const AttrListPtr &Attrs, const Value *V); - bool VerifyMDNode(const MDNode *N); void WriteValue(const Value *V) { if (!V) return; @@ -380,24 +379,22 @@ void Verifier::visitGlobalVariable(GlobalVariable &GV) { // Verify that any metadata used in a global initializer points only to // other globals. if (MDNode *FirstNode = dyn_cast(GV.getInitializer())) { - if (VerifyMDNode(FirstNode)) { - SmallVector NodesToAnalyze; - NodesToAnalyze.push_back(FirstNode); - while (!NodesToAnalyze.empty()) { - const MDNode *N = NodesToAnalyze.back(); - NodesToAnalyze.pop_back(); - - for (MDNode::const_elem_iterator I = N->elem_begin(), - E = N->elem_end(); I != E; ++I) - if (const Value *V = *I) { - if (const MDNode *Next = dyn_cast(V)) - NodesToAnalyze.push_back(Next); - else - Assert3(isa(V), - "reference to instruction from global metadata node", - &GV, N, V); - } - } + SmallVector NodesToAnalyze; + NodesToAnalyze.push_back(FirstNode); + while (!NodesToAnalyze.empty()) { + const MDNode *N = NodesToAnalyze.back(); + NodesToAnalyze.pop_back(); + + for (MDNode::const_elem_iterator I = N->elem_begin(), + E = N->elem_end(); I != E; ++I) + if (const Value *V = *I) { + if (const MDNode *Next = dyn_cast(V)) + NodesToAnalyze.push_back(Next); + else + Assert3(isa(V), + "reference to instruction from global metadata node", + &GV, N, V); + } } } } else { @@ -1708,44 +1705,6 @@ void Verifier::VerifyIntrinsicPrototype(Intrinsic::ID ID, Function *F, "Intrinsic has wrong parameter attributes!", F); } -/// Verify that an MDNode is not cyclic. -bool Verifier::VerifyMDNode(const MDNode *N) { - if (N->elem_empty()) return true; - - // The current DFS path through the nodes. Node and element number. - typedef std::pair Edge; - SmallVector Path; - - Path.push_back(std::make_pair(N, N->elem_begin())); - while (!Path.empty()) { - Edge &e = Path.back(); - const MDNode *&e_N = e.first; - MDNode::const_elem_iterator &e_I = e.second; - - if (e_N->elem_end() == e_I) { - Path.pop_back(); - continue; - } - - for (MDNode::const_elem_iterator e_E = e_N->elem_end(); e_I != e_E; ++e_I) { - if (const MDNode *C = dyn_cast_or_null(e_I->operator Value*())) { - // Is child MDNode C already in the Path? - for (SmallVectorImpl::iterator I = Path.begin(), E = Path.end(); - I != E; ++I) { - if (I->first != C) { - CheckFailed("MDNode is cyclic.", C); - return false; - } - } - - Path.push_back(std::make_pair(C, C->elem_begin())); - break; - } - } - } - return true; -} - //===----------------------------------------------------------------------===// // Implement the public interfaces to this file...