@@ -160,32 +160,32 @@ MetadataSetTy
160160llvm::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);
178- }
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);
182+ }
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