https://github.com/artempyanykh updated https://github.com/llvm/llvm-project/pull/129146
>From 52f4ec3ca373c81b7938056c2cd9c3ea890f09fe Mon Sep 17 00:00:00 2001 From: Artem Pianykh <a...@fb.com> Date: Tue, 25 Feb 2025 10:20:06 -0800 Subject: [PATCH] [NFC][Cloning] Make DifferentModule case more obvious in CollectDebugInfoForCloning Summary: This should be behaviorally equivalent. DIFinder is only used when cloning into a DifferentModule as part of llvm.dbg.cu update in CloneFunctionInto. Test Plan: ninja check-llvm-unit check-llvm stack-info: PR: https://github.com/llvm/llvm-project/pull/129146, branch: users/artempyanykh/fast-coro-upstream-part2-take2/4 --- llvm/lib/Transforms/Utils/CloneFunction.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index e03c5c27b5ac1..dd1b4fe718053 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -147,8 +147,10 @@ void llvm::CloneFunctionAttributesInto(Function *NewFunc, DISubprogram *llvm::CollectDebugInfoForCloning(const Function &F, CloneFunctionChangeType Changes, DebugInfoFinder &DIFinder) { - // CloneModule takes care of cloning debug info. - if (Changes == CloneFunctionChangeType::ClonedModule) + // CloneModule takes care of cloning debug info for ClonedModule. Cloning into + // DifferentModule is taken care of separately in ClonedFunctionInto as part + // of llvm.dbg.cu update. + if (Changes >= CloneFunctionChangeType::DifferentModule) return nullptr; DISubprogram *SPClonedWithinModule = nullptr; @@ -362,6 +364,10 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc, SmallPtrSet<const void *, 8> Visited; for (auto *Operand : NMD->operands()) Visited.insert(Operand); + + // Collect and clone all the compile units referenced from the instructions in + // the function (e.g. as a scope). + collectDebugInfoFromInstructions(*OldFunc, DIFinder); for (auto *Unit : DIFinder.compile_units()) { MDNode *MappedUnit = MapMetadata(Unit, VMap, RF_None, TypeMapper, Materializer); _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits