[clang] [Clang] Propagate elide safe context through [[clang::coro_must_await]] (PR #108474)
Yuxuan Chen via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 16 11:23:52 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]]
----------------
yuxuanchen1997 wrote:
Just letting you know that `$` at the end is asking the directive to literally check for a dollar sign. `{{$}}` at the end seemed to work fine.
https://github.com/llvm/llvm-project/pull/108474
More information about the cfe-commits
mailing list