Commit Graph

8 Commits

Author SHA1 Message Date
Joe Groff
f9d9d75768 SILGen: Change codegen for loading from no-implicit-copy lvalues.
Previously, we would emit this as

  %1 = load [copy] %address
  %2 = moveonly_wrapper_to_copyable [owned] %1

which is difficult for move-only checking to handle, since %2 looks like a
consume of %1, making it difficult to determine %1's true lifetime. Change
this to

  %1 = moveonly_wrapper_to_copyable_addr %address
  %2 = load [copy] %address

which is handled better by move-only checking, improving the accuracy of
existing move-checking as well as fixing a spurious diagnostic when
indirect parameters get passed as by-value arguments to other functions.
2025-01-06 21:34:56 -08:00
Allan Shortlidge
cb578172ea Tests: Remove -disable-availability-checking in more tests that use concurrency.
Use the `%target-swift-5.1-abi-triple` substitution to compile the tests for
deployment to the minimum OS versions required for use of _Concurrency APIs,
instead of disabling availability checking.
2024-10-19 12:35:20 -07:00
Kavon Farvardin
68db6a8bd2 Test: add coverage for consume in closure
fixes https://github.com/swiftlang/swift/issues/75487
2024-08-05 15:04:15 -07:00
Joe Groff
90e1ecb864 Consistently mark borrowing and consuming parameters for move-only checking when captured.
When a `borrowing` or `consuming` parameter is captured by a closure,
we emit references to the binding within the closure as if it is non-implicitly
copyable, but we didn't mark the bindings inside the closure for move-only
checking to ensure the uses were correct, so improper consumes would go
undiagnosed and lead to assertion failures, compiler crashes, and/or
miscompiles. Fixes rdar://127382105
2024-05-01 13:41:28 -07:00
Andrew Trick
3caf508494 Disable the TrivialMoveOnlyTypeEliminator pass.
This fixes the `consuming` and `borrowing` keywords for some basic
cases. In particular, if a nontrivial struct contains a trivial 'let'
field, then this pass would result in invalid SIL types:

class C {}

struct BV {
  let p: UnsafeRawPointer
  let c: C
}

func getPointer(bv: consuming BV) -> UnsafeRawPointer {
  return bv.p
}

Ultimately, this pass makes sense, but there is something strange
about the way move-only-ness propagates into fields of aggregates
which needs to be fixed first. Until then, other features are blocked
on basic support for these keywords.

Fixes rdar://122701694 (`consuming` keyword causes verification error on invalid SIL types)
2024-02-10 12:50:33 -08:00
Kavon Farvardin
e71594725a be specific that only escaping closures prevent consumption
rdar://109908383
2023-06-12 17:15:46 -07:00
Michael Gottesman
0d36738206 Enable sil-verify-all on noimplicitcopy_consuming_parameters and noimplicitcopy_borrowing_parameters.swift.
I found on 5.9 that this caught a small issue in MoveOnlyWrappedTypeLowering. I
am going to fix that issue in the next commit.
2023-06-06 23:50:02 -04:00
Michael Gottesman
59c8cff917 [borrowing] Add support for borrowing/consuming copyable types to be a noimplicitcopy type.
rdar://108383660
2023-06-06 18:12:29 -04:00