llvm-capstone/clang/test/CodeGenCoroutines/coro-always-inline.cpp
Nikita Popov 243e62b9d8 [Coroutines] Directly remove unnecessary lifetime intrinsics
The insertSpills() code will currently skip lifetime intrinsic users
when replacing the alloca with a frame reference. Rather than
leaving behind the dead lifetime intrinsics working on the old
alloca, directly remove them. This makes sure the alloca can be
dropped as well.

I noticed this as a regression when converting tests to opaque
pointers. Without opaque pointers, this code didn't really do
anything, because there would usually be a bitcast in between.
The lifetimes would get rewritten to the frame pointer. With
opaque pointers, this code now triggers and leaves behind users
of the old allocas.

Differential Revision: https://reviews.llvm.org/D148240
2023-04-14 10:22:30 +02:00

51 lines
1.3 KiB
C++

// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -std=c++20 \
// RUN: -O0 %s -o - | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -std=c++20 \
// RUN: -fno-inline -O0 %s -o - | FileCheck %s
namespace std {
struct handle {};
struct awaitable {
bool await_ready() noexcept { return true; }
// CHECK-NOT: await_suspend
inline void __attribute__((__always_inline__)) await_suspend(handle) noexcept {}
bool await_resume() noexcept { return true; }
};
template <typename T>
struct coroutine_handle {
static handle from_address(void *address) noexcept { return {}; }
};
template <typename T = void>
struct coroutine_traits {
struct promise_type {
awaitable initial_suspend() { return {}; }
awaitable final_suspend() noexcept { return {}; }
void return_void() {}
T get_return_object() { return T(); }
void unhandled_exception() {}
};
};
} // namespace std
// CHECK-LABEL: @_Z3foov
// CHECK-LABEL: entry:
// CHECK: %ref.tmp.reload.addr = getelementptr
// CHECK: %ref.tmp4.reload.addr = getelementptr
void foo() { co_return; }
// Check that bar is not inlined even it's marked as always_inline.
// CHECK-LABEL: define {{.*}} void @_Z3bazv()
// CHECK: call void @_Z3barv(
__attribute__((__always_inline__)) void bar() {
co_return;
}
void baz() {
bar();
co_return;
}