coro-dest-slot.cpp 865 B

1234567891011121314151617181920212223242526
  1. // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
  2. #include "Inputs/coroutine.h"
  3. using namespace std::experimental;
  4. struct coro {
  5. struct promise_type {
  6. coro get_return_object();
  7. suspend_always initial_suspend();
  8. suspend_never final_suspend();
  9. void return_void();
  10. static void unhandled_exception();
  11. };
  12. };
  13. extern "C" coro f(int) { co_return; }
  14. // Verify that cleanup.dest.slot is eliminated in a coroutine.
  15. // CHECK-LABEL: f(
  16. // CHECK: call void @_ZNSt12experimental13coroutines_v113suspend_never12await_resumeEv(
  17. // CHECK: %[[CLEANUP_DEST:.+]] = phi i32 [ 0, %{{.+}} ], [ 2, %{{.+}} ], [ 2, %{{.+}} ]
  18. // CHECK: call i8* @llvm.coro.free(
  19. // CHECK: switch i32 %cleanup.dest.slot.0, label %{{.+}} [
  20. // CHECK-NEXT: i32 0
  21. // CHECK-NEXT: i32 2
  22. // CHECK-NEXT: ]