[clang] [CIR] Pass the promise address to cir.coro.intrinsic.id (PR #236293)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 2 11:53:38 PST 2026


================
@@ -423,6 +423,16 @@ CIRGenFunction::emitCoroutineBody(const CoroutineBodyStmt &s) {
     auto initialSuspendBuilder = [&]() -> mlir::LogicalResult {
       if (emitStmt(s.getPromiseDeclStmt(), /*useCurrentScope=*/true).failed())
         return mlir::failure();
+      // Update coro.id to refer to the promise. We could not do it earlier
+      // because the promise local variable was not emitted yet.
+      Address promiseAddr = getAddrOfLocalVar(s.getPromiseDecl());
+      {
+        mlir::OpBuilder::InsertionGuard guard(builder);
+        builder.setInsertionPoint(coroId);
+        mlir::Value promisePtr = builder.createBitcast(
----------------
erichkeane wrote:

Hmm... a 'more specific' pointer kind than void might be a nice addition to this feature in the future, but relaxing it to 'any pointer' is probably reasonable to stop this from having to happen.

https://github.com/llvm/llvm-project/pull/236293


More information about the cfe-commits mailing list