diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index cde1ce8b43dbd..b411d4cb87fd4 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -266,8 +266,6 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc, if (OldFunc->isDeclaration()) return; - DebugInfoFinder DIFinder; - if (Changes < CloneFunctionChangeType::DifferentModule) { assert((NewFunc->getParent() == nullptr || NewFunc->getParent() == OldFunc->getParent()) && @@ -320,7 +318,8 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc, Visited.insert(Operand); // Collect and clone all the compile units referenced from the instructions in - // the function (e.g. as a scope). + // the function (e.g. as instructions' scope). + DebugInfoFinder DIFinder; collectDebugInfoFromInstructions(*OldFunc, DIFinder); for (auto *Unit : DIFinder.compile_units()) { MDNode *MappedUnit =