From c2dfbf35528fcdeebcd01c4493591c6a7ae48768 Mon Sep 17 00:00:00 2001 From: Kavon Farvardin Date: Thu, 18 Sep 2025 16:34:38 -0700 Subject: [PATCH 1/2] manualownership: add coverage for global let --- test/SIL/manual_ownership.swift | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/SIL/manual_ownership.swift b/test/SIL/manual_ownership.swift index b4e929542f78d..b38235868c9f6 100644 --- a/test/SIL/manual_ownership.swift +++ b/test/SIL/manual_ownership.swift @@ -152,3 +152,17 @@ public func basic_loop_nontrivial_values_fixed(_ t: Triangle, _ xs: [Triangle]) } (copy t.nontrivial).a = p // expected-error {{explicit 'copy' required here}} } + + +/// MARK: Globals +let ref_result = [5, 13, 29] + +@_manualOwnership +func access_global_1() -> Int { + return ref_result[2] // expected-error {{explicit 'copy' required here}} +} +@_manualOwnership +func access_global_1_fixed() -> Int { +return (copy ref_result)[2] +} + From d03d6d8198fbb999ed541afe9581198efaa2d9b2 Mon Sep 17 00:00:00 2001 From: Kavon Farvardin Date: Thu, 18 Sep 2025 16:58:26 -0700 Subject: [PATCH 2/2] manualownership: add coverage for rebinding lets --- test/SIL/manual_ownership.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/SIL/manual_ownership.swift b/test/SIL/manual_ownership.swift index b38235868c9f6..14bd0ac0542fe 100644 --- a/test/SIL/manual_ownership.swift +++ b/test/SIL/manual_ownership.swift @@ -56,6 +56,24 @@ public func basic_return3() -> Triangle { return Triangle() } +// FIXME: we need copy propagation in -Onone to eliminate all these copies +@_manualOwnership +func reassign_with_lets() -> Triangle { + let x = Triangle() + let y = x // expected-error {{explicit 'copy' required here}} + let z = y // expected-error {{explicit 'copy' required here}} + return z // expected-error {{explicit 'copy' required here}} +} + +// FIXME: we need copy propagation in -Onone to eliminate all but the copies for returning +@_manualOwnership +func renamed_return(_ cond: Bool, _ a: Triangle) -> Triangle { + let b = a // expected-error {{explicit 'copy' required here}} + let c = b // expected-error {{explicit 'copy' required here}} + if cond { return b } // expected-error {{explicit 'copy' required here}} + return c // expected-error {{explicit 'copy' required here}} +} + /// MARK: method calls @_manualOwnership