diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-31 02:27:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-31 02:27:30 +0000 |
commit | 2b4b1e2e603d5543bf2fe0ad45b62ca7bfaee81d (patch) | |
tree | 0a79e9a777cdb9a79d254cbb0acb1e122c838bc7 /lib | |
parent | bd72b3201b24f6ae574b2a1949348f514fcd4c4f (diff) | |
download | external_llvm-2b4b1e2e603d5543bf2fe0ad45b62ca7bfaee81d.zip external_llvm-2b4b1e2e603d5543bf2fe0ad45b62ca7bfaee81d.tar.gz external_llvm-2b4b1e2e603d5543bf2fe0ad45b62ca7bfaee81d.tar.bz2 |
random tidying for MDNode printing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92333 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 46dce1b..90160fc 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -751,7 +751,8 @@ 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 is a function-local metadata. + // Don't insert if N is a function-local metadata, these are always printed + // inline. if (N->isFunctionLocal()) return; @@ -762,12 +763,10 @@ void SlotTracker::CreateMetadataSlot(const MDNode *N) { unsigned DestSlot = mdnNext++; mdnMap[N] = DestSlot; - for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { - const Value *TV = N->getOperand(i); - if (TV) - if (const MDNode *N2 = dyn_cast<MDNode>(TV)) - CreateMetadataSlot(N2); - } + // Recursively add any MDNodes referenced by operands. + for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) + if (const MDNode *Op = dyn_cast_or_null<MDNode>(N->getOperand(i))) + CreateMetadataSlot(Op); } //===----------------------------------------------------------------------===// @@ -1217,7 +1216,6 @@ public: AssemblyAnnotationWriter *AAW) : Out(o), Machine(Mac), TheModule(M), AnnotationWriter(AAW) { AddModuleTypesToPrinter(TypePrinter, NumberedTypes, M); - // FIXME: Provide MDPrinter if (M) M->getMDKindNames(MDNames); } @@ -1996,8 +1994,7 @@ void AssemblyWriter::writeAllMDNodes() { for (unsigned i = 0, e = Nodes.size(); i != e; ++i) { Out << '!' << i << " = metadata "; - const MDNode *Node = Nodes[i]; - printMDNodeBody(Node); + printMDNodeBody(Nodes[i]); } } |