44 lines · cpp
1// An end-to-end test to make sure coroutine passes are added for thinlto.2// REQUIRES: x86-registered-target3// 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 %s5 6#include "Inputs/coroutine.h"7 8class BasicCoroutine {9public: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 27BasicCoroutine coro() {28// CHECK: define {{.*}} void @_Z4corov() {{.*}} {29// CHECK-NEXT: entry:30// CHECK-NEXT: ret void31// CHECK-NEXT: }32 co_return;33}34 35int main() {36// CHECK: define {{.*}} i32 @main() {{.*}} {37// CHECK-NEXT: entry:38// CHECK-NEXT: tail call void @_Z4corov()39// CHECK-NEXT: ret i32 040// CHECK-NEXT: }41 coro();42}43 44