diff options
author | Artem Pianykh <artem.pyanykh@gmail.com> | 2025-03-12 11:19:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-12 11:19:18 +0000 |
commit | 30fa7a231def5a688608a9ae7ec3d8f831b210a0 (patch) | |
tree | ab89ac792ceca5f25d4fdce96e3317ed27edeb8f /llvm/lib/Transforms/Utils/CloneFunction.cpp | |
parent | 77b55c76acebf30d3951788d1651607d5276380e (diff) | |
download | llvm-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.cpp | 10 |
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); |