coro-promise-dtor.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -triple=x86_64-pc-windows-msvc18.0.0 -emit-llvm -o - %s -fexceptions -fcxx-exceptions -disable-llvm-passes | FileCheck %s
  2. // -triple=x86_64-unknown-linux-gnu
  3. #include "Inputs/coroutine.h"
  4. namespace coro = std::experimental::coroutines_v1;
  5. struct coro_t {
  6. void* p;
  7. ~coro_t();
  8. struct promise_type {
  9. coro_t get_return_object();
  10. coro::suspend_never initial_suspend();
  11. coro::suspend_never final_suspend();
  12. void return_void();
  13. promise_type();
  14. ~promise_type();
  15. void unhandled_exception();
  16. };
  17. };
  18. struct Cleanup { ~Cleanup(); };
  19. void may_throw();
  20. coro_t f() {
  21. Cleanup cleanup;
  22. may_throw();
  23. co_return;
  24. }
  25. // CHECK-LABEL: define dso_local void @"?f@@YA?AUcoro_t@@XZ"(
  26. // CHECK: %gro.active = alloca i1
  27. // CHECK: store i1 false, i1* %gro.active
  28. // CHECK: invoke %"struct.coro_t::promise_type"* @"??0promise_type@coro_t@@QEAA@XZ"(
  29. // CHECK: invoke void @"?get_return_object@promise_type@coro_t@@QEAA?AU2@XZ"(
  30. // CHECK: store i1 true, i1* %gro.active
  31. // CHECK: %[[IS_ACTIVE:.+]] = load i1, i1* %gro.active
  32. // CHECK: br i1 %[[IS_ACTIVE]], label %[[CLEANUP1:.+]], label
  33. // CHECK: [[CLEANUP1]]:
  34. // CHECK: %[[NRVO:.+]] = load i1, i1* %nrvo
  35. // CHECK: br i1 %[[NRVO]], label %{{.+}}, label %[[DTOR:.+]]
  36. // CHECK: [[DTOR]]:
  37. // CHECK: call void @"??1coro_t@@QEAA@XZ"(