BitcodeWriter: Restructure WriteFunctionLocalMetadata, NFC

Use an early return to simplify logic.

llvm-svn: 264554
This commit is contained in:
Duncan P. N. Exon Smith 2016-03-27 23:38:36 +00:00
parent 0f57145845
commit 5465f0adc4
1 changed files with 10 additions and 12 deletions

View File

@ -1429,19 +1429,17 @@ static void WriteModuleMetadata(const Module &M,
static void WriteFunctionLocalMetadata(const Function &F,
const ValueEnumerator &VE,
BitstreamWriter &Stream) {
bool StartedMetadataBlock = false;
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);
}
ArrayRef<const Metadata *> MDs = VE.getFunctionMDs();
if (MDs.empty())
return;
if (StartedMetadataBlock)
Stream.ExitBlock();
Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
SmallVector<uint64_t, 64> Record;
for (const Metadata *MD : VE.getFunctionMDs())
WriteValueAsMetadata(cast<LocalAsMetadata>(MD), VE, Stream, Record);
Stream.ExitBlock();
}
static void WriteMetadataAttachment(const Function &F,