Skip to content

Commit 43ddb88

Browse files
authored
Merge pull request #59124 from eeckstein/fix-perf-annotations
PerformanceDiagnostics: fix a crash when emitting a module
2 parents beb9dd9 + 45c8c5f commit 43ddb88

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)