Skip to content

Commit d910e5a

Browse files
authored
[SourceKit] Disable expensive SIL options (#17306)
Disable the sanitizers and code coverage when building a swift invocation for the purpose of collecting diagnostics. This should speed up diagnostic generation and reduce exposure to compiler bugs. rdar://40955900
1 parent 88d305c commit d910e5a

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,9 @@ bool SwiftASTManager::initCompilerInvocation(CompilerInvocation &Invocation,
464464
// We don't care about LLVMArgs
465465
FrontendOpts.LLVMArgs.clear();
466466

467+
// Disable expensive SIL options to reduce time spent in SILGen.
468+
disableExpensiveSILOptions(Invocation.getSILOptions());
469+
467470
return false;
468471
}
469472

tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "swift/AST/ASTVisitor.h"
2020
#include "swift/AST/ClangModuleLoader.h"
21+
#include "swift/AST/SILOptions.h"
2122
#include "swift/AST/USRGeneration.h"
2223
#include "swift/Config.h"
2324
#include "swift/IDE/CodeCompletion.h"
@@ -777,3 +778,13 @@ CloseClangModuleFiles::~CloseClangModuleFiles() {
777778
M->getASTFile()->closeFile();
778779
}
779780
}
781+
782+
void SourceKit::disableExpensiveSILOptions(SILOptions &Opts) {
783+
// Disable the sanitizers.
784+
Opts.Sanitizers = {};
785+
786+
// Disable PGO and code coverage.
787+
Opts.GenerateProfile = false;
788+
Opts.EmitProfileCoverageMapping = false;
789+
Opts.UseProfile = "";
790+
}

tools/SourceKit/lib/SwiftLang/SwiftLangSupport.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespace swift {
3939
class Type;
4040
class AbstractStorageDecl;
4141
class SourceFile;
42+
class SILOptions;
4243
class ValueDecl;
4344
enum class AccessorKind;
4445

@@ -532,6 +533,10 @@ class CloseClangModuleFiles {
532533
~CloseClangModuleFiles();
533534
};
534535

536+
537+
/// Disable expensive SIL options which do not affect indexing or diagnostics.
538+
void disableExpensiveSILOptions(swift::SILOptions &Opts);
539+
535540
} // namespace SourceKit
536541

537542
#endif

0 commit comments

Comments
 (0)