Use early return to simplify code (NFC)

Follow on to r258405.

llvm-svn: 258407
This commit is contained in:
Teresa Johnson 2016-01-21 17:16:53 +00:00
parent 61035fa3cb
commit f5aa64f25f
1 changed files with 21 additions and 22 deletions
llvm/lib/Linker

View File

@ -660,7 +660,8 @@ Metadata *IRLinker::mapTemporaryMetadata(Metadata *MD) {
// If this temporary metadata has a value id recorded during function // If this temporary metadata has a value id recorded during function
// parsing, record that in the ValIDToTempMDMap if one was provided. // parsing, record that in the ValIDToTempMDMap if one was provided.
auto I = MetadataToIDs.find(MD); auto I = MetadataToIDs.find(MD);
if (I != MetadataToIDs.end()) { if (I == MetadataToIDs.end())
return nullptr;
unsigned Idx = I->second; unsigned Idx = I->second;
MDNode *Node = cast<MDNode>(MD); MDNode *Node = cast<MDNode>(MD);
assert(Node->isTemporary()); assert(Node->isTemporary());
@ -668,8 +669,6 @@ Metadata *IRLinker::mapTemporaryMetadata(Metadata *MD) {
// this module, reuse the same temporary metadata. // this module, reuse the same temporary metadata.
auto IterBool = ValIDToTempMDMap->insert(std::make_pair(Idx, Node)); auto IterBool = ValIDToTempMDMap->insert(std::make_pair(Idx, Node));
return IterBool.first->second; return IterBool.first->second;
}
return nullptr;
} }
void IRLinker::replaceTemporaryMetadata(const Metadata *OrigMD, void IRLinker::replaceTemporaryMetadata(const Metadata *OrigMD,
@ -685,7 +684,8 @@ void IRLinker::replaceTemporaryMetadata(const Metadata *OrigMD,
// metadata has a value id recorded during metadata parsing, replace // metadata has a value id recorded during metadata parsing, replace
// the temporary metadata with the final mapped metadata now. // the temporary metadata with the final mapped metadata now.
auto I = MetadataToIDs.find(OrigMD); auto I = MetadataToIDs.find(OrigMD);
if (I != MetadataToIDs.end()) { if (I == MetadataToIDs.end())
return;
unsigned Idx = I->second; unsigned Idx = I->second;
auto VI = ValIDToTempMDMap->find(Idx); auto VI = ValIDToTempMDMap->find(Idx);
// Nothing to do if we didn't need to create a temporary metadata during // Nothing to do if we didn't need to create a temporary metadata during
@ -696,7 +696,6 @@ void IRLinker::replaceTemporaryMetadata(const Metadata *OrigMD,
TempMD->replaceAllUsesWith(NewMD); TempMD->replaceAllUsesWith(NewMD);
MDNode::deleteTemporary(TempMD); MDNode::deleteTemporary(TempMD);
ValIDToTempMDMap->erase(VI); ValIDToTempMDMap->erase(VI);
}
} }
bool IRLinker::isMetadataNeeded(Metadata *MD) { bool IRLinker::isMetadataNeeded(Metadata *MD) {