Skip to content

Commit 7cc5e27

Browse files
committed
[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
1 parent 6fc0fa0 commit 7cc5e27

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

llvm/lib/Transforms/Utils/CloneFunction.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -160,32 +160,32 @@ MetadataSetTy
160160
llvm::FindDebugInfoToIdentityMap(CloneFunctionChangeType Changes,
161161
DebugInfoFinder &DIFinder,
162162
DISubprogram *SPClonedWithinModule) {
163+
if (Changes >= CloneFunctionChangeType::DifferentModule)
164+
return {};
165+
166+
if (DIFinder.subprogram_count() == 0)
167+
assert(!SPClonedWithinModule &&
168+
"Subprogram should be in DIFinder->subprogram_count()...");
169+
163170
MetadataSetTy MD;
164171

165-
if (Changes < CloneFunctionChangeType::DifferentModule &&
166-
DIFinder.subprogram_count() > 0) {
167-
// Avoid cloning types, compile units, and (other) subprograms.
168-
for (DISubprogram *ISP : DIFinder.subprograms()) {
169-
if (ISP != SPClonedWithinModule)
170-
MD.insert(ISP);
171-
}
172+
// Avoid cloning types, compile units, and (other) subprograms.
173+
for (DISubprogram *ISP : DIFinder.subprograms())
174+
if (ISP != SPClonedWithinModule)
175+
MD.insert(ISP);
172176

173-
// If a subprogram isn't going to be cloned skip its lexical blocks as well.
174-
for (DIScope *S : DIFinder.scopes()) {
175-
auto *LScope = dyn_cast<DILocalScope>(S);
176-
if (LScope && LScope->getSubprogram() != SPClonedWithinModule)
177-
MD.insert(S);
177+
// If a subprogram isn't going to be cloned skip its lexical blocks as well.
178+
for (DIScope *S : DIFinder.scopes()) {
179+
auto *LScope = dyn_cast<DILocalScope>(S);
180+
if (LScope && LScope->getSubprogram() != SPClonedWithinModule)
181+
MD.insert(S);
178182
}
179183

180184
for (DICompileUnit *CU : DIFinder.compile_units())
181185
MD.insert(CU);
182186

183187
for (DIType *Type : DIFinder.types())
184188
MD.insert(Type);
185-
} else {
186-
assert(!SPClonedWithinModule &&
187-
"Subprogram should be in DIFinder->subprogram_count()...");
188-
}
189189

190190
return MD;
191191
}

0 commit comments

Comments
 (0)