From ff7707e98393255e23a66f3f6689cdcf59197548 Mon Sep 17 00:00:00 2001 From: Victor Hernandez Date: Fri, 4 Dec 2009 20:07:10 +0000 Subject: [PATCH] Avoid creating a metadata slot for all metadata that contains an instruction git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90581 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/AsmWriter.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 44095ca4e85..9a23506e23b 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -695,13 +695,8 @@ void SlotTracker::processFunction() { !I->hasName()) CreateFunctionSlot(I); for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) - if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) { - // Create a metadata slot only if N contains no instructions. - for (unsigned n = 0, e = N->getNumElements(); n != e; ++n) - if (N->getElement(n) && isa(N->getElement(n))) - continue; + if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) CreateMetadataSlot(N); - } // Process metadata attached with this instruction. MDs.clear(); @@ -818,6 +813,11 @@ void SlotTracker::CreateFunctionSlot(const Value *V) { void SlotTracker::CreateMetadataSlot(const MDNode *N) { assert(N && "Can't insert a null Value into SlotTracker!"); + // Don't insert if N contains an instruction. + for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) + if (N->getElement(i) && isa(N->getElement(i))) + return; + ValueMap::iterator I = mdnMap.find(N); if (I != mdnMap.end()) return;