Skip to content

Commit a0e5e41

Browse files
committed
[Perf] Improve dirty AST rebuild speed 2.56x on many-core machines
On many-core machines, the files that take the longest to compile are build bottlenecks. With this change, we workaround clang scaling problems compiling large llvm::StringSwitch expressions and bring the "touch tools/swift/include/swift/AST/* ; time ninja swift" time down from 1m43.24s down to 40.26s. I've also benchmarked rebuilding Swift.o after this change. The before and after seems to be deep in the noise.
1 parent ac001c7 commit a0e5e41

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

lib/AST/Builtins.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,11 +1604,11 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
16041604
return getAllocWithTailElemsOperation(Context, Id, NumTailTypes);
16051605
}
16061606

1607-
BuiltinValueKind BV = llvm::StringSwitch<BuiltinValueKind>(OperationName)
1607+
auto BV = BuiltinValueKind::None;
16081608
#define BUILTIN(id, name, Attrs) \
1609-
.Case(name, BuiltinValueKind::id)
1609+
if (name == OperationName) { BV = BuiltinValueKind::id; } else
16101610
#include "swift/AST/Builtins.def"
1611-
.Default(BuiltinValueKind::None);
1611+
/* final "else" */ {}
16121612

16131613
// Filter out inappropriate overloads.
16141614
OverloadedBuiltinKind OBK = OverloadedBuiltinKinds[unsigned(BV)];

lib/SIL/SILModule.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,10 @@ const BuiltinInfo &SILModule::getBuiltinInfo(Identifier ID) {
455455
Info.ID = BuiltinValueKind::AllocWithTailElems;
456456
else {
457457
// Switch through the rest of builtins.
458-
Info.ID = llvm::StringSwitch<BuiltinValueKind>(OperationName)
459-
#define BUILTIN(ID, Name, Attrs) \
460-
.Case(Name, BuiltinValueKind::ID)
458+
#define BUILTIN(Id, Name, Attrs) \
459+
if (OperationName == Name) { Info.ID = BuiltinValueKind::Id; } else
461460
#include "swift/AST/Builtins.def"
462-
.Default(BuiltinValueKind::None);
461+
/* final "else" */ { Info.ID = BuiltinValueKind::None; }
463462
}
464463

465464
return Info;

0 commit comments

Comments
 (0)