Skip to content

Commit

Permalink
[NFC][Cloning] Add a helper to collect debug info from instructions
Browse files Browse the repository at this point in the history
Summary:
Just moving around. This helper will be used for further refactoring.

Test Plan:
ninja check-llvm-unit check-llvm

stack-info: PR: #129145, branch: users/artempyanykh/fast-coro-upstream-part2-take2/3
  • Loading branch information
artempyanykh committed Feb 27, 2025
1 parent eefce02 commit dd91189
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions llvm/lib/Transforms/Utils/CloneFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ using namespace llvm;

#define DEBUG_TYPE "clone-function"

namespace {
void collectDebugInfoFromInstructions(const Function &F,
DebugInfoFinder &DIFinder) {
const Module *M = F.getParent();
if (M) {
// Inspect instructions to process e.g. DILexicalBlocks of inlined functions
for (const auto &I : instructions(F))
DIFinder.processInstruction(*M, I);
}
}
} // namespace

/// See comments in Cloning.h.
BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap,
const Twine &NameSuffix, Function *F,
Expand Down Expand Up @@ -146,12 +158,7 @@ DISubprogram *llvm::CollectDebugInfoForCloning(const Function &F,
if (SPClonedWithinModule)
DIFinder.processSubprogram(SPClonedWithinModule);

const Module *M = F.getParent();
if (M) {
// Inspect instructions to process e.g. DILexicalBlocks of inlined functions
for (const auto &I : instructions(F))
DIFinder.processInstruction(*M, I);
}
collectDebugInfoFromInstructions(F, DIFinder);

return SPClonedWithinModule;
}
Expand Down

0 comments on commit dd91189

Please sign in to comment.