Skip to content

Commit bd52be8

Browse files
committed
[Test] Add for MOAC reinit miscompile.
On recent main, this test case fails verification with ``` SIL memory lifetime failure in @$s4main4doityyF: memory is not initialized, but should be memory location: %21 = struct_element_addr %20 : $*M4, #M4.s2 // user: %23 at instruction: %23 = apply %22(%19, %21) : $@convention(thin) (@inout S, @inout S) -> () [...] 4. While running pass swiftlang#173 SILFunctionTransform "MoveOnlyChecker" on SILFunction "@$s4main4doityyF". for 'doit()' (at test/Interpreter/moveonly_reinit_noncontiguous.swift:32:1) ```
1 parent 8a7cbb6 commit bd52be8

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-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()

0 commit comments

Comments
 (0)