CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
124 lines
3.3 KiB
C++
124 lines
3.3 KiB
C++
// Test for PR56919. Tests the we won't contain the resumption of final suspend point.
|
|
//
|
|
// RUN: %clang_cc1 -triple %itanium_abi_triple -std=c++20 %s -O3 -emit-llvm -o - | FileCheck %s
|
|
// This test is expected to fail on PowerPC.
|
|
// XFAIL: target=powerpc{{.*}}
|
|
|
|
#include "Inputs/coroutine.h"
|
|
|
|
void _exit(int status) __attribute__ ((__noreturn__));
|
|
|
|
class Promise;
|
|
|
|
// An object that can be co_awaited, but we always resume immediately from
|
|
// await_suspend.
|
|
struct ResumeFromAwaitSuspend{};
|
|
|
|
struct Task {
|
|
using promise_type = Promise;
|
|
Promise& promise;
|
|
};
|
|
|
|
struct Promise {
|
|
static std::coroutine_handle<Promise> GetHandle(Promise& promise) {
|
|
return std::coroutine_handle<Promise>::from_promise(promise);
|
|
}
|
|
|
|
void unhandled_exception() {}
|
|
Task get_return_object() { return Task{*this}; }
|
|
void return_void() {}
|
|
|
|
// Always suspend before starting the coroutine body. We actually run the body
|
|
// when we are co_awaited.
|
|
std::suspend_always initial_suspend() { return {}; }
|
|
|
|
// We support awaiting tasks. We do so by configuring them to resume us when
|
|
// they are finished, and then resuming them from their initial suspend.
|
|
auto await_transform(Task&& task) {
|
|
struct Awaiter {
|
|
bool await_ready() { return false; }
|
|
|
|
std::coroutine_handle<> await_suspend(
|
|
const std::coroutine_handle<> handle) {
|
|
// Tell the child to resume the parent once it finishes.
|
|
child.resume_at_final_suspend = GetHandle(parent);
|
|
|
|
// Run the child.
|
|
return GetHandle(child);
|
|
}
|
|
|
|
void await_resume() {
|
|
// The child is now at its final suspend point, and can be destroyed.
|
|
return GetHandle(child).destroy();
|
|
}
|
|
|
|
Promise& parent;
|
|
Promise& child;
|
|
};
|
|
|
|
return Awaiter{
|
|
.parent = *this,
|
|
.child = task.promise,
|
|
};
|
|
}
|
|
|
|
// Make evaluation of `co_await ResumeFromAwaitSuspend{}` go through the
|
|
// await_suspend path, but cause it to resume immediately by returning our own
|
|
// handle to resume.
|
|
auto await_transform(ResumeFromAwaitSuspend) {
|
|
struct Awaiter {
|
|
bool await_ready() { return false; }
|
|
|
|
std::coroutine_handle<> await_suspend(const std::coroutine_handle<> h) {
|
|
return h;
|
|
}
|
|
|
|
void await_resume() {}
|
|
};
|
|
|
|
return Awaiter{};
|
|
}
|
|
|
|
// Always suspend at the final suspend point, transferring control back to our
|
|
// caller. We expect never to be resumed from the final suspend.
|
|
auto final_suspend() noexcept {
|
|
struct FinalSuspendAwaitable final {
|
|
bool await_ready() noexcept { return false; }
|
|
|
|
std::coroutine_handle<> await_suspend(std::coroutine_handle<>) noexcept {
|
|
return promise.resume_at_final_suspend;
|
|
}
|
|
|
|
void await_resume() noexcept {
|
|
_exit(1);
|
|
}
|
|
|
|
Promise& promise;
|
|
};
|
|
|
|
return FinalSuspendAwaitable{.promise = *this};
|
|
}
|
|
|
|
// The handle we will resume once we hit final suspend.
|
|
std::coroutine_handle<> resume_at_final_suspend;
|
|
};
|
|
|
|
Task Inner();
|
|
|
|
Task Outer() {
|
|
co_await ResumeFromAwaitSuspend();
|
|
co_await Inner();
|
|
}
|
|
|
|
// CHECK: define{{.*}}@_Z5Outerv.resume(
|
|
// CHECK-NOT: }
|
|
// CHECK-NOT: _exit
|
|
// CHECK: musttail call
|
|
// CHECK: musttail call
|
|
// CHECK: musttail call
|
|
// CHECK-NEXT: ret void
|
|
// CHECK-EMPTY:
|
|
// CHECK-NEXT: unreachable:
|
|
// CHECK-NEXT: unreachable
|
|
// CHECK-NEXT: }
|