-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[libcxx] Test await_suspend
control flow & coro_await_suspend_destroy
attr
#152820
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
base: main
Are you sure you want to change the base?
[libcxx] Test await_suspend
control flow & coro_await_suspend_destroy
attr
#152820
Conversation
…d test for [[clang::coro_await_suspend_destroy]] When reviewing llvm#152623, @@ChuanqiXu9 suggested that it's better to separate `clang` and `libcxx` changes, so I did that here. This event-replay test is compatible with compilers lacking the new attribute. The two PRs can be landed in any order. Furthermore, the test does not just verify the attribute's correct behavior. By storing "gold" event traces, it also provides some protection against future breakage in the complex control flow of the C++ coroutine implementation. Since suspension remains an area of active optimization work, such bugs are not ruled out. As a new contributor to LLVM, I myself made (and fixed) 2 control-flow bugs while working on llvm#152623. This test would've caught both.
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-libcxx Author: None (snarkmaster) ChangesWhen reviewing #152623, @@ChuanqiXu9 suggested that it's better to separate This event-replay test is compatible with compilers lacking the new attribute The test does not just verify the attribute's correct behavior. By comparing "gold" event traces, it also provides some "change detector" protection against future breakage in the complex control flow of the main C++ coroutine implementation. Since suspension remains an area of active optimization work, such bugs are not ruled out. For example, as a new contributor to LLVM, I made (and fixed) 2 control-flow bugs while working on #152623. This test would've caught both. Patch is 128.81 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/152820.diff 3 Files Affected:
diff --git a/libcxx/test/std/language.support/support.coroutines/end.to.end/coro_await_suspend_destroy.golden-exceptions.h b/libcxx/test/std/language.support/support.coroutines/end.to.end/coro_await_suspend_destroy.golden-exceptions.h
new file mode 100644
index 0000000000000..2911e97ad9f59
--- /dev/null
+++ b/libcxx/test/std/language.support/support.coroutines/end.to.end/coro_await_suspend_destroy.golden-exceptions.h
@@ -0,0 +1,1163 @@
+// coro_await_suspend_destroy.golden-exceptions.h
++ test_coro_shortcircuits_to_empty(std::vector<test_driver>{
+ {.toggles_ = 0,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 18,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 65}},
+ {.toggles_ = 1,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 19,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 81, 65}},
+ {.toggles_ = 2,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 18,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 65}},
+ {.toggles_ = 3,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 19,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 81, 65}},
+ {.toggles_ = 4,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 5,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 6,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 7,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 8,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 22,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 72, 69, 66, 64, 65}},
+ {.toggles_ = 9,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 23,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 10,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 22,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 72, 69, 66, 64, 65}},
+ {.toggles_ = 11,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 23,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 12,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 13,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 14,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 15,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 16,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 18,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 65}},
+ {.toggles_ = 17,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 19,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 81, 65}},
+ {.toggles_ = 18,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 18,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 65}},
+ {.toggles_ = 19,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 19,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 81, 65}},
+ {.toggles_ = 20,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 21,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 22,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 23,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 24,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 22,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 72, 69, 66, 64, 65}},
+ {.toggles_ = 25,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 23,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 26,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 22,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 72, 69, 66, 64, 65}},
+ {.toggles_ = 27,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 23,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 28,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 29,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 30,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 31,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+}) +
+ test_coro_simple_await(std::vector<test_driver>{
+ {.toggles_ = 0,
+ .threw_ = 0,
+ .result_ = 12,
+ .next_event_ = 20,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 74, 2, 70, 12, 75, 2, 75, 1, 69, 66, 64, 65}},
+ {.toggles_ = 1,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 21,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 74, 2, 70, 12, 75, 2, 75, 1, 69, 66, 64, 81, 65}},
+ {.toggles_ = 2,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 22,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 74, 2, 70, 12, 71, 75, 2, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 3,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 23,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 74, 2, 70, 12, 71, 75, 2, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 4,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 5,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 6,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 7,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 8,
+ .threw_ = 0,
+ .result_ = 12,
+ .next_event_ = 20,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 74, 2, 70, 12, 75, 2, 75, 1, 69, 66, 64, 65}},
+ {.toggles_ = 9,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 21,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 74, 2, 70, 12, 75, 2, 75, 1, 69, 66, 64, 81, 65}},
+ {.toggles_ = 10,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 22,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 74, 2, 70, 12, 71, 75, 2, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 11,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 23,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 74, 2, 70, 12, 71, 75, 2, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 12,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 13,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 14,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 15,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 16,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 18,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 79, 77, 2, 75, 2, 75, 1, 66, 64, 65}},
+ {.toggles_ = 17,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 19,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 79, 77, 2, 75, 2, 75, 1, 66, 64, 81, 65}},
+ {.toggles_ = 18,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 18,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 79, 77, 2, 75, 2, 75, 1, 66, 64, 65}},
+ {.toggles_ = 19,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 19,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 79, 77, 2, 75, 2, 75, 1, 66, 64, 81, 65}},
+ {.toggles_ = 20,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 21,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 22,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 23,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 24,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 22,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 25,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 23,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 26,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 22,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 27,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 23,
+ .events_ = {67, 68, 73, 1, 74, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 28,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 29,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 30,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 15,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 65}},
+ {.toggles_ = 31,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 72, 69, 66, 64, 81, 65}},
+ }) +
+ test_coro_catching_shortcircuits_to_empty(std::vector<test_driver>{
+ {.toggles_ = 0,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 18,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 65}},
+ {.toggles_ = 1,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 19,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 81, 65}},
+ {.toggles_ = 2,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 18,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 65}},
+ {.toggles_ = 3,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 19,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 81, 65}},
+ {.toggles_ = 4,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 65}},
+ {.toggles_ = 5,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 17,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 6,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 65}},
+ {.toggles_ = 7,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 17,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 8,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 23,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 80, 72, 69, 66, 64, 65}},
+ {.toggles_ = 9,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 24,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 80, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 10,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 23,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 80, 72, 69, 66, 64, 65}},
+ {.toggles_ = 11,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 24,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 80, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 12,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 65}},
+ {.toggles_ = 13,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 17,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 14,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 65}},
+ {.toggles_ = 15,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 17,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 16,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 18,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 65}},
+ {.toggles_ = 17,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 19,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 81, 65}},
+ {.toggles_ = 18,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 18,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 65}},
+ {.toggles_ = 19,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 19,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 75, 2, 66, 64, 81, 65}},
+ {.toggles_ = 20,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 65}},
+ {.toggles_ = 21,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 17,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 22,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 65}},
+ {.toggles_ = 23,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 17,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 24,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 23,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 80, 72, 69, 66, 64, 65}},
+ {.toggles_ = 25,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 24,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 80, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 26,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 23,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 80, 72, 69, 66, 64, 65}},
+ {.toggles_ = 27,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 24,
+ .events_ = {67, 68, 73, 1, 74, 1, 75, 1, 73, 2, 79, 77, 2, 78, 2, 75, 2, 80, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 28,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 65}},
+ {.toggles_ = 29,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 17,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 81, 65}},
+ {.toggles_ = 30,
+ .threw_ = 0,
+ .result_ = {},
+ .next_event_ = 16,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 65}},
+ {.toggles_ = 31,
+ .threw_ = 1,
+ .result_ = -1,
+ .next_event_ = 17,
+ .events_ = {67, 68, 73, 1, 74, 1, 76, 1, 75, 1, 80, 72, 69, 66, 64, 81, 65}},
+ }) +
+ test_coro_catching_simple_await(std::vector<test_driver>{
+ {.toggles_ = 0,
+ .threw_ = 0,
+ .result_ = 12,
+ .next_event_ = 20,...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, why does this need to live in libc++? The attribute doesn't have anything to do with what we need to implement. This test also looks completely different from what any of our normal tests look like, and having "golden" in the name of a test seems very smelly to me.
@philnik777, thanks for looking -- a few responses, please be understanding since this is my first time contributing to LLVM.
I hope this gives some additional useful context! Please guide me in regards to these concrete decisions:
|
It is quite funny to see that we have such good coverage that we're asked to run tests for other sub-projects. That may be an indication that other sub-projects need some more robust CI. The main problem here is that the tests under
I'm sure there is value. However, the libc++ test suite is usually not run against the rest of the compiler. So any breaks in LLVM would break our CI. This is just not an acceptable way to handle this, especially since these are (as far as I understand currently) golden tests - i.e. they may be broken without the changes that broke them being incorrect.
I'm happy to talk to people who work on coroutines. How happy I am about golden tests depend very much on how golden they actually are. If they're actually testing standards-mandated behaviour I wouldn't consider them golden - simply conformance tests. Though that still doesn't mean they should live inside |
Thanks @philnik777 , I agree that these effects you're flagging are quite problematic: (1) For any breakage in these tests, the (2) Since there's a lag between compiler changes and So, philosophically, I'm also in favor of moving this into I think I did a reasonable job of looking at the existing Being very new to the LLVM build-and-test flows (it seems to be CMake x {ninja, make, xcodebuild, ...} x {lit, ...}), I'm not sure I could volunteer to do the plumbing for a new type of compiler test, and actually do a good job of it. Do you know who might be able to give me guidance on this? @ChuanqiXu9, do you have any ideas here? PS I agree about calling these "conformance tests" instead of the more nebulous "golden". I will do this in the next rev. Of course, being a "change detector" design, they could be measuring current non-conformance, but at least we know when the degree of conformance changes lol. |
Hi @snarkmaster, the usual location for tests related to your change are located in |
I was able to talk with @yuxuanchen1997 offline, and we got on the same page. These should go in
Unless I hear otherwise, I'll resubmit this PR to What I'm doing is quite similar in spirit to this test: https://github.com/llvm/llvm-test-suite/tree/main/MultiSource/UnitTests/C%2B%2B11/frame_layout I'll leave this open for feedback for another couple of days. Thanks all for taking the time to guide me here! |
When reviewing #152623, @@ChuanqiXu9 suggested that it's better to separate
clang
andlibcxx
changes, so I did that here.This event-replay test is compatible with compilers lacking the new attribute
[[clang::coro_await_suspend_destroy]]
. The two PRs can be landed in any order.The test does not just verify the attribute's correct behavior. By comparing "gold" event traces, it also provides some "change detector" protection against future breakage in the complex control flow of the main C++ coroutine implementation. Since suspension remains an area of active optimization work, such bugs are not ruled out. For example, as a new contributor to LLVM, I made (and fixed) 2 control-flow bugs while working on #152623. This test would've caught both.