diff options
author | Luke Drummond <luke.drummond@codeplay.com> | 2021-03-23 11:27:29 +0000 |
---|---|---|
committer | Luke Drummond <luke.drummond@codeplay.com> | 2021-03-23 12:53:27 +0000 |
commit | 0448ddd169ef3f05c6ec88828565f27b2bcd9b00 (patch) | |
tree | 0735ed67fda42e6303fe8f5c3f6be557fcb62100 /llvm/lib/Transforms/Utils/CloneFunction.cpp | |
parent | 39e36fff3d09310f5fceccc049da412de75e4656 (diff) | |
download | llvm-0448ddd169ef3f05c6ec88828565f27b2bcd9b00.zip llvm-0448ddd169ef3f05c6ec88828565f27b2bcd9b00.tar.gz llvm-0448ddd169ef3f05c6ec88828565f27b2bcd9b00.tar.bz2 |
[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
22a52dfddce.
Reviewed by: nikic, dexonsmith
Differential Revisision: https://reviews.llvm.org/D98957
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/CloneFunction.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index 0ff28e9..9d5922a 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -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. |