brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.3 KiB · 6b61ccd Raw
87 lines · cpp
1// RUN: %clang_cc1 -std=c++20 -triple=x86_64-pc-windows-msvc18.0.0 -emit-llvm %s -o - -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck %s2// RUN: %clang_cc1 -std=c++20 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck --check-prefix=CHECK-LPAD %s3 4namespace std {5template <typename R, typename... T> struct coroutine_traits {6  using promise_type = typename R::promise_type;7};8 9template <class Promise = void> struct coroutine_handle;10 11template <> struct coroutine_handle<void> {12  static coroutine_handle from_address(void *) noexcept;13  coroutine_handle() = default;14  template <class PromiseType>15  coroutine_handle(coroutine_handle<PromiseType>) noexcept;16};17template <class Promise> struct coroutine_handle: coroutine_handle<void> {18  coroutine_handle() = default;19  static coroutine_handle from_address(void *) noexcept;20};21} // namespace std22 23struct suspend_always {24  bool await_ready() noexcept;25  void await_suspend(std::coroutine_handle<>) noexcept;26  void await_resume() noexcept;27};28 29struct coro_t {30  struct promise_type {31    coro_t get_return_object() noexcept;32    suspend_always initial_suspend() noexcept;33    suspend_always final_suspend() noexcept;34    void return_void() noexcept;35    void unhandled_exception() noexcept;36  };37};38 39struct Cleanup { ~Cleanup(); };40void may_throw();41 42coro_t f() {43  Cleanup x;44  may_throw();45  co_return;46}47 48// CHECK: @"?f@@YA?AUcoro_t@@XZ"(49// CHECK:   invoke void @"?may_throw@@YAXXZ"()50// CHECK:       to label %[[CONT:.+]] unwind label %[[EHCLEANUP:.+]]51// CHECK: [[EHCLEANUP]]:52// CHECK:   %[[INNERPAD:.+]] = cleanuppad within none []53// CHECK:   call void @"??1Cleanup@@QEAA@XZ"(54// CHECK:   cleanupret from %{{.+}} unwind label %[[CATCHDISPATCH:.+]]55 56// CHECK: [[CATCHDISPATCH]]:57// CHECK:   catchswitch within none [label %[[CATCHPAD:.+]]] unwind label %[[COROENDBB:.+]]58// CHECK: [[CATCHPAD]]:59// CHECK:   call void @"?unhandled_exception@promise_type@coro_t@@QEAAXXZ"60 61// CHECK: [[COROENDBB]]:62// CHECK-NEXT: %[[CLPAD:.+]] = cleanuppad within none63// CHECK-NEXT: call void @llvm.coro.end(ptr null, i1 true, token none) [ "funclet"(token %[[CLPAD]]) ]64// CHECK-NEXT: cleanupret from %[[CLPAD]] unwind label65 66// CHECK-LPAD: @_Z1fv(67// CHECK-LPAD:   invoke void @_Z9may_throwv()68// CHECK-LPAD:       to label %[[CONT:.+]] unwind label %[[EHCLEANUP:.+]]69// CHECK-LPAD: [[EHCLEANUP]]:70// CHECK-LPAD:    landingpad { ptr, i32 }71// CHECK-LPAD:          catch72// CHECK-LPAD:   call void @_ZN7CleanupD1Ev(73// CHECK-LPAD:   call ptr @__cxa_begin_catch74// CHECK-LPAD:   call void @_ZN6coro_t12promise_type19unhandled_exceptionEv75// CHECK-LPAD:   invoke void @__cxa_end_catch()76// CHECK-LPAD:             to label %{{.+}} unwind label %[[UNWINDBB:.+]]77 78// CHECK-LPAD: [[UNWINDBB]]:79// CHECK-LPAD:   %[[InRamp:.+]] = call i1 @llvm.coro.is_in_ramp()80// CHECK-LPAD:   br i1  %[[InRamp]], label %{{.+}}, label %[[EHRESUME:.+]]81// CHECK-LPAD: [[EHRESUME]]:82// CHECK-LPAD-NEXT:  %[[exn:.+]] = load ptr, ptr %exn.slot, align 883// CHECK-LPAD-NEXT:  %[[sel:.+]] = load i32, ptr %ehselector.slot, align 484// CHECK-LPAD-NEXT:  %[[val1:.+]] = insertvalue { ptr, i32 } poison, ptr %[[exn]], 085// CHECK-LPAD-NEXT:  %[[val2:.+]] = insertvalue { ptr, i32 } %[[val1]], i32 %[[sel]], 186// CHECK-LPAD-NEXT:  resume { ptr, i32 } %[[val2]]87