| 1 |
// RUN: %clang_cc1 -std=c++20 -triple=x86_64-unknown-linux-gnu -emit-llvm -fextend-variable-liveness -o - %s -disable-llvm-passes -fexceptions | FileCheck %s |
| 2 |
|
| 3 |
// See issue #192351 |
| 4 |
// Tests that parameters to a coroutine do not have fake uses inserted for them |
| 5 |
// when we enable -fextend-variable-liveness, except for `this`, which is not |
| 6 |
// stored in the coroutine frame. |
| 7 |
|
| 8 |
#include "Inputs/coroutine.h" |
| 9 |
|
| 10 |
struct task { |
| 11 |
struct promise_type { |
| 12 |
task get_return_object() noexcept { return {}; } |
| 13 |
std::suspend_never initial_suspend() noexcept { return {}; } |
| 14 |
std::suspend_never final_suspend() noexcept { return {}; } |
| 15 |
void return_void() noexcept {} |
| 16 |
void unhandled_exception() noexcept {} |
| 17 |
}; |
| 18 |
}; |
| 19 |
|
| 20 |
class C { |
| 21 |
public: |
| 22 |
C() {} |
| 23 |
|
| 24 |
// CHECK-LABEL: void @_ZN1C1fEb(ptr noundef{{.*}} %this, i1 noundef{{.*}} %b) |
| 25 |
task f(bool b) { |
| 26 |
// CHECK: store ptr %this, ptr %[[THIS_ADDR:.+]] |
| 27 |
// CHECK-NOT: llvm.fake.use |
| 28 |
|
| 29 |
// CHECK: coro.ret: |
| 30 |
// CHECK-NEXT: call void @llvm.coro.end( |
| 31 |
// CHECK-NEXT: %[[THIS_FAKE_USE:.+]] = load ptr, ptr %[[THIS_ADDR]] |
| 32 |
// CHECK-NEXT: notail call void (...) @llvm.fake.use(ptr %[[THIS_FAKE_USE]]) |
| 33 |
// CHECK-NEXT: ret void |
| 34 |
if (b) { |
| 35 |
co_await std::suspend_always{}; |
| 36 |
} |
| 37 |
} |
| 38 |
}; |
| 39 |
|
| 40 |
void foo() { |
| 41 |
C().f(false); |
| 42 |
} |