BitcodeWriter: Further unify function metadata, NFC

Further unify the handling of function-local metadata with global
metadata, by exposing the same interface in ValueEnumerator.  Both
contexts use the same accessors:

  - getMDStrings(): get the strings for this block.
  - getNonMDStrings(): get the non-strings for this block.

A future commit will start adding strings to the function-block.

llvm-svn: 265224
This commit is contained in:
Duncan P. N. Exon Smith
2016-04-02 15:09:42 +00:00
parent 8742de9b20
commit 9342911f31
3 changed files with 17 additions and 12 deletions

View File

@@ -1429,7 +1429,7 @@ static void writeMetadataRecords(ArrayRef<const Metadata *> MDs,
static void writeModuleMetadata(const Module &M,
const ValueEnumerator &VE,
BitstreamWriter &Stream) {
if (VE.getMDs().empty() && M.named_metadata_empty())
if (!VE.hasMDs() && M.named_metadata_empty())
return;
Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
@@ -1442,13 +1442,14 @@ static void writeModuleMetadata(const Module &M,
static void writeFunctionMetadata(const Function &F, const ValueEnumerator &VE,
BitstreamWriter &Stream) {
ArrayRef<const Metadata *> MDs = VE.getFunctionMDs();
if (MDs.empty())
if (!VE.hasMDs())
return;
Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
SmallVector<uint64_t, 64> Record;
writeMetadataRecords(MDs, VE, Stream, Record);
assert(VE.getMDStrings().empty() &&
"Unexpected strings at the function-level");
writeMetadataRecords(VE.getNonMDStrings(), VE, Stream, Record);
Stream.ExitBlock();
}