From 9342911f31ff177052d201f1b78c83ab0783a4d6 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sat, 2 Apr 2016 15:09:42 +0000 Subject: 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 --- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp') diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 4ee53b5..26f0ac6 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1429,7 +1429,7 @@ static void writeMetadataRecords(ArrayRef 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 MDs = VE.getFunctionMDs(); - if (MDs.empty()) + if (!VE.hasMDs()) return; Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3); SmallVector Record; - writeMetadataRecords(MDs, VE, Stream, Record); + assert(VE.getMDStrings().empty() && + "Unexpected strings at the function-level"); + writeMetadataRecords(VE.getNonMDStrings(), VE, Stream, Record); Stream.ExitBlock(); } -- cgit v1.1