[llvm] r264555 - BitcodeWriter: Split out writeMetadataRecords, NFC
Duncan P. N. Exon Smith via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 27 16:53:31 PDT 2016
Author: dexonsmith
Date: Sun Mar 27 18:53:30 2016
New Revision: 264555
URL: http://llvm.org/viewvc/llvm-project?rev=264555&view=rev
Log:
BitcodeWriter: Split out writeMetadataRecords, NFC
Besides being a nice cleanup, this is preparation for reusing the code
in function metadata blocks.
Modified:
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=264555&r1=264554&r2=264555&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Sun Mar 27 18:53:30 2016
@@ -1391,21 +1391,18 @@ static void writeMetadataStrings(ArrayRe
Record.clear();
}
-static void WriteModuleMetadata(const Module &M,
- const ValueEnumerator &VE,
- BitstreamWriter &Stream) {
- if (VE.getMDs().empty() && M.named_metadata_empty())
+static void writeMetadataRecords(ArrayRef<const Metadata *> MDs,
+ const ValueEnumerator &VE,
+ BitstreamWriter &Stream,
+ SmallVectorImpl<uint64_t> &Record) {
+ if (MDs.empty())
return;
- Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
-
// Initialize MDNode abbreviations.
#define HANDLE_MDNODE_LEAF(CLASS) unsigned CLASS##Abbrev = 0;
#include "llvm/IR/Metadata.def"
- SmallVector<uint64_t, 64> Record;
- writeMetadataStrings(VE.getMDStrings(), Stream, Record);
- for (const Metadata *MD : VE.getNonMDStrings()) {
+ for (const Metadata *MD : MDs) {
if (const MDNode *N = dyn_cast<MDNode>(MD)) {
assert(N->isResolved() && "Expected forward references to be resolved");
@@ -1421,7 +1418,18 @@ static void WriteModuleMetadata(const Mo
}
WriteValueAsMetadata(cast<ConstantAsMetadata>(MD), VE, Stream, Record);
}
+}
+static void WriteModuleMetadata(const Module &M,
+ const ValueEnumerator &VE,
+ BitstreamWriter &Stream) {
+ if (VE.getMDs().empty() && M.named_metadata_empty())
+ return;
+
+ Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
+ SmallVector<uint64_t, 64> Record;
+ writeMetadataStrings(VE.getMDStrings(), Stream, Record);
+ writeMetadataRecords(VE.getNonMDStrings(), VE, Stream, Record);
writeNamedMetadata(M, VE, Stream, Record);
Stream.ExitBlock();
}
More information about the llvm-commits
mailing list