[CoroSplit] Rename Suspend/End to AlwaysKill/NeverKill (NFC)#199150
Merged
Conversation
|
@llvm/pr-subscribers-llvm-transforms Author: Weibo He (NewSigma) ChangesRename them so that we can generalize to more intrinsics, for example, Full diff: https://github.com/llvm/llvm-project/pull/199150.diff 2 Files Affected:
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) {
|
|
@llvm/pr-subscribers-coroutines Author: Weibo He (NewSigma) ChangesRename them so that we can generalize to more intrinsics, for example, Full diff: https://github.com/llvm/llvm-project/pull/199150.diff 2 Files Affected:
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) {
|
ChuanqiXu9
approved these changes
May 22, 2026
Contributor
Author
|
Thanks for the code review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rename them so that we can generalize to more intrinsics, for example,
llvm.coro.is_in_rampin #198226