[llvm] [Utils] Extract ProcessSubprogramAttachment from CloneFunctionInto (PR #114537)
Felipe de Azevedo Piovezan via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 11 11:51:32 PST 2024
================
@@ -137,6 +137,29 @@ void llvm::CloneFunctionAttributesInto(Function *NewFunc,
OldAttrs.getRetAttrs(), NewArgAttrs));
}
+DISubprogram *llvm::ProcessSubprogramAttachment(const Function &F,
+ CloneFunctionChangeType Changes,
+ DebugInfoFinder &DIFinder) {
+ DISubprogram *SPClonedWithinModule = nullptr;
+ if (Changes < CloneFunctionChangeType::DifferentModule) {
+ SPClonedWithinModule = F.getSubprogram();
+ }
+ if (SPClonedWithinModule)
+ DIFinder.processSubprogram(SPClonedWithinModule);
+
+ const Module *M = F.getParent();
+ if (Changes != CloneFunctionChangeType::ClonedModule && M) {
+ // Inspect instructions to process e.g. DILexicalBlocks of inlined functions
+ for (const auto &BB : F) {
+ for (const auto &I : BB) {
+ DIFinder.processInstruction(*M, I);
+ }
----------------
felipepiovezan wrote:
```
for (const auto &I : instructions(F))
DIFinder...
```
[No need to go over BBs](https://llvm.org/doxygen/InstIterator_8h.html), also [no braces in single-line blocks](https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements)
https://github.com/llvm/llvm-project/pull/114537
More information about the llvm-commits
mailing list