Skip to content

Commit e326728

Browse files
authored
Merge pull request #9108 from vedantk/master
[Coverage] Emit a profiler increment in ObjC destructors
2 parents b8fda57 + a07b1d6 commit e326728

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/SILGen/SILGenDestructor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ void SILGenFunction::emitObjCDestructor(SILDeclRef dtor) {
207207
// We won't actually emit the block until we finish with the destructor body.
208208
prepareEpilog(Type(), false, CleanupLocation::get(loc));
209209

210+
emitProfilerIncrement(dd->getBody());
210211
// Emit the destructor body.
211212
emitStmt(dd->getBody());
212213

test/SILGen/coverage_deinit.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -suppress-warnings -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_deinit %s | %FileCheck %s
2+
// REQUIRES: objc_interop
3+
4+
import Foundation
5+
6+
public class Derived: NSString {
7+
// CHECK-LABEL: sil @_T015coverage_deinit7DerivedCfD
8+
// CHECK: builtin "int_instrprof_increment"
9+
// CHECK-NEXT: super_method {{.*}} : $Derived, #NSString.deinit!deallocator.foreign
10+
deinit {
11+
}
12+
}
13+
14+
// CHECK-LABEL: sil_coverage_map "{{.*}}coverage_deinit.swift" _T015coverage_deinit7DerivedCfD
15+
// CHECK-NEXT: [[@LINE-5]]:10 -> [[@LINE-4]]:4 : 0

0 commit comments

Comments
 (0)