[NFCI] cleanup CloneFunctionInto

Hoist early return for decl-only clones to before DIFinder
calculation.
Also fix an out of date assert message after invariants changed in
22a52dfddc.

Reviewed by: nikic, dexonsmith
Differential Revisision: https://reviews.llvm.org/D98957
This commit is contained in:
Luke Drummond 2021-03-23 11:27:29 +00:00
parent 39e36fff3d
commit 0448ddd169
1 changed files with 6 additions and 6 deletions

View File

@ -125,6 +125,11 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
AttributeList::get(NewFunc->getContext(), OldAttrs.getFnAttributes(),
OldAttrs.getRetAttributes(), NewArgAttrs));
// Everything else beyond this point deals with function instructions,
// so if we are dealing with a function declaration, we're done.
if (OldFunc->isDeclaration())
return;
// When we remap instructions within the same module, we want to avoid
// duplicating inlined DISubprograms, so record all subprograms we find as we
// duplicate instructions and then freeze them in the MD map. We also record
@ -149,7 +154,7 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
} else {
assert((NewFunc->getParent() == nullptr ||
NewFunc->getParent() != OldFunc->getParent()) &&
"Set SameModule to true if the new function is in the same module");
"Expected NewFunc to have different parents, or no parent");
if (Changes == CloneFunctionChangeType::DifferentModule) {
assert(NewFunc->getParent() &&
@ -160,11 +165,6 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
}
}
// Everything else beyond this point deals with function instructions,
// so if we are dealing with a function declaration, we're done.
if (OldFunc->isDeclaration())
return;
// Loop over all of the basic blocks in the function, cloning them as
// appropriate. Note that we save BE this way in order to handle cloning of
// recursive functions into themselves.