Skip to content

Commit 746dd98

Browse files
authored
Merge pull request #66976 from nate-chandler/test/20230627/1
[Test] Commented two tests and added one.
2 parents bd90e31 + bd52be8 commit 746dd98

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// RUN: %target-run-simple-swift(-Xfrontend -sil-verify-all -enforce-exclusivity=none -Xllvm -move-only-address-checker-disable-lifetime-extension=true) | %FileCheck %s
2+
// RUN: %target-run-simple-swift(-O -Xfrontend -sil-verify-all -enforce-exclusivity=none -Xllvm -move-only-address-checker-disable-lifetime-extension=true) | %FileCheck %s
3+
4+
// REQUIRES: executable_test
5+
6+
struct S: ~Copyable {
7+
let s: String
8+
init(_ s: String) { self.s = s }
9+
deinit { print("deiniting \(s)") }
10+
}
11+
12+
struct M4 : ~Copyable {
13+
var s1: S
14+
var s2: S
15+
var s3: S
16+
var s4: S
17+
init(_ s: String) {
18+
self.s1 = S("\(s).s1")
19+
self.s2 = S("\(s).s2")
20+
self.s3 = S("\(s).s3")
21+
self.s4 = S("\(s).s4")
22+
}
23+
}
24+
25+
func rewriteTwo(_ one: inout S, _ two: inout S) {
26+
print("entering \(#function)")
27+
one = S("new1")
28+
two = S("new2")
29+
print("exiting \(#function)")
30+
}
31+
32+
func doit() {
33+
var m = M4("1")
34+
// CHECK: deiniting 1.s1
35+
// CHECK: deiniting 1.s2
36+
// CHECK: deiniting new1
37+
// CHECK: deiniting new2
38+
rewriteTwo(&m.s1, &m.s2)
39+
}
40+
41+
doit()

test/SILOptimizer/moveonly_addresschecker_unmaximized.sil

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,15 @@ bb0:
6666
return %22 : $()
6767
}
6868

69+
// Two non-contiguous fields (#M4.s2, #M4.s4) are reinitialized by @replace_2.
70+
//
71+
// Verify that #M4.s4 is not destroyed before being passed to replace_2.
6972
// CHECK-LABEL: sil [ossa] @rdar111356251 : $@convention(thin) () -> () {
7073
// CHECK: [[STACK:%[^,]+]] = alloc_stack $M4
7174
// CHECK: [[GET_M4:%[^,]+]] = function_ref @get_M4 : $@convention(thin) () -> @owned M4
7275
// CHECK: [[INSTANCE:%[^,]+]] = apply [[GET_M4]]() : $@convention(thin) () -> @owned M4
7376
// CHECK: store [[INSTANCE]] to [init] [[STACK]] : $*M4
77+
// CHECK-NOT: destroy_addr
7478
// CHECK: [[S2_ADDR:%[^,]+]] = struct_element_addr [[STACK]] : $*M4, #M4.s2
7579
// CHECK: [[S4_ADDR:%[^,]+]] = struct_element_addr [[STACK]] : $*M4, #M4.s4
7680
// CHECK: [[REPLACE_2:%[^,]+]] = function_ref @replace_2 : $@convention(thin) (@inout M, @inout M) -> ()
@@ -109,6 +113,8 @@ bb0:
109113
return %22 : $()
110114
}
111115

116+
// Two non-contiguous fields (#M4.s2, #M4.s4) are initialized by @get_out_2.
117+
//
112118
// Verify that M4.s4 is not leaked after it is set.
113119
// CHECK-LABEL: sil [ossa] @rdar111391893 : $@convention(thin) () -> () {
114120
// CHECK: [[GET_OUT_2:%[^,]+]] = function_ref @get_out_2

0 commit comments

Comments
 (0)