Skip to content

Commit 2b7849d

Browse files
authored
Merge pull request swiftlang#31272 from martinboehme/optimize-emit-clang-decl
[IRGen] Check as early as possible for Clang decls we've seen before.
2 parents 5d9817a + 0e75f37 commit 2b7849d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/IRGen/GenClangDecl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ clang::Decl *getDeclWithExecutableCode(clang::Decl *decl) {
5959
} // end anonymous namespace
6060

6161
void IRGenModule::emitClangDecl(const clang::Decl *decl) {
62+
// Ignore this decl if we've seen it before.
63+
if (!GlobalClangDecls.insert(decl->getCanonicalDecl()).second)
64+
return;
65+
6266
// Fast path for the case where `decl` doesn't contain executable code, so it
6367
// can't reference any other declarations that we would need to emit.
6468
if (getDeclWithExecutableCode(const_cast<clang::Decl *>(decl)) == nullptr) {
@@ -67,8 +71,6 @@ void IRGenModule::emitClangDecl(const clang::Decl *decl) {
6771
return;
6872
}
6973

70-
if (!GlobalClangDecls.insert(decl->getCanonicalDecl()).second)
71-
return;
7274
SmallVector<const clang::Decl *, 8> stack;
7375
stack.push_back(decl);
7476

0 commit comments

Comments
 (0)