
This patch tries to salvage the debug information for the coroutine frames within optimizations by creating the help alloca varaibles with optimizations too. We didn't do this when I implement it initially. I roughtly remember the reason was, we feel the additional help alloca variable may pessimize the performance, which is almost the most important thing under optimizations. But now, it looks like the new inserted help alloca variables can be optimized out by the following optimizations. So it looks like the time to make it available within optimizations. And also, it looks like the following optimizations will convert the generated dbg.declare instrinsic into dbg.value intrinsic within optimizations. In LLVM's test, there is a slightly regression that a dbg.declare for the promise object failed to be remained after this change. But it looks like we won't have a chance to see dbg.declare for the promise object when we split the coroutine as that dbg.declare will be converted into a dbg.value in early stage. So everything looks fine.
40 lines
1.0 KiB
C++
40 lines
1.0 KiB
C++
// Check that we can still observe the value of the coroutine frame
|
|
// with optimizations.
|
|
//
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
|
|
// RUN: -emit-llvm %s -debug-info-kind=limited -dwarf-version=5 \
|
|
// RUN: -O2 -o - | FileCheck %s
|
|
|
|
#include "Inputs/coroutine.h"
|
|
|
|
template <>
|
|
struct std::coroutine_traits<void> {
|
|
struct promise_type {
|
|
void get_return_object();
|
|
std::suspend_always initial_suspend();
|
|
std::suspend_always final_suspend() noexcept;
|
|
void return_void();
|
|
void unhandled_exception();
|
|
};
|
|
};
|
|
|
|
struct ScalarAwaiter {
|
|
template <typename F> void await_suspend(F);
|
|
bool await_ready();
|
|
int await_resume();
|
|
};
|
|
|
|
extern "C" void UseScalar(int);
|
|
|
|
extern "C" void f() {
|
|
UseScalar(co_await ScalarAwaiter{});
|
|
|
|
int Val = co_await ScalarAwaiter{};
|
|
|
|
co_await ScalarAwaiter{};
|
|
}
|
|
|
|
// CHECK: define {{.*}}@f.resume({{.*}} %[[ARG:.*]])
|
|
// CHECK: #dbg_value(ptr %[[ARG]], ![[CORO_NUM:[0-9]+]], !DIExpression(DW_OP_deref)
|
|
// CHECK: ![[CORO_NUM]] = !DILocalVariable(name: "__coro_frame"
|