diff options
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 20 | ||||
-rw-r--r-- | lib/VMCore/Metadata.cpp | 16 |
2 files changed, 14 insertions, 22 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 4ef57fe..c9c9bf0 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -1330,8 +1330,8 @@ class AssemblyWriter { TypePrinting TypePrinter; AssemblyAnnotationWriter *AnnotationWriter; std::vector<const Type*> NumberedTypes; - DenseMap<unsigned, StringRef> MDNames; - + SmallVector<StringRef, 8> MDNames; + public: inline AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac, const Module *M, @@ -1339,16 +1339,8 @@ public: : Out(o), Machine(Mac), TheModule(M), AnnotationWriter(AAW) { AddModuleTypesToPrinter(TypePrinter, NumberedTypes, M); // FIXME: Provide MDPrinter - if (M) { - MetadataContext &TheMetadata = M->getContext().getMetadata(); - SmallVector<std::pair<unsigned, StringRef>, 4> Names; - TheMetadata.getHandlerNames(Names); - for (SmallVector<std::pair<unsigned, StringRef>, 4>::iterator - I = Names.begin(), - E = Names.end(); I != E; ++I) { - MDNames[I->first] = I->second; - } - } + if (M) + M->getContext().getMetadata().getMDKindNames(MDNames); } void write(const Module *M) { printModule(M); } @@ -2075,14 +2067,14 @@ void AssemblyWriter::printInstruction(const Instruction &I) { } } - // Print post operand alignment for load/store + // Print post operand alignment for load/store. if (isa<LoadInst>(I) && cast<LoadInst>(I).getAlignment()) { Out << ", align " << cast<LoadInst>(I).getAlignment(); } else if (isa<StoreInst>(I) && cast<StoreInst>(I).getAlignment()) { Out << ", align " << cast<StoreInst>(I).getAlignment(); } - // Print Metadata info + // Print Metadata info. if (!MDNames.empty()) { MetadataContext &TheMetadata = I.getContext().getMetadata(); typedef SmallVector<std::pair<unsigned, MDNode*>, 2> MDMapTy; diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp index 3d136cc..31e737f 100644 --- a/lib/VMCore/Metadata.cpp +++ b/lib/VMCore/Metadata.cpp @@ -290,9 +290,9 @@ public: /// the same metadata to In2. void copyMD(Instruction *In1, Instruction *In2); - /// getHandlerNames - Populate client-supplied smallvector using custom + /// getMDKindNames - Populate client-supplied smallvector using custom /// metadata name and ID. - void getHandlerNames(SmallVectorImpl<std::pair<unsigned, StringRef> >&) const; + void getMDKindNames(SmallVectorImpl<StringRef> &) const; /// ValueIsDeleted - This handler is used to update metadata store /// when a value is deleted. @@ -415,12 +415,13 @@ getMDs(const Instruction *Inst, /// getHandlerNames - Populate client supplied smallvector using custome /// metadata name and ID. void MetadataContextImpl:: -getHandlerNames(SmallVectorImpl<std::pair<unsigned, StringRef> >&Names) const { - Names.resize(MDHandlerNames.size()); +getMDKindNames(SmallVectorImpl<StringRef> &Names) const { + Names.resize(MDHandlerNames.size()+1); + Names[0] = ""; for (StringMap<unsigned>::const_iterator I = MDHandlerNames.begin(), E = MDHandlerNames.end(); I != E; ++I) // MD Handlers are numbered from 1. - Names[I->second - 1] = std::make_pair(I->second, I->first()); + Names[I->second] = I->first(); } /// ValueIsCloned - This handler is used to update metadata store @@ -520,9 +521,8 @@ void MetadataContext::copyMD(Instruction *In1, Instruction *In2) { /// getHandlerNames - Populate client supplied smallvector using custome /// metadata name and ID. -void MetadataContext:: -getHandlerNames(SmallVectorImpl<std::pair<unsigned, StringRef> >&N) const { - pImpl->getHandlerNames(N); +void MetadataContext::getMDKindNames(SmallVectorImpl<StringRef> &N) const { + pImpl->getMDKindNames(N); } /// ValueIsDeleted - This handler is used to update metadata store |