Skip to content

Commit dfdb2e5

Browse files
committed
[SILProfiler] Do not set up a profiler for a function twice
rdar://58861159
1 parent 509ffb3 commit dfdb2e5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/SILGen/SILGen.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ static bool haveProfiledAssociatedFunction(SILDeclRef constant) {
551551
/// Set up the function for profiling instrumentation.
552552
static void setUpForProfiling(SILDeclRef constant, SILFunction *F,
553553
ForDefinition_t forDefinition) {
554-
if (!forDefinition)
554+
if (!forDefinition || F->getProfiler())
555555
return;
556556

557557
ASTNode profiledNode;

test/Profiler/coverage_struct.swift

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_struct %s | %FileCheck %s
2+
3+
struct Foo {
4+
var a = false
5+
6+
// CHECK: sil_coverage_map {{.*}}// variable initialization expression of coverage_struct.Foo.b : Swift.Bool
7+
// CHECK-NEXT: [[@LINE+1]]:11 -> [[@LINE+3]]:6 : 0
8+
let b = {
9+
false
10+
}()
11+
}

0 commit comments

Comments
 (0)