Dump the presence of attached metadata even if we don't know what it is. This
authorNick Lewycky <nicholas@mxc.ca>
Thu, 25 Feb 2010 06:53:04 +0000 (06:53 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Thu, 25 Feb 2010 06:53:04 +0000 (06:53 +0000)
format is not parsable, even if the module is legal. To get parsable output,
dump the module instead of the function or smaller, since metadata kind are
attached to the module (not the context).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97124 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/AsmWriter.cpp

index 1ed13843f0fb5bf395ec197c4d5c7d8e8ec7cc05..361c58e0820c4240d283d8d6ae032b429b6bebe9 100644 (file)
@@ -1988,12 +1988,16 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
   }
 
   // Print Metadata info.
-  if (!MDNames.empty()) {
-    SmallVector<std::pair<unsigned, MDNode*>, 4> InstMD;
-    I.getAllMetadata(InstMD);
-    for (unsigned i = 0, e = InstMD.size(); i != e; ++i)
-      Out << ", !" << MDNames[InstMD[i].first]
-          << " !" << Machine.getMetadataSlot(InstMD[i].second);
+  SmallVector<std::pair<unsigned, MDNode*>, 4> InstMD;
+  I.getAllMetadata(InstMD);
+  for (unsigned i = 0, e = InstMD.size(); i != e; ++i) {
+    unsigned Kind = InstMD[i].first;
+    if (Kind < MDNames.size()) {
+      Out << ", !" << MDNames[Kind];
+    } else {
+      Out << ", !<unknown kind #" << Kind << ">";
+    }
+    Out << " !" << Machine.getMetadataSlot(InstMD[i].second);
   }
   printInfoComment(I);
 }