Derive MDNode from MetadataBase instead of Constant. Emit MDNodes into METADATA_BLOCK in bitcode file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76834 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Devang Patel
2009-07-23 01:07:34 +00:00
parent 0aaf4e91c2
commit 104cf9e02b
17 changed files with 109 additions and 154 deletions

View File

@ -734,6 +734,23 @@ bool BitcodeReader::ParseMetadata() {
switch (Stream.ReadRecord(Code, Record)) {
default: // Default behavior: ignore.
break;
case bitc::METADATA_NODE: {
if (Record.empty() || Record.size() % 2 == 1)
return Error("Invalid METADATA_NODE record");
unsigned Size = Record.size();
SmallVector<Value*, 8> Elts;
for (unsigned i = 0; i != Size; i += 2) {
const Type *Ty = getTypeByID(Record[i], false);
if (Ty != Type::VoidTy)
Elts.push_back(ValueList.getValueFwdRef(Record[i+1], Ty));
else
Elts.push_back(NULL);
}
Value *V = Context.getMDNode(&Elts[0], Elts.size());
ValueList.AssignValue(V, NextValueNo++);
break;
}
case bitc::METADATA_STRING: {
unsigned MDStringLength = Record.size();
SmallString<8> String;
@ -1078,22 +1095,6 @@ bool BitcodeReader::ParseConstants() {
AsmStr, ConstrStr, HasSideEffects);
break;
}
case bitc::CST_CODE_MDNODE: {
if (Record.empty() || Record.size() % 2 == 1)
return Error("Invalid CST_MDNODE record");
unsigned Size = Record.size();
SmallVector<Value*, 8> Elts;
for (unsigned i = 0; i != Size; i += 2) {
const Type *Ty = getTypeByID(Record[i], false);
if (Ty != Type::VoidTy)
Elts.push_back(ValueList.getValueFwdRef(Record[i+1], Ty));
else
Elts.push_back(NULL);
}
V = Context.getMDNode(&Elts[0], Elts.size());
break;
}
}
ValueList.AssignValue(V, NextCstNo);