[llvm] [Coroutines] Add verifier checks for llvm.coro.begin and llvm.coro.id (PR #192887)

via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 19 20:00:09 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-coroutines

Author: Weibo He (NewSigma)

<details>
<summary>Changes</summary>

Close #<!-- -->156652
Close #<!-- -->191990

---

Patch is 88.94 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/192887.diff


81 Files Affected:

- (modified) llvm/lib/IR/Verifier.cpp (+22-2) 
- (modified) llvm/test/Transforms/Coroutines/ArgAddr.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-align16.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-align32.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-align64-02.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-align64.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-align8-02.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-align8.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloc-with-param-O0.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloc-with-param-O2.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloca-01.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloca-02.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloca-03.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloca-04.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloca-05.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloca-06.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloca-07.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloca-08.ll (+4-4) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloca-09.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloca-10.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloca-loop-carried-address.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloca-outside-frame.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-alloca-with-addrspace.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-catchswitch-cleanuppad.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-catchswitch.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-debug-spill-dbg.declare.ll (+1-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-00.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-01.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-eh-aware-edge-split-02.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-frame-arrayalloca.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-00.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-03.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-frame-unreachable.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-frame.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-lifetime-end.ll (+6-6) 
- (modified) llvm/test/Transforms/Coroutines/coro-materialize.ll (+5-5) 
- (modified) llvm/test/Transforms/Coroutines/coro-padding.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-param-copy.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-readnone-02.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-readnone.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-spill-after-phi.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-spill-corobegin.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-spill-defs-before-corobegin.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-spill-promise-02.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-spill-promise.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-spill-suspend.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-00.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-02.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-addrspace.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-alloc.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-eh-00.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-eh-01.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-final-suspend.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-hidden.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-musttail-ppc64le.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-musttail.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-musttail1.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-musttail10.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-musttail12.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-musttail13.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-musttail2.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-musttail3.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-musttail4.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-musttail5.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-musttail6.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-musttail7.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-musttail8.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-musttail9.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-no-lifetime.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-noinline.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-01.ll (+4-4) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-02.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-03.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-04.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-tbaa-md-neg-2.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-tbaa-md-neg.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/coro-split-tbaa-md.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-zero-alloca.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/gh107139-split-in-scc.ll (+1-1) 
- (modified) llvm/test/Transforms/Coroutines/gh114487-crash-in-cgscc.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/no-suspend.ll (+8-8) 


``````````diff
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index d4ade9c7ce534..12c6ea52ca0fc 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -123,6 +123,7 @@
 #include "llvm/Support/ModRef.h"
 #include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Transforms/Coroutines/CoroInstr.h"
 #include <algorithm>
 #include <cassert>
 #include <cstdint>
@@ -6037,10 +6038,29 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
     }
     break;
   }
+  case Intrinsic::coro_begin:
+  case Intrinsic::coro_begin_custom_abi:
+    Check(isa<AnyCoroIdInst>(Call.getArgOperand(0)),
+          "id argument of llvm.coro.begin must refer to coro.id");
+    break;
   case Intrinsic::coro_id: {
-    auto *InfoArg = Call.getArgOperand(3)->stripPointerCasts();
-    if (isa<ConstantPointerNull>(InfoArg))
+    Check(isa<ConstantInt>(Call.getArgOperand(0)),
+          "align argument only accepts constants");
+    auto *Promise = Call.getArgOperand(1);
+    Check(isa<ConstantPointerNull>(Promise) || isa<AllocaInst>(Promise),
+          "promise argument must refer to an alloca");
+
+    auto *CoroAddr = Call.getArgOperand(2)->stripPointerCasts();
+    bool BeforeCoroEarly = isa<ConstantPointerNull>(CoroAddr);
+    Check(BeforeCoroEarly || isa<Function>(CoroAddr),
+          "coro argument must refer to a function");
+
+    auto *InfoArg = Call.getArgOperand(3);
+    bool BeforeCoroSplit = isa<ConstantPointerNull>(InfoArg);
+    if (BeforeCoroSplit)
       break;
+
+    Check(!BeforeCoroEarly, "cannot run CoroSplit before CoroEarly");
     auto *GV = dyn_cast<GlobalVariable>(InfoArg);
     Check(GV && GV->isConstant() && GV->hasDefinitiveInitializer(),
           "info argument of llvm.coro.id must refer to an initialized "
diff --git a/llvm/test/Transforms/Coroutines/ArgAddr.ll b/llvm/test/Transforms/Coroutines/ArgAddr.ll
index c6fca4996d86c..11ca32a4ba83e 100644
--- a/llvm/test/Transforms/Coroutines/ArgAddr.ll
+++ b/llvm/test/Transforms/Coroutines/ArgAddr.ll
@@ -9,7 +9,7 @@ define nonnull ptr @f(i32 %n) presplitcoroutine {
 ; CHECK-LABEL: define nonnull ptr @f(
 ; CHECK-SAME: i32 [[N:%.*]]) {
 ; CHECK-NEXT:  [[ENTRY:.*:]]
-; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f.resumers)
+; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr @f.resumers)
 ; CHECK-NEXT:    [[N_ADDR:%.*]] = alloca i32, align 4
 ; CHECK-NEXT:    store i32 [[N]], ptr [[N_ADDR]], align 4
 ; CHECK-NEXT:    [[CALL:%.*]] = tail call ptr @malloc(i32 24)
@@ -29,7 +29,7 @@ define nonnull ptr @f(i32 %n) presplitcoroutine {
 ; CHECK-NEXT:    ret ptr [[TMP0]]
 ;
 entry:
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null);
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null);
   %n.addr = alloca i32
   store i32 %n, ptr %n.addr ; this needs to go after coro.begin
   %0 = tail call i32 @llvm.coro.size.i32()
diff --git a/llvm/test/Transforms/Coroutines/coro-align16.ll b/llvm/test/Transforms/Coroutines/coro-align16.ll
index e74f23e8e531c..12674b00e165a 100644
--- a/llvm/test/Transforms/Coroutines/coro-align16.ll
+++ b/llvm/test/Transforms/Coroutines/coro-align16.ll
@@ -8,7 +8,7 @@ target datalayout = "e-m:e-p:64:64-i64:64-f80:128-n8:16:32:64-S128"
 define ptr @f() presplitcoroutine {
 ; CHECK-LABEL: define ptr @f() {
 ; CHECK-NEXT:  [[ENTRY:.*:]]
-; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f.resumers)
+; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr @f.resumers)
 ; CHECK-NEXT:    [[ALLOC:%.*]] = call ptr @aligned_alloc(i32 16, i32 48)
 ; CHECK-NEXT:    [[HDL:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]])
 ; CHECK-NEXT:    store ptr @f.resume, ptr [[HDL]], align 8
@@ -22,7 +22,7 @@ entry:
   ; %x needs to go to the frame since it's escaped; %y will stay as local since it doesn't escape.
   %x = alloca i64, align 16
   %y = alloca i64
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null)
   %size = call i32 @llvm.coro.size.i32()
   %align = call i32 @llvm.coro.align.i32()
   %alloc = call ptr @aligned_alloc(i32 %align, i32 %size)
diff --git a/llvm/test/Transforms/Coroutines/coro-align32.ll b/llvm/test/Transforms/Coroutines/coro-align32.ll
index 6f61a32fde95a..9dfb91dce8ca5 100644
--- a/llvm/test/Transforms/Coroutines/coro-align32.ll
+++ b/llvm/test/Transforms/Coroutines/coro-align32.ll
@@ -8,7 +8,7 @@ target datalayout = "e-m:e-p:64:64-i64:64-f80:128-n8:16:32:64-S128"
 define ptr @f() presplitcoroutine {
 ; CHECK-LABEL: define ptr @f() {
 ; CHECK-NEXT:  [[ENTRY:.*:]]
-; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f.resumers)
+; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr @f.resumers)
 ; CHECK-NEXT:    [[ALLOC:%.*]] = call ptr @aligned_alloc(i32 32, i32 64)
 ; CHECK-NEXT:    [[HDL:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]])
 ; CHECK-NEXT:    store ptr @f.resume, ptr [[HDL]], align 8
