Skip to content

[CoroSplit] Rename Suspend/End to AlwaysKill/NeverKill (NFC)#199150

Merged
NewSigma merged 1 commit into
llvm:mainfrom
NewSigma:always-never-kill
May 22, 2026
Merged

[CoroSplit] Rename Suspend/End to AlwaysKill/NeverKill (NFC)#199150
NewSigma merged 1 commit into
llvm:mainfrom
NewSigma:always-never-kill

Conversation

@NewSigma
Copy link
Copy Markdown
Contributor

Rename them so that we can generalize to more intrinsics, for example, llvm.coro.is_in_ramp in #198226

@llvmorg-github-actions
Copy link
Copy Markdown

@llvm/pr-subscribers-llvm-transforms

Author: Weibo He (NewSigma)

Changes

Rename them so that we can generalize to more intrinsics, for example, llvm.coro.is_in_ramp in #198226


Full diff: https://github.com/llvm/llvm-project/pull/199150.diff

2 Files Affected:

  • (modified) llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h (+4-4)
  • (modified) llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.cpp (+5-13)
diff --git a/llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h b/llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h
index 1e04f09ddc275..8235c26669be1 100644
--- a/llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h
+++ b/llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h
@@ -60,8 +60,8 @@ class BlockToIndexMapping {
 //   Kills: a bit vector which contains a set of indices of blocks that can
 //          reach block 'i' but there is a path crossing a suspend point
 //          not repeating 'i' (path to 'i' without cycles containing 'i').
-//   Suspend: a boolean indicating whether block 'i' contains a suspend point.
-//   End: a boolean indicating whether block 'i' contains a coro.end intrinsic.
+//   AlwaysKill: a boolean indicating whether block 'i' always propagate kills.
+//   NeverKill: a boolean indicating whether block 'i' never propagate kills.
 //   KillLoop: There is a path from 'i' to 'i' not otherwise repeating 'i' that
 //             crosses a suspend point.
 //
@@ -71,8 +71,8 @@ class SuspendCrossingInfo {
   struct BlockData {
     BitVector Consumes;
     BitVector Kills;
-    bool Suspend = false;
-    bool End = false;
+    bool AlwaysKill = false;
+    bool NeverKill = false;
     bool KillLoop = false;
     bool Changed = false;
   };
diff --git a/llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.cpp b/llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.cpp
index c9bb3395a9949..58c146e7fc680 100644
--- a/llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.cpp
+++ b/llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.cpp
@@ -121,21 +121,13 @@ bool SuspendCrossingInfo::computeBlockData(
       B.Consumes |= P.Consumes;
       B.Kills |= P.Kills;
 
-      // If block P is a suspend block, it should propagate kills into block
-      // B for every block P consumes.
-      if (P.Suspend)
+      if (P.AlwaysKill)
         B.Kills |= P.Consumes;
     }
 
-    if (B.Suspend) {
-      // If block B is a suspend block, it should kill all of the blocks it
-      // consumes.
+    if (B.AlwaysKill) {
       B.Kills |= B.Consumes;
-    } else if (B.End) {
-      // If block B is an end block, it should not propagate kills as the
-      // blocks following coro.end() are reached during initial invocation
-      // of the coroutine while all the data are still available on the
-      // stack or in the registers.
+    } else if (B.NeverKill) {
       B.Kills.reset();
     } else {
       // This is reached when B block it not Suspend nor coro.end and it
@@ -177,7 +169,7 @@ SuspendCrossingInfo::SuspendCrossingInfo(
     assert(CE->getParent()->getFirstInsertionPt() == CE->getIterator() &&
            CE->getParent()->size() <= 2 && "CoroEnd must be in its own BB");
 
-    getBlockData(CE->getParent()).End = true;
+    getBlockData(CE->getParent()).NeverKill = true;
   }
 
   // Mark all suspend blocks and indicate that they kill everything they
@@ -187,7 +179,7 @@ SuspendCrossingInfo::SuspendCrossingInfo(
   auto markSuspendBlock = [&](IntrinsicInst *BarrierInst) {
     BasicBlock *SuspendBlock = BarrierInst->getParent();
     auto &B = getBlockData(SuspendBlock);
-    B.Suspend = true;
+    B.AlwaysKill = true;
     B.Kills |= B.Consumes;
   };
   for (auto *CSI : CoroSuspends) {

@llvmorg-github-actions
Copy link
Copy Markdown

@llvm/pr-subscribers-coroutines

Author: Weibo He (NewSigma)

Changes

Rename them so that we can generalize to more intrinsics, for example, llvm.coro.is_in_ramp in #198226


Full diff: https://github.com/llvm/llvm-project/pull/199150.diff

2 Files Affected:

  • (modified) llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h (+4-4)
  • (modified) llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.cpp (+5-13)
diff --git a/llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h b/llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h
index 1e04f09ddc275..8235c26669be1 100644
--- a/llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h
+++ b/llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h
@@ -60,8 +60,8 @@ class BlockToIndexMapping {
 //   Kills: a bit vector which contains a set of indices of blocks that can
 //          reach block 'i' but there is a path crossing a suspend point
 //          not repeating 'i' (path to 'i' without cycles containing 'i').
-//   Suspend: a boolean indicating whether block 'i' contains a suspend point.
-//   End: a boolean indicating whether block 'i' contains a coro.end intrinsic.
+//   AlwaysKill: a boolean indicating whether block 'i' always propagate kills.
+//   NeverKill: a boolean indicating whether block 'i' never propagate kills.
 //   KillLoop: There is a path from 'i' to 'i' not otherwise repeating 'i' that
 //             crosses a suspend point.
 //
@@ -71,8 +71,8 @@ class SuspendCrossingInfo {
   struct BlockData {
     BitVector Consumes;
     BitVector Kills;
-    bool Suspend = false;
-    bool End = false;
+    bool AlwaysKill = false;
+    bool NeverKill = false;
     bool KillLoop = false;
     bool Changed = false;
   };
diff --git a/llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.cpp b/llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.cpp
index c9bb3395a9949..58c146e7fc680 100644
--- a/llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.cpp
+++ b/llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.cpp
@@ -121,21 +121,13 @@ bool SuspendCrossingInfo::computeBlockData(
       B.Consumes |= P.Consumes;
       B.Kills |= P.Kills;
 
-      // If block P is a suspend block, it should propagate kills into block
-      // B for every block P consumes.
-      if (P.Suspend)
+      if (P.AlwaysKill)
         B.Kills |= P.Consumes;
     }
 
-    if (B.Suspend) {
-      // If block B is a suspend block, it should kill all of the blocks it
-      // consumes.
+    if (B.AlwaysKill) {
       B.Kills |= B.Consumes;
-    } else if (B.End) {
-      // If block B is an end block, it should not propagate kills as the
-      // blocks following coro.end() are reached during initial invocation
-      // of the coroutine while all the data are still available on the
-      // stack or in the registers.
+    } else if (B.NeverKill) {
       B.Kills.reset();
     } else {
       // This is reached when B block it not Suspend nor coro.end and it
@@ -177,7 +169,7 @@ SuspendCrossingInfo::SuspendCrossingInfo(
     assert(CE->getParent()->getFirstInsertionPt() == CE->getIterator() &&
            CE->getParent()->size() <= 2 && "CoroEnd must be in its own BB");
 
-    getBlockData(CE->getParent()).End = true;
+    getBlockData(CE->getParent()).NeverKill = true;
   }
 
   // Mark all suspend blocks and indicate that they kill everything they
@@ -187,7 +179,7 @@ SuspendCrossingInfo::SuspendCrossingInfo(
   auto markSuspendBlock = [&](IntrinsicInst *BarrierInst) {
     BasicBlock *SuspendBlock = BarrierInst->getParent();
     auto &B = getBlockData(SuspendBlock);
-    B.Suspend = true;
+    B.AlwaysKill = true;
     B.Kills |= B.Consumes;
   };
   for (auto *CSI : CoroSuspends) {

@NewSigma
Copy link
Copy Markdown
Contributor Author

Thanks for the code review.

@NewSigma NewSigma enabled auto-merge (squash) May 22, 2026 02:32
@NewSigma NewSigma merged commit dc6c7ee into llvm:main May 22, 2026
12 of 13 checks passed
@NewSigma NewSigma deleted the always-never-kill branch May 22, 2026 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants