Fix crash when printing instructions that have a metadata attached but no parent.
[oota-llvm.git] / lib / IR / AsmWriter.cpp
index 1ebe9b7ee5bc64d1d843f0cdd11816b258185d21..0ce44e105cc397590ea8b19c7dd362c6a850f7c1 100644 (file)
@@ -3121,7 +3121,7 @@ void AssemblyWriter::printMetadataAttachments(
     return;
 
   if (MDNames.empty())
-    TheModule->getMDKindNames(MDNames);
+    MDs[0].second->getContext().getMDKindNames(MDNames);
 
   for (const auto &I : MDs) {
     unsigned Kind = I.first;