@@ -24,7 +24,7 @@ entry:
   %y = alloca i32, align 32
   %z = alloca i32, align 16
   %alpha = alloca i1, align 8
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null)
   %size = call i32 @llvm.coro.size.i32()
   %align = call i32 @llvm.coro.align.i32()
   %alloc = call ptr @aligned_alloc(i32 %align, i32 %size)
diff --git a/llvm/test/Transforms/Coroutines/coro-align64-02.ll b/llvm/test/Transforms/Coroutines/coro-align64-02.ll
index 471e4fc751378..a97ae3682211b 100644
--- a/llvm/test/Transforms/Coroutines/coro-align64-02.ll
+++ b/llvm/test/Transforms/Coroutines/coro-align64-02.ll
@@ -8,7 +8,7 @@ target datalayout = "e-m:e-p:64:64-i64:64-f80:128-n8:16:32:64-S128"
 define ptr @f() presplitcoroutine {
 ; CHECK-LABEL: define ptr @f() {
 ; CHECK-NEXT:  [[ENTRY:.*:]]
-; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f.resumers)
+; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr @f.resumers)
 ; CHECK-NEXT:    [[ALLOC:%.*]] = call ptr @aligned_alloc(i32 64, i32 128)
 ; CHECK-NEXT:    [[HDL:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]])
 ; CHECK-NEXT:    store ptr @f.resume, ptr [[HDL]], align 8
@@ -22,7 +22,7 @@ entry:
   ; Both %x and %y need to go to the frame since they're escaped.
   %x = alloca i1, align 64
   %y = alloca i64, align 32
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null)
   %size = call i32 @llvm.coro.size.i32()
   %align = call i32 @llvm.coro.align.i32()
   %alloc = call ptr @aligned_alloc(i32 %align, i32 %size)
diff --git a/llvm/test/Transforms/Coroutines/coro-align64.ll b/llvm/test/Transforms/Coroutines/coro-align64.ll
index 801a7a1d89a9a..efded219ba2db 100644
--- a/llvm/test/Transforms/Coroutines/coro-align64.ll
+++ b/llvm/test/Transforms/Coroutines/coro-align64.ll
@@ -8,7 +8,7 @@ target datalayout = "e-m:e-p:64:64-i64:64-f80:128-n8:16:32:64-S128"
 define ptr @f() presplitcoroutine {
 ; CHECK-LABEL: define ptr @f() {
 ; CHECK-NEXT:  [[ENTRY:.*:]]
-; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f.resumers)
+; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr @f.resumers)
 ; CHECK-NEXT:    [[ALLOC:%.*]] = call ptr @aligned_alloc(i32 64, i32 128)
 ; CHECK-NEXT:    [[HDL:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]])
 ; CHECK-NEXT:    store ptr @f.resume, ptr [[HDL]], align 8
@@ -22,7 +22,7 @@ entry:
   ; Both %x and %y need to go to the frame since they're escaped.
   %x = alloca i1, align 64
   %y = alloca i64
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null)
   %size = call i32 @llvm.coro.size.i32()
   %align = call i32 @llvm.coro.align.i32()
   %alloc = call ptr @aligned_alloc(i32 %align, i32 %size)
diff --git a/llvm/test/Transforms/Coroutines/coro-align8-02.ll b/llvm/test/Transforms/Coroutines/coro-align8-02.ll
index 5a09b211ccfe4..a578887f54b60 100644
--- a/llvm/test/Transforms/Coroutines/coro-align8-02.ll
+++ b/llvm/test/Transforms/Coroutines/coro-align8-02.ll
@@ -8,7 +8,7 @@ target datalayout = "e-m:e-p:64:64-i64:64-f80:128-n8:16:32:64-S128"
 define ptr @f() presplitcoroutine {
 ; CHECK-LABEL: define ptr @f() {
 ; CHECK-NEXT:  [[ENTRY:.*:]]
-; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f.resumers)
+; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr @f.resumers)
 ; CHECK-NEXT:    [[ALLOC:%.*]] = call ptr @aligned_alloc(i32 8, i32 24)
 ; CHECK-NEXT:    [[HDL:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]])
 ; CHECK-NEXT:    store ptr @f.resume, ptr [[HDL]], align 8
