[PATCH] D24242: [Coroutines] Part13: Handle single edge PHINodes across suspends

Gor Nishanov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 5 21:08:05 PDT 2016


GorNishanov added inline comments.

================
Comment at: lib/Transforms/Coroutines/CoroEarly.cpp:169-174
@@ -162,2 +168,8 @@
   }
+  // Make sure that all CoroFree reference the coro.id intrinsic.
+  // Token type is not exposed through coroutine C/C++ builtins to plain C, so
+  // we allow specifying none and fixing it up here.
+  if (CoroId)
+    for (CoroFreeInst *CF : CoroFrees)
+      CF->setArgOperand(0, CoroId);
   return Changed;
----------------
majnemer wrote:
> Can't the FE do this?
Coroutine await C++ FE, sure.

This particular helper allows construct coroutines in plain C using __builtins mapping to llvm.coro.* intrinsics.
coro.id creates trouble, since it returns tokens and those do not have a good mapping in the builtin type system.

The workaround is to allow __builtin_coro_free(mem) output llvm.coro.free(token none, %mem) and then fixup in CoroEarly to point to an appropriate coro.id.


https://reviews.llvm.org/D24242





More information about the llvm-commits mailing list