Skip to content

Commit 80056c1

Browse files
committed
[embedded] Explicitly disable PerfDiags from SourceKit instead of always disabling when WMO is off
1 parent 3ad777b commit 80056c1

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

include/swift/AST/SILOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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

lib/SILOptimizer/Mandatory/PerformanceDiagnostics.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff 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

tools/SourceKit/lib/SwiftLang/SwiftASTManager.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff 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)) {

0 commit comments

Comments
 (0)