Skip to content

Commit 1e2af9b

Browse files
authored
Merge pull request #60911 from hamishknight/dist-deinit
2 parents 9a90b75 + ab7b691 commit 1e2af9b

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

lib/SILGen/SILGenDestructor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ void SILGenFunction::emitDestroyingDestructor(DestructorDecl *dd) {
8181
}
8282
}
8383

84-
emitProfilerIncrement(dd->getTypecheckedBody());
8584
// Emit the destructor body.
8685
if (deinitBodyBB)
8786
B.emitBlock(deinitBodyBB);
87+
88+
emitProfilerIncrement(dd->getTypecheckedBody());
8889
emitStmt(dd->getTypecheckedBody());
8990

9091
Optional<SILValue> maybeReturnValue;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/../Inputs/FakeDistributedActorSystems.swift
3+
4+
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -profile-generate -profile-coverage-mapping -emit-sorted-sil -emit-sil -module-name coverage_dist -disable-availability-checking -I %t %s | %FileCheck %s
5+
// RUN: %target-swift-frontend -profile-generate -profile-coverage-mapping -emit-ir -disable-availability-checking -I %t %s
6+
7+
// REQUIRES: concurrency
8+
// REQUIRES: distributed
9+
10+
import Distributed
11+
import FakeDistributedActorSystems
12+
13+
typealias DefaultDistributedActorSystem = FakeActorSystem
14+
15+
distributed actor MyDistActor {
16+
init(system: FakeActorSystem) {
17+
self.actorSystem = system
18+
}
19+
20+
// CHECK-LABEL: sil hidden @$s13coverage_dist11MyDistActorCfd : $@convention(method) (@guaranteed MyDistActor) -> @owned Builtin.NativeObject
21+
// CHECK: cond_br {{%[0-9]+}}, {{bb[0-9]+}}, [[DEINITBODYBB:bb[0-9]+]]
22+
23+
// CHECK: [[DEINITBODYBB]]:
24+
// CHECK-NEXT: string_literal utf8
25+
// CHECK-NEXT: integer_literal $Builtin.Int64, 0
26+
// CHECK-NEXT: integer_literal $Builtin.Int32, 2
27+
// CHECK-NEXT: integer_literal $Builtin.Int32, 0
28+
// CHECK-NEXT: int_instrprof_increment
29+
// CHECK: function_ref @$sSb6randomSbyFZ
30+
// CHECK: cond_br {{%[0-9]+}}, [[TRUEBB:bb[0-9]+]], {{bb[0-9]+}}
31+
32+
// CHECK: [[TRUEBB]]:
33+
// CHECK-NEXT: string_literal utf8
34+
// CHECK-NEXT: integer_literal $Builtin.Int64, 0
35+
// CHECK-NEXT: integer_literal $Builtin.Int32, 2
36+
// CHECK-NEXT: integer_literal $Builtin.Int32, 1
37+
// CHECK-NEXT: int_instrprof_increment
38+
39+
// CHECK-LABEL: sil_coverage_map {{.*}} "$s13coverage_dist11MyDistActorCfd" {{.*}} // coverage_dist.MyDistActor.deinit
40+
// CHECK-NEXT: [[@LINE+3]]:10 -> [[@LINE+5]]:4 : 0
41+
// CHECK-NEXT: [[@LINE+3]]:25 -> [[@LINE+3]]:26 : 1
42+
// CHECK-NEXT: [[@LINE+2]]:29 -> [[@LINE+2]]:30 : (0 - 1)
43+
deinit {
44+
let _ = .random() ? 0 : 1
45+
}
46+
}

0 commit comments

Comments
 (0)