-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[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
[NFC][Cloning] Simplify the flow in FindDebugInfoToIdentityMap #129144
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
@llvm/pr-subscribers-llvm-transforms Author: Artem Pianykh (artempyanykh) Changes[NFC][Cloning] Simplify the flow in FindDebugInfoToIdentityMap Summary: Test Plan: Full diff: https://github.com/llvm/llvm-project/pull/129144.diff 1 Files Affected:
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;
}
|
7cc5e27
to
eefce02
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice simplification
eefce02
to
7888809
Compare
7888809
to
36480c7
Compare
Stacked PRs:
[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