@@ -19,7 +19,7 @@ define ptr @f() presplitcoroutine {
 ; CHECK-NEXT:    ret ptr [[HDL]]
 ;
 entry:
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null)
   %size = call i32 @llvm.coro.size.i32()
   %align = call i32 @llvm.coro.align.i32()
   %alloc = call ptr @aligned_alloc(i32 %align, i32 %size)
diff --git a/llvm/test/Transforms/Coroutines/coro-align8.ll b/llvm/test/Transforms/Coroutines/coro-align8.ll
index d98fd10a44655..7368816c921f7 100644
--- a/llvm/test/Transforms/Coroutines/coro-align8.ll
+++ b/llvm/test/Transforms/Coroutines/coro-align8.ll
@@ -8,7 +8,7 @@ target datalayout = "e-m:e-p:64:64-i64:64-f80:128-n8:16:32:64-S128"
 define ptr @f() presplitcoroutine {
 ; CHECK-LABEL: define ptr @f() {
 ; CHECK-NEXT:  [[ENTRY:.*:]]
-; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f.resumers)
+; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr @f.resumers)
 ; CHECK-NEXT:    [[ALLOC:%.*]] = call ptr @aligned_alloc(i32 8, i32 32)
 ; CHECK-NEXT:    [[HDL:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]])
 ; CHECK-NEXT:    store ptr @f.resume, ptr [[HDL]], align 8
@@ -22,7 +22,7 @@ entry:
   ; %x needs to go to the frame since it's escaped; %y will stay as local since it doesn't escape.
   %x = alloca i64
   %y = alloca i64
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null)
   %size = call i32 @llvm.coro.size.i32()
   %align = call i32 @llvm.coro.align.i32()
   %alloc = call ptr @aligned_alloc(i32 %align, i32 %size)
diff --git a/llvm/test/Transforms/Coroutines/coro-alloc-with-param-O0.ll b/llvm/test/Transforms/Coroutines/coro-alloc-with-param-O0.ll
index 77f383a4ff387..b996ffeeaa4f5 100644
--- a/llvm/test/Transforms/Coroutines/coro-alloc-with-param-O0.ll
+++ b/llvm/test/Transforms/Coroutines/coro-alloc-with-param-O0.ll
@@ -10,7 +10,7 @@ entry:
   %this.addr = alloca i64
   store i64 %this_arg, ptr %this.addr
   %this = load i64, ptr %this.addr
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f_copy, ptr null)
   %size = call i32 @llvm.coro.size.i32()
   %alloc = call ptr @myAlloc(i64 %this, i32 %size)
   %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
@@ -50,7 +50,7 @@ declare void @free(ptr)
 ; CHECK-NEXT:  [[ENTRY:.*:]]
 ; CHECK-NEXT:    [[THIS_ADDR:%.*]] = alloca i64, align 8
 ; CHECK-NEXT:    store i64 [[THIS_ARG]], ptr [[THIS_ADDR]], align 4
-; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f_copy.resumers)
+; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr @f_copy, ptr @f_copy.resumers)
 ; CHECK-NEXT:    [[ALLOC:%.*]] = call ptr @myAlloc(i64 [[THIS_ARG]], i32 32)
 ; CHECK-NEXT:    [[HDL:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]])
 ; CHECK-NEXT:    store ptr @f_copy.resume, ptr [[HDL]], align 8
diff --git a/llvm/test/Transforms/Coroutines/coro-alloc-with-param-O2.ll b/llvm/test/Transforms/Coroutines/coro-alloc-with-param-O2.ll
index 953f937b62e17..f8c40879067e2 100644
--- a/llvm/test/Transforms/Coroutines/coro-alloc-with-param-O2.ll
+++ b/llvm/test/Transforms/Coroutines/coro-alloc-with-param-O2.ll
@@ -7,7 +7,7 @@
 ; using this directly (as it would happen under -O2)
 define ptr @f_direct(i64 %this) presplitcoroutine {
 entry:
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f_direct, ptr null)
   %size = call i32 @llvm.coro.size.i32()
   %alloc = call ptr @myAlloc(i64 %this, i32 %size)
   %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
