aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/AsmWriter.cpp
diff options
context:
space:
mode:
authorErick Tryzelaar <idadesub@users.sourceforge.net>2010-03-02 05:32:52 +0000
committerErick Tryzelaar <idadesub@users.sourceforge.net>2010-03-02 05:32:52 +0000
commit3efafefbfa6b07e1dc335105ea62c809d192979c (patch)
tree166ec6aac2efb801745be7f4283e2ca8fe58216b /lib/VMCore/AsmWriter.cpp
parentb98a62344646620b8b266996a97e50a03961ec1c (diff)
downloadexternal_llvm-3efafefbfa6b07e1dc335105ea62c809d192979c.zip
external_llvm-3efafefbfa6b07e1dc335105ea62c809d192979c.tar.gz
external_llvm-3efafefbfa6b07e1dc335105ea62c809d192979c.tar.bz2
Fix looking up MD names to not need a module.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97550 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/AsmWriter.cpp')
-rw-r--r--lib/VMCore/AsmWriter.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index 361c58e..fd74241 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -17,6 +17,7 @@
#include "llvm/Assembly/Writer.h"
#include "llvm/Assembly/PrintModulePass.h"
#include "llvm/Assembly/AsmAnnotationWriter.h"
+#include "llvm/LLVMContext.h"
#include "llvm/CallingConv.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
@@ -1236,7 +1237,6 @@ class AssemblyWriter {
TypePrinting TypePrinter;
AssemblyAnnotationWriter *AnnotationWriter;
std::vector<const Type*> NumberedTypes;
- SmallVector<StringRef, 8> MDNames;
public:
inline AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac,
@@ -1244,8 +1244,6 @@ public:
AssemblyAnnotationWriter *AAW)
: Out(o), Machine(Mac), TheModule(M), AnnotationWriter(AAW) {
AddModuleTypesToPrinter(TypePrinter, NumberedTypes, M);
- if (M)
- M->getMDKindNames(MDNames);
}
void printMDNodeBody(const MDNode *MD);
@@ -1990,14 +1988,18 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
// Print Metadata info.
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 << ">";
+ if (!InstMD.empty()) {
+ SmallVector<StringRef, 8> MDNames;
+ I.getType()->getContext().getMDKindNames(MDNames);
+ 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);
}
- Out << " !" << Machine.getMetadataSlot(InstMD[i].second);
}
printInfoComment(I);
}