brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 66537db Raw
82 lines · cpp
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 %s5 6// Check that for the coroutine below, we mark the created DISubprogram as7// not having key instructions. This will prevent AsmPrinter from trying to8// instrument the linetable with key-instructions for source-locations in9// the coroutine scope.10//11// This is a temporary workaround for key instructions: we can instrument12// coroutine code in the future, but it hasn't been done yet.13//14// File contents copied from coro-dwarf.cpp.15 16namespace std {17template <typename... T> struct coroutine_traits;18 19template <class Promise = void> struct coroutine_handle {20  coroutine_handle() = default;21  static coroutine_handle from_address(void *) noexcept;22};23template <> 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 std30 31struct suspend_always {32  bool await_ready() noexcept;33  void await_suspend(std::coroutine_handle<>) noexcept;34  void await_resume() noexcept;35};36 37template <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 yet50struct CopyOnly {51  int val;52  CopyOnly(const CopyOnly &) noexcept;53  CopyOnly(CopyOnly &&) = delete;54  ~CopyOnly();55};56 57struct MoveOnly {58  int val;59  MoveOnly(const MoveOnly &) = delete;60  MoveOnly(MoveOnly &&) noexcept;61  ~MoveOnly();62};63 64struct MoveAndCopy {65  int val;66  MoveAndCopy(const MoveAndCopy &) noexcept;67  MoveAndCopy(MoveAndCopy &&) noexcept;68  ~MoveAndCopy();69};70 71void consume(int, int, int) noexcept;72 73void 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: !DIFil81 82