Add support for remapping metadata kind IDs when reading in a

bitcode file, so that two bitcode files where the same metadata kind
name happens to have been assigned a different ID can still be
linked together.

Eliminate the restriction that metadata kind IDs can't be 0.

Change MD_dbg from 1 to 0, because we can now, and because it's
less mysterious that way.

llvm-svn: 108939
This commit is contained in:
Dan Gohman
2010-07-20 21:42:28 +00:00
parent c3eb5e3d4b
commit 43aa8f03c1
5 changed files with 19 additions and 16 deletions

View File

@@ -634,12 +634,11 @@ static void WriteModuleMetadataStore(const Module *M, BitstreamWriter &Stream) {
SmallVector<StringRef, 4> Names;
M->getMDKindNames(Names);
assert(Names[0] == "" && "MDKind #0 is invalid");
if (Names.size() == 1) return;
if (Names.empty()) return;
Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
for (unsigned MDKindID = 1, e = Names.size(); MDKindID != e; ++MDKindID) {
for (unsigned MDKindID = 0, e = Names.size(); MDKindID != e; ++MDKindID) {
Record.push_back(MDKindID);
StringRef KName = Names[MDKindID];
Record.append(KName.begin(), KName.end());