Skip to content

[Test] Commented two tests and added one. #66976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions test/Interpreter/moveonly_reinit_noncontiguous.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// RUN: %target-run-simple-swift(-Xfrontend -sil-verify-all -enforce-exclusivity=none -Xllvm -move-only-address-checker-disable-lifetime-extension=true) | %FileCheck %s
// RUN: %target-run-simple-swift(-O -Xfrontend -sil-verify-all -enforce-exclusivity=none -Xllvm -move-only-address-checker-disable-lifetime-extension=true) | %FileCheck %s

// REQUIRES: executable_test

struct S: ~Copyable {
let s: String
init(_ s: String) { self.s = s }
deinit { print("deiniting \(s)") }
}

struct M4 : ~Copyable {
var s1: S
var s2: S
var s3: S
var s4: S
init(_ s: String) {
self.s1 = S("\(s).s1")
self.s2 = S("\(s).s2")
self.s3 = S("\(s).s3")
self.s4 = S("\(s).s4")
}
}

func rewriteTwo(_ one: inout S, _ two: inout S) {
print("entering \(#function)")
one = S("new1")
two = S("new2")
print("exiting \(#function)")
}

func doit() {
var m = M4("1")
// CHECK: deiniting 1.s1
// CHECK: deiniting 1.s2
// CHECK: deiniting new1
// CHECK: deiniting new2
rewriteTwo(&m.s1, &m.s2)
}

doit()
6 changes: 6 additions & 0 deletions test/SILOptimizer/moveonly_addresschecker_unmaximized.sil
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,15 @@ bb0:
return %22 : $()
}

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

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