Skip to content

[NFC][Cloning] Simplify the flow in FindDebugInfoToIdentityMap #129144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Summary:
The new flow should make it more clear what is happening in cases of
Different of Cloned modules.

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

stack-info: PR: #129144, branch: users/artempyanykh/fast-coro-upstream-part2-take2/2
@llvmbot
Copy link
Member

llvmbot commented Feb 27, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Artem Pianykh (artempyanykh)

Changes

[NFC][Cloning] Simplify the flow in FindDebugInfoToIdentityMap

Summary:
The new flow should make it more clear what is happening in cases of
Different of Cloned modules.

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


Full diff: https://github.com/llvm/llvm-project/pull/129144.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Utils/CloneFunction.cpp (+16-16)
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp
index 9267930027c04..5a5b84c8e0a3c 100644
--- a/llvm/lib/Transforms/Utils/CloneFunction.cpp
+++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp
@@ -160,21 +160,25 @@ MetadataSetTy
 llvm::FindDebugInfoToIdentityMap(CloneFunctionChangeType Changes,
                                  DebugInfoFinder &DIFinder,
                                  DISubprogram *SPClonedWithinModule) {
+  if (Changes >= CloneFunctionChangeType::DifferentModule)
+    return {};
+
+  if (DIFinder.subprogram_count() == 0)
+    assert(!SPClonedWithinModule &&
+           "Subprogram should be in DIFinder->subprogram_count()...");
+
   MetadataSetTy MD;
 
-  if (Changes < CloneFunctionChangeType::DifferentModule &&
-      DIFinder.subprogram_count() > 0) {
-    // Avoid cloning types, compile units, and (other) subprograms.
-    for (DISubprogram *ISP : DIFinder.subprograms()) {
-      if (ISP != SPClonedWithinModule)
-        MD.insert(ISP);
-    }
+  // Avoid cloning types, compile units, and (other) subprograms.
+  for (DISubprogram *ISP : DIFinder.subprograms())
+    if (ISP != SPClonedWithinModule)
+      MD.insert(ISP);
 
-    // If a subprogram isn't going to be cloned skip its lexical blocks as well.
-    for (DIScope *S : DIFinder.scopes()) {
-      auto *LScope = dyn_cast<DILocalScope>(S);
-      if (LScope && LScope->getSubprogram() != SPClonedWithinModule)
-        MD.insert(S);
+  // If a subprogram isn't going to be cloned skip its lexical blocks as well.
+  for (DIScope *S : DIFinder.scopes()) {
+    auto *LScope = dyn_cast<DILocalScope>(S);
+    if (LScope && LScope->getSubprogram() != SPClonedWithinModule)
+      MD.insert(S);
     }
 
     for (DICompileUnit *CU : DIFinder.compile_units())
@@ -182,10 +186,6 @@ llvm::FindDebugInfoToIdentityMap(CloneFunctionChangeType Changes,
 
     for (DIType *Type : DIFinder.types())
       MD.insert(Type);
-  } else {
-    assert(!SPClonedWithinModule &&
-           "Subprogram should be in DIFinder->subprogram_count()...");
-  }
 
   return MD;
 }

Copy link

github-actions bot commented Feb 27, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

jollaitbot pushed a commit to sailfishos-mirror/llvm-project that referenced this pull request Feb 28, 2025
Summary:
The new flow should make it more clear what is happening in cases of
Different of Cloned modules.

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

stack-info: PR: llvm/llvm-project#129144, branch: users/artempyanykh/fast-coro-upstream-part2-take2/2
Copy link
Contributor

@felipepiovezan felipepiovezan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice simplification

@artempyanykh artempyanykh changed the base branch from users/artempyanykh/fast-coro-upstream-part2-take2/1 to main March 9, 2025 14:29
@artempyanykh artempyanykh force-pushed the users/artempyanykh/fast-coro-upstream-part2-take2/2 branch from eefce02 to 7888809 Compare March 9, 2025 14:30
@artempyanykh artempyanykh changed the base branch from main to users/artempyanykh/fast-coro-upstream-part2-take2/1 March 9, 2025 14:30
@artempyanykh artempyanykh changed the base branch from users/artempyanykh/fast-coro-upstream-part2-take2/1 to main March 9, 2025 14:32
@artempyanykh artempyanykh changed the base branch from main to users/artempyanykh/fast-coro-upstream-part2-take2/1 March 9, 2025 14:32
Base automatically changed from users/artempyanykh/fast-coro-upstream-part2-take2/1 to main March 9, 2025 15:49
@artempyanykh artempyanykh force-pushed the users/artempyanykh/fast-coro-upstream-part2-take2/2 branch from 7888809 to 36480c7 Compare March 9, 2025 15:49
@artempyanykh artempyanykh merged commit df570da into main Mar 9, 2025
11 checks passed
@artempyanykh artempyanykh deleted the users/artempyanykh/fast-coro-upstream-part2-take2/2 branch March 9, 2025 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants