[clang] [Clang] Propagate elide safe context through [[clang::coro_must_await]] (PR #108474)
Adrian Vogelsgesang via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 14 05:00:30 PDT 2024
================
@@ -84,4 +84,35 @@ Task<int> nonelidable() {
co_return 1;
}
+// CHECK-LABEL: define{{.*}} @_Z8addTasksO4TaskIiES1_{{.*}} {
+Task<int> addTasks([[clang::coro_must_await]] Task<int> &&t1, Task<int> &&t2) {
+ int i1 = co_await t1;
+ int i2 = co_await t2;
+ co_return i1 + i2;
+}
+
+// CHECK-LABEL: define{{.*}} @_Z10returnSamei{{.*}} {
+Task<int> returnSame(int i) {
+ co_return i;
+}
+
+// CHECK-LABEL: define{{.*}} @_Z21elidableWithMustAwaitv{{.*}} {
+Task<int> elidableWithMustAwait() {
+ // CHECK: call void @_Z10returnSamei(ptr {{.*}}, i32 noundef 2) #[[ELIDE_SAFE]]
+ // CHECK-NOT: call void @_Z10returnSamei(ptr {{.*}}, i32 noundef 3) #[[ELIDE_SAFE]]
----------------
vogelsgesang wrote:
Can we somehow turn this into a positive test? Negative tests can easily regress, e.g. if something else in the line would change.
Can we use a `$` (or some other mechanism) to check for the end of the line, and there by explicitly check that a call to `_Z10returnSamei(ptr {{.*}}, i32 noundef 3)` does exist, but does not have the ELIDE_SAFE annotation?
```suggestion
// CHECK: call void @_Z10returnSamei(ptr {{.*}}, i32 noundef 3)$
```
https://github.com/llvm/llvm-project/pull/108474
More information about the cfe-commits
mailing list