diff options
author | Chris Lattner <sabre@nondot.org> | 2009-12-28 20:10:43 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-12-28 20:10:43 +0000 |
commit | c9558df1f0144f43c4c6025d2bef4aa2ead518ee (patch) | |
tree | 7054ca51d78baea200dfd59a5efb51f86ef6b000 /llvm/lib/Bitcode/Writer | |
parent | 9a258777a5ad6d509d8167d5cd53bc9d7aaf04f2 (diff) | |
download | bcm5719-llvm-c9558df1f0144f43c4c6025d2bef4aa2ead518ee.tar.gz bcm5719-llvm-c9558df1f0144f43c4c6025d2bef4aa2ead518ee.zip |
rename getHandlerNames to getMDKindNames, simplify its interface
and simplify all the clients that use it.
llvm-svn: 92224
Diffstat (limited to 'llvm/lib/Bitcode/Writer')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index ab514d2cb5b..cf8f7670c72 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -593,35 +593,30 @@ static void WriteMetadataAttachment(const Function &F, Stream.ExitBlock(); } -static void WriteModuleMetadataStore(const Module *M, - const ValueEnumerator &VE, - BitstreamWriter &Stream) { - - bool StartedMetadataBlock = false; +static void WriteModuleMetadataStore(const Module *M, BitstreamWriter &Stream) { SmallVector<uint64_t, 64> Record; // Write metadata kinds // METADATA_KIND - [n x [id, name]] 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) { - 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) { - Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); - StartedMetadataBlock = true; - } + SmallVector<StringRef, 4> Names; + TheMetadata.getMDKindNames(Names); + + assert(Names[0] == "" && "MDKind #0 is invalid"); + if (Names.size() == 1) return; + + Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); + + for (unsigned MDKindID = 1, e = Names.size(); MDKindID != e; ++MDKindID) { + Record.push_back(MDKindID); + StringRef KName = Names[MDKindID]; + Record.append(KName.begin(), KName.end()); + Stream.EmitRecord(bitc::METADATA_KIND, Record, 0); Record.clear(); } - if (StartedMetadataBlock) - Stream.ExitBlock(); + Stream.ExitBlock(); } static void WriteConstants(unsigned FirstVal, unsigned LastVal, @@ -1466,7 +1461,7 @@ static void WriteModule(const Module *M, BitstreamWriter &Stream) { WriteFunction(*I, VE, Stream); // Emit metadata. - WriteModuleMetadataStore(M, VE, Stream); + WriteModuleMetadataStore(M, Stream); // Emit the type symbol table information. WriteTypeSymbolTable(M->getTypeSymbolTable(), VE, Stream); |