| 1 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 -emit-llvm %s -o - | FileCheck %s |
| 2 |
#include "Inputs/coroutine.h" |
| 3 |
|
| 4 |
using namespace std; |
| 5 |
|
| 6 |
struct coro { |
| 7 |
struct promise_type { |
| 8 |
coro get_return_object(); |
| 9 |
suspend_never initial_suspend(); |
| 10 |
suspend_never final_suspend() noexcept; |
| 11 |
void return_void(); |
| 12 |
static void unhandled_exception(); |
| 13 |
}; |
| 14 |
}; |
| 15 |
|
| 16 |
struct A { |
| 17 |
~A(); |
| 18 |
bool await_ready(); |
| 19 |
int await_resume() { return 8; } |
| 20 |
template <typename F> void await_suspend(F); |
| 21 |
}; |
| 22 |
|
| 23 |
extern "C" void consume(int); |
| 24 |
|
| 25 |
// Verifies that domination is properly built during cleanup. |
| 26 |
// Without CGCleanup.cpp fix verifier was reporting: |
| 27 |
// Instruction does not dominate all uses! |
| 28 |
// %tmp.exprcleanup = alloca i32*, align 8 |
| 29 |
// store i32* %x, i32** %tmp.exprcleanup, align 8 |
| 30 |
|
| 31 |
|
| 32 |
// CHECK-LABEL: f( |
| 33 |
extern "C" coro f(int) { |
| 34 |
int x = 42; |
| 35 |
x = co_await A{}; |
| 36 |
consume(x); |
| 37 |
} |