aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/CloneFunction.cpp
diff options
context:
space:
mode:
authorArtem Pianykh <artem.pyanykh@gmail.com>2025-03-12 11:19:18 +0000
committerGitHub <noreply@github.com>2025-03-12 11:19:18 +0000
commit30fa7a231def5a688608a9ae7ec3d8f831b210a0 (patch)
treeab89ac792ceca5f25d4fdce96e3317ed27edeb8f /llvm/lib/Transforms/Utils/CloneFunction.cpp
parent77b55c76acebf30d3951788d1651607d5276380e (diff)
downloadllvm-30fa7a231def5a688608a9ae7ec3d8f831b210a0.zip
llvm-30fa7a231def5a688608a9ae7ec3d8f831b210a0.tar.gz
llvm-30fa7a231def5a688608a9ae7ec3d8f831b210a0.tar.bz2
[NFC][Cloning] Make DifferentModule case more obvious in CollectDebugInfoForCloning (#129146)
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
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/CloneFunction.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index e03c5c2..dd1b4fe 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);