forked from OSchip/llvm-project
Bitcode: Add abbreviation for METADATA_NAME
llvm-svn: 225715
This commit is contained in:
parent
f8dd6ad6de
commit
b1ad5d39a9
|
@ -798,6 +798,16 @@ static void WriteModuleMetadata(const Module *M,
|
|||
MDSAbbrev = Stream.EmitAbbrev(Abbv);
|
||||
}
|
||||
|
||||
unsigned NameAbbrev = 0;
|
||||
if (!M->named_metadata_empty()) {
|
||||
// Abbrev for METADATA_NAME.
|
||||
BitCodeAbbrev *Abbv = new BitCodeAbbrev();
|
||||
Abbv->Add(BitCodeAbbrevOp(bitc::METADATA_NAME));
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
|
||||
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
|
||||
NameAbbrev = Stream.EmitAbbrev(Abbv);
|
||||
}
|
||||
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
for (const Metadata *MD : MDs) {
|
||||
if (const MDNode *N = dyn_cast<MDNode>(MD)) {
|
||||
|
@ -821,9 +831,8 @@ static void WriteModuleMetadata(const Module *M,
|
|||
for (const NamedMDNode &NMD : M->named_metadata()) {
|
||||
// Write name.
|
||||
StringRef Str = NMD.getName();
|
||||
for (unsigned i = 0, e = Str.size(); i != e; ++i)
|
||||
Record.push_back(Str[i]);
|
||||
Stream.EmitRecord(bitc::METADATA_NAME, Record, 0/*TODO*/);
|
||||
Record.append(Str.bytes_begin(), Str.bytes_end());
|
||||
Stream.EmitRecord(bitc::METADATA_NAME, Record, NameAbbrev);
|
||||
Record.clear();
|
||||
|
||||
// Write named metadata operands.
|
||||
|
|
Loading…
Reference in New Issue