Debian Codegraph @

clang/test/DebugInfo/KeyInstructions/coro-dwarf-key-instrs.cpp

raw
1 // RUN: %clang_cc1 -disable-llvm-optzns -std=c++20 \
2 // RUN: -triple=x86_64 -dwarf-version=4 -debug-info-kind=limited \
3 // RUN: -emit-llvm -o - %s -gkey-instructions | \
4 // RUN: FileCheck %s
5
6 // Check that for the coroutine below, we mark the created DISubprogram as
7 // not having key instructions. This will prevent AsmPrinter from trying to
8 // instrument the linetable with key-instructions for source-locations in
9 // the coroutine scope.
10 //
11 // This is a temporary workaround for key instructions: we can instrument
12 // coroutine code in the future, but it hasn't been done yet.
13 //
14 // File contents copied from coro-dwarf.cpp.
15
16 namespace std {
17 template <typename... T> struct coroutine_traits;
18
19 template <class Promise = void> struct coroutine_handle {
20 coroutine_handle() = default;
21 static coroutine_handle from_address(void *) noexcept;
22 };
23 template <> struct coroutine_handle<void> {
24 static coroutine_handle from_address(void *) noexcept;
25 coroutine_handle() = default;
26 template <class PromiseType>
27 coroutine_handle(coroutine_handle<PromiseType>) noexcept;
28 };
29 } // namespace std
30
31 struct suspend_always {
32 bool await_ready() noexcept;
33 void await_suspend(std::coroutine_handle<>) noexcept;
34 void await_resume() noexcept;
35 };
36
37 template <typename... Args> struct std::coroutine_traits<void, Args...> {
38 struct promise_type {
39 void get_return_object() noexcept;
40 suspend_always initial_suspend() noexcept;
41 suspend_always final_suspend() noexcept;
42 void return_void() noexcept;
43 promise_type();
44 ~promise_type() noexcept;
45 void unhandled_exception() noexcept;
46 };
47 };
48
49 // TODO: Not supported yet
50 struct CopyOnly {
51 int val;
52 CopyOnly(const CopyOnly &) noexcept;
53 CopyOnly(CopyOnly &&) = delete;
54 ~CopyOnly();
55 };
56
57 struct MoveOnly {
58 int val;
59 MoveOnly(const MoveOnly &) = delete;
60 MoveOnly(MoveOnly &&) noexcept;
61 ~MoveOnly();
62 };
63
64 struct MoveAndCopy {
65 int val;
66 MoveAndCopy(const MoveAndCopy &) noexcept;
67 MoveAndCopy(MoveAndCopy &&) noexcept;
68 ~MoveAndCopy();
69 };
70
71 void consume(int, int, int) noexcept;
72
73 void f_coro(int val, MoveOnly moParam, MoveAndCopy mcParam) {
74 consume(val, moParam.val, mcParam.val);
75 co_return;
76 }
77
78 // CHECK: ![[SP:[0-9]+]] = distinct !DISubprogram(name: "f_coro", linkageName: "_Z6f_coroi8MoveOnly11MoveAndCopy"
79 // CHECK-NOT: keyInstructions:
80 // CHECK: !DIFil
81