diff options
| author | Devang Patel <dpatel@apple.com> | 2009-10-07 16:37:55 +0000 | 
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2009-10-07 16:37:55 +0000 | 
| commit | bcdb02587e3320ebe596a3bc3d42d64a1c09cec9 (patch) | |
| tree | 38a088805ec3ca4ef7c907f31335fa5e2021e7e5 /llvm/lib/VMCore/AsmWriter.cpp | |
| parent | 822f634d29a3aae1e0ba7ff7e3f7a3d3a133580c (diff) | |
| download | bcm5719-llvm-bcdb02587e3320ebe596a3bc3d42d64a1c09cec9.tar.gz bcm5719-llvm-bcdb02587e3320ebe596a3bc3d42d64a1c09cec9.zip | |
Do not assume that the module is set.
llvm-svn: 83462
Diffstat (limited to 'llvm/lib/VMCore/AsmWriter.cpp')
| -rw-r--r-- | llvm/lib/VMCore/AsmWriter.cpp | 33 | 
1 files changed, 18 insertions, 15 deletions
| diff --git a/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp index 34ce7bb9964..3e628ae0d08 100644 --- a/llvm/lib/VMCore/AsmWriter.cpp +++ b/llvm/lib/VMCore/AsmWriter.cpp @@ -1303,12 +1303,14 @@ public:      : Out(o), Machine(Mac), TheModule(M), AnnotationWriter(AAW) {      AddModuleTypesToPrinter(TypePrinter, NumberedTypes, M);      // FIXME: Provide MDPrinter -    MetadataContext &TheMetadata = M->getContext().getMetadata(); -    const StringMap<unsigned> *Names = TheMetadata.getHandlerNames(); -    for (StringMapConstIterator<unsigned> I = Names->begin(), -           E = Names->end(); I != E; ++I) { -      const StringMapEntry<unsigned> &Entry = *I; -      MDNames[I->second] = Entry.getKeyData(); +    if (M) { +      MetadataContext &TheMetadata = M->getContext().getMetadata(); +      const StringMap<unsigned> *Names = TheMetadata.getHandlerNames(); +      for (StringMapConstIterator<unsigned> I = Names->begin(), +             E = Names->end(); I != E; ++I) { +        const StringMapEntry<unsigned> &Entry = *I; +        MDNames[I->second] = Entry.getKeyData(); +      }      }    } @@ -2029,15 +2031,16 @@ void AssemblyWriter::printInstruction(const Instruction &I) {    }    // Print Metadata info -  MetadataContext &TheMetadata = I.getContext().getMetadata(); -  const MetadataContext::MDMapTy *MDMap = TheMetadata.getMDs(&I); -  if (MDMap) -    for (MetadataContext::MDMapTy::const_iterator MI = MDMap->begin(), -           ME = MDMap->end(); MI != ME; ++MI) -      if (const MDNode *MD = dyn_cast_or_null<MDNode>(MI->second)) -        Out << ", !" << MDNames[MI->first] -            << " !" << Machine.getMetadataSlot(MD); - +  if (!MDNames.empty()) { +    MetadataContext &TheMetadata = I.getContext().getMetadata(); +    const MetadataContext::MDMapTy *MDMap = TheMetadata.getMDs(&I); +    if (MDMap) +      for (MetadataContext::MDMapTy::const_iterator MI = MDMap->begin(), +             ME = MDMap->end(); MI != ME; ++MI) +        if (const MDNode *MD = dyn_cast_or_null<MDNode>(MI->second)) +          Out << ", !" << MDNames[MI->first] +              << " !" << Machine.getMetadataSlot(MD); +  }    printInfoComment(I);  } | 

