[llvm-commits] [llvm] r84820 - in /llvm/trunk: include/llvm/Metadata.h lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/AsmWriter.cpp lib/VMCore/Metadata.cpp
Devang Patel
dpatel at apple.com
Wed Oct 21 18:01:24 PDT 2009
Author: dpatel
Date: Wed Oct 21 20:01:24 2009
New Revision: 84820
URL: http://llvm.org/viewvc/llvm-project?rev=84820&view=rev
Log:
Fix getHandlerNames() interface. Now it populate clinet supplied small vector with handler names.
Modified:
llvm/trunk/include/llvm/Metadata.h
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/trunk/lib/VMCore/AsmWriter.cpp
llvm/trunk/lib/VMCore/Metadata.cpp
Modified: llvm/trunk/include/llvm/Metadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=84820&r1=84819&r2=84820&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Metadata.h (original)
+++ llvm/trunk/include/llvm/Metadata.h Wed Oct 21 20:01:24 2009
@@ -287,7 +287,7 @@
/// getHandlerNames - Get handler names. This is used by bitcode
/// writer.
- const StringMap<unsigned> *getHandlerNames();
+ void getHandlerNames(SmallVectorImpl<std::pair<unsigned, StringRef> >&N) const;
/// ValueIsDeleted - This handler is used to update metadata store
/// when a value is deleted.
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=84820&r1=84819&r2=84820&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Wed Oct 21 20:01:24 2009
@@ -602,11 +602,13 @@
// Write metadata kinds
// METADATA_KIND - [n x [id, name]]
MetadataContext &TheMetadata = M->getContext().getMetadata();
- const StringMap<unsigned> *Kinds = TheMetadata.getHandlerNames();
- for (StringMap<unsigned>::const_iterator
- I = Kinds->begin(), E = Kinds->end(); I != E; ++I) {
- Record.push_back(I->second);
- StringRef KName = I->first();
+ 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) {
+ Record.push_back(I->first);
+ StringRef KName = I->second;
for (unsigned i = 0, e = KName.size(); i != e; ++i)
Record.push_back(KName[i]);
if (!StartedMetadataBlock) {
Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=84820&r1=84819&r2=84820&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/trunk/lib/VMCore/AsmWriter.cpp Wed Oct 21 20:01:24 2009
@@ -1295,7 +1295,7 @@
TypePrinting TypePrinter;
AssemblyAnnotationWriter *AnnotationWriter;
std::vector<const Type*> NumberedTypes;
- DenseMap<unsigned, const char *> MDNames;
+ DenseMap<unsigned, StringRef> MDNames;
public:
inline AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac,
@@ -1306,11 +1306,12 @@
// FIXME: Provide MDPrinter
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();
+ 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;
}
}
}
Modified: llvm/trunk/lib/VMCore/Metadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=84820&r1=84819&r2=84820&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Metadata.cpp (original)
+++ llvm/trunk/lib/VMCore/Metadata.cpp Wed Oct 21 20:01:24 2009
@@ -305,9 +305,12 @@
}
/// getHandlerNames - Get handler names. This is used by bitcode
-/// writer.
-const StringMap<unsigned> *MetadataContext::getHandlerNames() {
- return &MDHandlerNames;
+/// writer and aswm writer.
+void MetadataContext::
+getHandlerNames(SmallVectorImpl<std::pair<unsigned, StringRef> >&Names) const {
+ for (StringMap<unsigned>::const_iterator I = MDHandlerNames.begin(),
+ E = MDHandlerNames.end(); I != E; ++I)
+ Names.push_back(std::make_pair(I->second, I->first()));
}
/// ValueIsCloned - This handler is used to update metadata store
More information about the llvm-commits
mailing list