Skip to content

Commit 45c8c5f

Browse files
committed
PerformanceDiagnostics: fix a crash when emitting a module
rdar://93439187
1 parent 689e9e3 commit 45c8c5f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/SILOptimizer/Mandatory/PerformanceDiagnostics.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ static bool isEffectFreeArraySemanticCall(SILInstruction *inst) {
9090
bool PerformanceDiagnostics::visitFunction(SILFunction *function,
9191
PerformanceConstraints perfConstr,
9292
LocWithParent *parentLoc) {
93+
if (!function->isDefinition())
94+
return false;
95+
9396
ReachingReturnBlocks rrBlocks(function);
9497
NonErrorHandlingBlocks neBlocks(function);
9598

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-swift-frontend -experimental-performance-annotations -experimental-skip-non-inlinable-function-bodies-without-types -emit-module %s -o /dev/null
2+
3+
// Don't crash when emitting a module
4+
5+
@_noAllocation
6+
func foo() -> Int {
7+
return 42
8+
}
9+
print(foo())

0 commit comments

Comments
 (0)