mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-16 12:24:03 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108939 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -39,6 +39,7 @@ void BitcodeReader::FreeState() {
|
||||
std::vector<BasicBlock*>().swap(FunctionBBs);
|
||||
std::vector<Function*>().swap(FunctionsWithBodies);
|
||||
DeferredFunctionInfo.clear();
|
||||
MDKindMap.clear();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -859,13 +860,12 @@ bool BitcodeReader::ParseMetadata() {
|
||||
SmallString<8> Name;
|
||||
Name.resize(RecordLength-1);
|
||||
unsigned Kind = Record[0];
|
||||
(void) Kind;
|
||||
for (unsigned i = 1; i != RecordLength; ++i)
|
||||
Name[i-1] = Record[i];
|
||||
|
||||
unsigned NewKind = TheModule->getMDKindID(Name.str());
|
||||
assert(Kind == NewKind &&
|
||||
"FIXME: Unable to handle custom metadata mismatch!");(void)NewKind;
|
||||
if (!MDKindMap.insert(std::make_pair(Kind, NewKind)).second)
|
||||
return Error("Conflicting METADATA_KIND records");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1621,8 +1621,12 @@ bool BitcodeReader::ParseMetadataAttachment() {
|
||||
Instruction *Inst = InstructionList[Record[0]];
|
||||
for (unsigned i = 1; i != RecordLength; i = i+2) {
|
||||
unsigned Kind = Record[i];
|
||||
DenseMap<unsigned, unsigned>::iterator I =
|
||||
MDKindMap.find(Kind);
|
||||
if (I == MDKindMap.end())
|
||||
return Error("Invalid metadata kind ID");
|
||||
Value *Node = MDValueList.getValueFwdRef(Record[i+1]);
|
||||
Inst->setMetadata(Kind, cast<MDNode>(Node));
|
||||
Inst->setMetadata(I->second, cast<MDNode>(Node));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user