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

View File

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