File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed
lib/SILOptimizer/Mandatory
tools/SourceKit/lib/SwiftLang Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,10 @@ class SILOptions {
150150 // / Enables SIL-level diagnostics for NonescapableTypes.
151151 bool EnableLifetimeDependenceDiagnostics = true ;
152152
153+ // / Enables SIL-level performance diagnostics (for @noLocks, @noAllocation
154+ // / annotations and for Embedded Swift).
155+ bool EnablePerformanceDiagnostics = true ;
156+
153157 // / Controls whether or not paranoid verification checks are run.
154158 bool VerifyAll = false ;
155159
Original file line number Diff line number Diff line change @@ -805,9 +805,10 @@ class PerformanceDiagnosticsPass : public SILModuleTransform {
805805 void run () override {
806806 SILModule *module = getModule ();
807807
808- // Skip all performance/embedded diagnostics if not in WMO mode. Building in
809- // non-WMO mode currently results in false positives.
810- if (!module ->isWholeModule ()) return ;
808+ // Skip all performance/embedded diagnostics if asked. This is used from
809+ // SourceKit to avoid reporting false positives when WMO is turned off for
810+ // indexing purposes.
811+ if (!module ->getOptions ().EnablePerformanceDiagnostics ) return ;
811812
812813 PerformanceDiagnostics diagnoser (*module , getAnalysis<BasicCalleeAnalysis>());
813814
Original file line number Diff line number Diff line change @@ -1219,6 +1219,11 @@ ASTUnitRef ASTBuildOperation::buildASTUnit(std::string &Error) {
12191219 // flag and might thus fail, which SILGen cannot handle.
12201220 llvm::SaveAndRestore<std::shared_ptr<std::atomic<bool >>> DisableCancellationDuringSILGen (CompIns.getASTContext ().CancellationFlag , nullptr );
12211221 SILOptions SILOpts = Invocation.getSILOptions ();
1222+
1223+ // Disable PerformanceDiagnostics SIL pass, which in some cases requires
1224+ // WMO (e.g. for Embedded Swift diags) but SourceKit compiles without WMO.
1225+ SILOpts.EnablePerformanceDiagnostics = false ;
1226+
12221227 auto &TC = CompIns.getSILTypes ();
12231228 std::unique_ptr<SILModule> SILMod = performASTLowering (*SF, TC, SILOpts);
12241229 if (CancellationFlag->load (std::memory_order_relaxed)) {
You can’t perform that action at this time.
0 commit comments