aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-02 15:09:42 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-02 15:09:42 +0000
commit9342911f31ff177052d201f1b78c83ab0783a4d6 (patch)
tree44ce4d55fe1e481d3d9e551f3411358ead70c921 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
parent8742de9b20eb8b1960403842b38dcf0c80aa586b (diff)
downloadllvm-9342911f31ff177052d201f1b78c83ab0783a4d6.zip
llvm-9342911f31ff177052d201f1b78c83ab0783a4d6.tar.gz
llvm-9342911f31ff177052d201f1b78c83ab0783a4d6.tar.bz2
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
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp9
1 files changed, 5 insertions, 4 deletions
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<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();
}