@@ -45,7 +45,7 @@ declare void @free(ptr)
 ; CHECK-LABEL: define ptr @f_direct(
 ; CHECK-SAME: i64 [[THIS:%.*]]) {
 ; CHECK-NEXT:  [[ENTRY:.*:]]
-; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f_direct.resumers)
+; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr @f_direct, ptr @f_direct.resumers)
 ; CHECK-NEXT:    [[ALLOC:%.*]] = call ptr @myAlloc(i64 [[THIS]], i32 32)
 ; CHECK-NEXT:    [[HDL:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]])
 ; CHECK-NEXT:    store ptr @f_direct.resume, ptr [[HDL]], align 8
diff --git a/llvm/test/Transforms/Coroutines/coro-alloca-01.ll b/llvm/test/Transforms/Coroutines/coro-alloca-01.ll
index 64530553c254a..c11d785ca594b 100644
--- a/llvm/test/Transforms/Coroutines/coro-alloca-01.ll
+++ b/llvm/test/Transforms/Coroutines/coro-alloca-01.ll
@@ -10,7 +10,7 @@ define ptr @f(i1 %n) presplitcoroutine {
 ; CHECK-LABEL: define ptr @f(
 ; CHECK-SAME: i1 [[N:%.*]]) {
 ; CHECK-NEXT:  [[ENTRY:.*]]:
-; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f.resumers)
+; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr @f.resumers)
 ; CHECK-NEXT:    [[ALLOC:%.*]] = call ptr @malloc(i32 48)
 ; CHECK-NEXT:    [[HDL:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]])
 ; CHECK-NEXT:    store ptr @f.resume, ptr [[HDL]], align 8
@@ -33,7 +33,7 @@ entry:
   ; both %x and %y, as well as %alias_phi would all go to the frame.
   %x = alloca i64
   %y = alloca i64
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null)
   %size = call i32 @llvm.coro.size.i32()
   %alloc = call ptr @malloc(i32 %size)
   %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
diff --git a/llvm/test/Transforms/Coroutines/coro-alloca-02.ll b/llvm/test/Transforms/Coroutines/coro-alloca-02.ll
index 5dfa4892c03d3..4573af711175a 100644
--- a/llvm/test/Transforms/Coroutines/coro-alloca-02.ll
+++ b/llvm/test/Transforms/Coroutines/coro-alloca-02.ll
@@ -9,7 +9,7 @@ target datalayout = "e-m:e-p:64:64-i64:64-f80:128-n8:16:32:64-S128"
 define ptr @f() presplitcoroutine {
 ; CHECK-LABEL: define ptr @f() {
 ; CHECK-NEXT:  [[ENTRY:.*:]]
-; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f.resumers)
+; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr @f.resumers)
 ; CHECK-NEXT:    [[ALLOC:%.*]] = call ptr @malloc(i32 40)
 ; CHECK-NEXT:    [[HDL:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]])
 ; CHECK-NEXT:    store ptr @f.resume, ptr [[HDL]], align 8
@@ -25,7 +25,7 @@ define ptr @f() presplitcoroutine {
 entry:
   %x = alloca i64
   %y = alloca ptr
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null)
   %size = call i32 @llvm.coro.size.i32()
   %alloc = call ptr @malloc(i32 %size)
   %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
diff --git a/llvm/test/Transforms/Coroutines/coro-alloca-03.ll b/llvm/test/Transforms/Coroutines/coro-alloca-03.ll
index 4c5e4393dae90..e316ed4347394 100644
--- a/llvm/test/Transforms/Coroutines/coro-alloca-03.ll
+++ b/llvm/test/Transforms/Coroutines/coro-alloca-03.ll
@@ -9,7 +9,7 @@ define ptr @f() presplitcoroutine {
 ; CHECK-LABEL: define ptr @f() {
 ; CHECK-NEXT:  [[ENTRY:.*:]]
 ; CHECK-NEXT:    [[Y:%.*]] = alloca i64, align 8
-; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f.resumers)
+; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr @f.resumers)
 ; CHECK-NEXT:    [[ALLOC:%.*]] = call ptr @malloc(i32 32)
 ; CHECK-NEXT:    [[HDL:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]])
 ; CHECK-NEXT:    store ptr @f.resume, ptr [[HDL]], align 8
