Skip to content

Commit 36b445a

Browse files
committed
[NFC][Cloning] Add a helper to collect debug info from instructions
Summary: Just moving around. This helper will be used for further refactoring. Test Plan: ninja check-llvm-unit check-llvm
1 parent 7cc5e27 commit 36b445a

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

llvm/lib/Transforms/Utils/CloneFunction.cpp

+13-6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ using namespace llvm;
4040

4141
#define DEBUG_TYPE "clone-function"
4242

43+
namespace {
44+
void collectDebugInfoFromInstructions(const Function &F,
45+
DebugInfoFinder &DIFinder) {
46+
const Module *M = F.getParent();
47+
if (M) {
48+
// Inspect instructions to process e.g. DILexicalBlocks of inlined functions
49+
for (const auto &I : instructions(F))
50+
DIFinder.processInstruction(*M, I);
51+
}
52+
}
53+
} // namespace
54+
4355
/// See comments in Cloning.h.
4456
BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap,
4557
const Twine &NameSuffix, Function *F,
@@ -146,12 +158,7 @@ DISubprogram *llvm::CollectDebugInfoForCloning(const Function &F,
146158
if (SPClonedWithinModule)
147159
DIFinder.processSubprogram(SPClonedWithinModule);
148160

149-
const Module *M = F.getParent();
150-
if (M) {
151-
// Inspect instructions to process e.g. DILexicalBlocks of inlined functions
152-
for (const auto &I : instructions(F))
153-
DIFinder.processInstruction(*M, I);
154-
}
161+
collectDebugInfoFromInstructions(F, DIFinder);
155162

156163
return SPClonedWithinModule;
157164
}

0 commit comments

Comments
 (0)