Skip to content

Commit 46dfb15

Browse files
committed
[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: #129146, branch: users/artempyanykh/fast-coro-upstream-part2-take2/4
1 parent 29129be commit 46dfb15

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/lib/Transforms/Utils/CloneFunction.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ void llvm::CloneFunctionAttributesInto(Function *NewFunc,
147147
DISubprogram *llvm::CollectDebugInfoForCloning(const Function &F,
148148
CloneFunctionChangeType Changes,
149149
DebugInfoFinder &DIFinder) {
150-
// CloneModule takes care of cloning debug info.
151-
if (Changes == CloneFunctionChangeType::ClonedModule)
150+
// CloneModule takes care of cloning debug info for ClonedModule. Cloning into
151+
// DifferentModule is taken care of separately in ClonedFunctionInto as part
152+
// of llvm.dbg.cu update.
153+
if (Changes >= CloneFunctionChangeType::DifferentModule)
152154
return nullptr;
153155

154156
DISubprogram *SPClonedWithinModule = nullptr;
@@ -362,6 +364,10 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
362364
SmallPtrSet<const void *, 8> Visited;
363365
for (auto *Operand : NMD->operands())
364366
Visited.insert(Operand);
367+
368+
// Collect and clone all the compile units referenced from the instructions in
369+
// the function (e.g. as a scope).
370+
collectDebugInfoFromInstructions(*OldFunc, DIFinder);
365371
for (auto *Unit : DIFinder.compile_units()) {
366372
MDNode *MappedUnit =
367373
MapMetadata(Unit, VMap, RF_None, TypeMapper, Materializer);

0 commit comments

Comments
 (0)