static void WriteFunctionLocalMetadata(const Function &F,
const ValueEnumerator &VE,
BitstreamWriter &Stream) {
- bool StartedMetadataBlock = false;
+ ArrayRef<const Metadata *> MDs = VE.getFunctionMDs();
+ if (MDs.empty())
+ return;
+
+ Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
+
SmallVector<uint64_t, 64> Record;
- for (const Metadata *MD : VE.getFunctionMDs()) {
- auto *Local = cast<LocalAsMetadata>(MD);
- if (!StartedMetadataBlock) {
- Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
- StartedMetadataBlock = true;
- }
- WriteValueAsMetadata(Local, VE, Stream, Record);
- }
+ for (const Metadata *MD : VE.getFunctionMDs())
+ WriteValueAsMetadata(cast<LocalAsMetadata>(MD), VE, Stream, Record);
- if (StartedMetadataBlock)
- Stream.ExitBlock();
+ Stream.ExitBlock();
}
static void WriteMetadataAttachment(const Function &F,