[llvm] [NFC][Cloning] Make ClonedModule case more obvious in CollectDebugInfoForCloning (PR #129143)

Artem Pianykh via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 9 07:30:22 PDT 2025


https://github.com/artempyanykh updated https://github.com/llvm/llvm-project/pull/129143

>From 336c0203871da8d76dc20dd8fdd6c2e2a8cd52f6 Mon Sep 17 00:00:00 2001
From: Artem Pianykh <arr at fb.com>
Date: Tue, 25 Feb 2025 09:55:02 -0800
Subject: [PATCH] [NFC][Cloning] Make ClonedModule case more obvious in
 CollectDebugInfoForCloning

Summary:
The code's behavior is unchanged, but it's more obvious right now.

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

stack-info: PR: https://github.com/llvm/llvm-project/pull/129143, branch: users/artempyanykh/fast-coro-upstream-part2-take2/1
---
 llvm/lib/Transforms/Utils/CloneFunction.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 58d400ac396be..9267930027c04 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -135,6 +135,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)
+    return nullptr;
+
   DISubprogram *SPClonedWithinModule = nullptr;
   if (Changes < CloneFunctionChangeType::DifferentModule) {
     SPClonedWithinModule = F.getSubprogram();
@@ -143,7 +147,7 @@ DISubprogram *llvm::CollectDebugInfoForCloning(const Function &F,
     DIFinder.processSubprogram(SPClonedWithinModule);
 
   const Module *M = F.getParent();
-  if (Changes != CloneFunctionChangeType::ClonedModule && M) {
+  if (M) {
     // Inspect instructions to process e.g. DILexicalBlocks of inlined functions
     for (const auto &I : instructions(F))
       DIFinder.processInstruction(*M, I);



More information about the llvm-commits mailing list