Debian Codegraph @

clang/test/CodeGenCoroutines/pr134409.cpp

raw
1 // An end-to-end test to make sure coroutine passes are added for thinlto.
2 // REQUIRES: x86-registered-target
3 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++23 -ffat-lto-objects -flto=thin -emit-llvm %s -O3 -o - \
4 // RUN: | FileCheck %s
5
6 #include "Inputs/coroutine.h"
7
8 class BasicCoroutine {
9 public:
10 struct Promise {
11 BasicCoroutine get_return_object() { return BasicCoroutine {}; }
12
13 void unhandled_exception() noexcept { }
14
15 void return_void() noexcept { }
16
17 std::suspend_never initial_suspend() noexcept { return {}; }
18 std::suspend_never final_suspend() noexcept { return {}; }
19 };
20 using promise_type = Promise;
21 };
22
23 // COM: match the embedded module, so we don't match something in it by accident.
24 // CHECK: @llvm.embedded.object = {{.*}}
25 // CHECK: @llvm.compiler.used = {{.*}}
26
27 BasicCoroutine coro() {
28 // CHECK: define {{.*}} void @_Z4corov() {{.*}} {
29 // CHECK-NEXT: entry:
30 // CHECK-NEXT: ret void
31 // CHECK-NEXT: }
32 co_return;
33 }
34
35 int main() {
36 // CHECK: define {{.*}} i32 @main() {{.*}} {
37 // CHECK-NEXT: entry:
38 // CHECK-NEXT: tail call void @_Z4corov()
39 // CHECK-NEXT: ret i32 0
40 // CHECK-NEXT: }
41 coro();
42 }
43