Skip to content

[move-function] Address feedback from previous test commits and add even more tests! #3991

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

Conversation

gottesmm
Copy link

This began as a commit to address @kastiglione's feedback on #3986. After I did that I decided to add even more tests using the same PR. I basically just ported some tests that I already had in Swift that FileChecked LLVM-IR to be LLDB tests of the same sort I have here: walk through programs validating that a value shows up as appropriate when moved.

…lf.assertXXX methods.

Thanks to @kastiglione for the suggestions on the more idiomatic method usage!
I forgot to include this in the previous test commit I updated. This is a
particularly important one since it shows given the following code:

```
let k = Klass()
if alwaysFalse() {
  let _ = _move(k)
}
// <== (A)
```

that at point A, the debugger views k as being uninitialized. This is the
correct behavior since:

1. The lifetime of k needs to be defined by static PC regions in the binary. We
can not model the notion that k's availability is control dependent on the
conditional alwaysFalse unless we cloned code. So fundamentally, we have to be
conservative and say that since (A) is reachable from the _move that the value
isn't available.

2. move semantics means that k can not be used at any point reachable from the
_move. Thus we know that k can not have any uses after the conditional. Thus it
is reasonable that k would not necessarily be available in the debugger at that
point since it is guaranteed to not have any later uses in the function.

Thus we are forced by 1 into this solution with the solice of 2 that it does fit
the model.
I already had tests for these in Swift itself that check at the IR level things
look correct. This just provides a true end<->end test that these continue to
work as expected.
@gottesmm
Copy link
Author

@swift-ci test

@gottesmm gottesmm requested a review from kastiglione February 23, 2022 22:58
@kastiglione
Copy link

nice 👍

@gottesmm gottesmm merged commit 3e8566d into swiftlang:stable/20211026 Feb 24, 2022
@gottesmm gottesmm deleted the stable/20211026/move-function-more-tests branch February 24, 2022 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants