Skip to content

Commit 3ad777b

Browse files
committed
[embedded] Don't produce PerfDiags when in non-WMO mode (e.g. when building during indexing)
1 parent 2b17ed2 commit 3ad777b

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/SILOptimizer/Mandatory/PerformanceDiagnostics.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +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;
811+
808812
PerformanceDiagnostics diagnoser(*module, getAnalysis<BasicCalleeAnalysis>());
809813

810814
// Check that @_section, @_silgen_name is only on constant globals
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Check that when emitting diagnostics in SourceKit, we don't report false positives in PerformanceDiagnostics (because WMO is disabled).
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: split-file %s %t
5+
6+
// RUN: %sourcekitd-test -req=diags %t/file1.swift -- %t/file1.swift %t/file2.swift -enable-experimental-feature Embedded | %FileCheck %s
7+
8+
// REQUIRES: swift_in_compiler
9+
// REQUIRES: embedded_stdlib
10+
// REQUIRES: OS=macosx || OS=linux-gnu
11+
12+
//--- file1.swift
13+
14+
func foo() {
15+
bar(Int.self)
16+
}
17+
18+
@main
19+
struct Main {
20+
static func main() {
21+
foo()
22+
}
23+
}
24+
25+
//--- file2.swift
26+
27+
func bar<T>(_ T: T.Type) {
28+
29+
}
30+
31+
// CHECK: {
32+
// CHECK-NEXT: key.diagnostics: [
33+
// CHECK-NEXT: ]
34+
// CHECK-NEXT: }

0 commit comments

Comments
 (0)