coro-await-domination.cpp 900 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm %s -o - | 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_never initial_suspend();
  8. suspend_never final_suspend();
  9. void return_void();
  10. static void unhandled_exception();
  11. };
  12. };
  13. struct A {
  14. ~A();
  15. bool await_ready();
  16. int await_resume() { return 8; }
  17. template <typename F> void await_suspend(F);
  18. };
  19. extern "C" void consume(int);
  20. // Verifies that domination is properly built during cleanup.
  21. // Without CGCleanup.cpp fix verifier was reporting:
  22. // Instruction does not dominate all uses!
  23. // %tmp.exprcleanup = alloca i32*, align 8
  24. // store i32* %x, i32** %tmp.exprcleanup, align 8
  25. // CHECK-LABEL: f(
  26. extern "C" coro f(int) {
  27. int x = 42;
  28. x = co_await A{};
  29. consume(x);
  30. }