@@ -26,7 +26,7 @@ entry:
   ; %x needs to go to the frame since it's escaped; %y will stay as local since it doesn't escape.
   %x = alloca i64
   %y = alloca i64
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null)
   %size = call i32 @llvm.coro.size.i32()
   %alloc = call ptr @malloc(i32 %size)
   %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
diff --git a/llvm/test/Transforms/Coroutines/coro-alloca-04.ll b/llvm/test/Transforms/Coroutines/coro-alloca-04.ll
index f31c0fc32defc..62581594f2a0d 100644
--- a/llvm/test/Transforms/Coroutines/coro-alloca-04.ll
+++ b/llvm/test/Transforms/Coroutines/coro-alloca-04.ll
@@ -10,7 +10,7 @@ define ptr @f(i1 %n) presplitcoroutine {
 ; CHECK-LABEL: define ptr @f(
 ; CHECK-SAME: i1 [[N:%.*]]) {
 ; CHECK-NEXT:  [[ENTRY:.*:]]
-; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f.resumers)
+; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr @f.resumers)
 ; CHECK-NEXT:    [[ALLOC:%.*]] = call ptr @malloc(i32 40)
 ; CHECK-NEXT:    [[HDL:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]])
 ; CHECK-NEXT:    store ptr @f.resume, ptr [[HDL]], align 8
@@ -36,7 +36,7 @@ flag_false:
 
 merge:
   %alias_phi = phi ptr [ %x, %flag_true ], [ %x, %flag_false ]
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null)
   %size = call i32 @llvm.coro.size.i32()
   %alloc = call ptr @malloc(i32 %size)
   %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
diff --git a/llvm/test/Transforms/Coroutines/coro-alloca-05.ll b/llvm/test/Transforms/Coroutines/coro-alloca-05.ll
index a096bb1beea21..3affa9b156691 100644
--- a/llvm/test/Transforms/Coroutines/coro-alloca-05.ll
+++ b/llvm/test/Transforms/Coroutines/coro-alloca-05.ll
@@ -4,7 +4,7 @@
 
 define ptr @f() presplitcoroutine {
 entry:
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null)
   %size = call i32 @llvm.coro.size.i32()
   %alloc = call ptr @malloc(i32 %size)
   %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
diff --git a/llvm/test/Transforms/Coroutines/coro-alloca-06.ll b/llvm/test/Transforms/Coroutines/coro-alloca-06.ll
index e9c54f8c49171..83242a5140305 100644
--- a/llvm/test/Transforms/Coroutines/coro-alloca-06.ll
+++ b/llvm/test/Transforms/Coroutines/coro-alloca-06.ll
@@ -13,7 +13,7 @@ define ptr @f() presplitcoroutine {
 ; CHECK-NEXT:  [[ENTRY:.*:]]
 ; CHECK-NEXT:    [[TMP0:%.*]] = alloca [[HANDLE:%.*]], align 8
 ; CHECK-NEXT:    [[TMP1:%.*]] = alloca ptr, align 8
-; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f.resumers)
+; CHECK-NEXT:    [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr @f.resumers)
 ; CHECK-NEXT:    [[ALLOC:%.*]] = call ptr @malloc(i32 24)
 ; CHECK-NEXT:    [[HDL:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]])
 ; CHECK-NEXT:    store ptr @f.resume, ptr [[HDL]], align 8
@@ -31,7 +31,7 @@ define ptr @f() presplitcoroutine {
 entry:
   %0 = alloca %"handle", align 8
   %1 = alloca ptr, align 8
-  %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
+  %id = call token @llvm.coro.id(i32 0, ptr null, ptr @f, ptr null)
   %size = call i32 @llvm.coro.size.i32()
   %alloc = call ptr @malloc(i32 %size)
   %hdl = call ptr @llv...
[truncated]

``````````

</details>


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


More information about the llvm-commits mailing list