Skip to content

Commit 8f7c729

Browse files
author
tnowicki
committed
[Coroutines] Verify normalization was not missed
* Add asserts to verify normalization of the coroutine happened. * This will be important if/when normalization becomes part of an ABI object.
1 parent 9a9f155 commit 8f7c729

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
12841284

12851285
// If we have a single edge PHINode, remove it and replace it with a
12861286
// reload from the coroutine frame. (We already took care of multi edge
1287-
// PHINodes by rewriting them in the rewritePHIs function).
1287+
// PHINodes by normalizing them in the rewritePHIs function).
12881288
if (auto *PN = dyn_cast<PHINode>(U)) {
12891289
assert(PN->getNumIncomingValues() == 1 &&
12901290
"unexpected number of incoming "

llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,13 @@ SuspendCrossingInfo::SuspendCrossingInfo(
165165
// Mark all CoroEnd Blocks. We do not propagate Kills beyond coro.ends as
166166
// the code beyond coro.end is reachable during initial invocation of the
167167
// coroutine.
168-
for (auto *CE : CoroEnds)
168+
for (auto *CE : CoroEnds) {
169+
// Verify CoroEnd was normalized
170+
assert(CE->getParent()->getFirstInsertionPt() == CE->getIterator() &&
171+
CE->getParent()->size() <= 2 && "CoroEnd must be in its own BB");
172+
169173
getBlockData(CE->getParent()).End = true;
174+
}
170175

171176
// Mark all suspend blocks and indicate that they kill everything they
172177
// consume. Note, that crossing coro.save also requires a spill, as any code
@@ -179,6 +184,11 @@ SuspendCrossingInfo::SuspendCrossingInfo(
179184
B.Kills |= B.Consumes;
180185
};
181186
for (auto *CSI : CoroSuspends) {
187+
// Verify CoroSuspend was normalized
188+
assert(CSI->getParent()->getFirstInsertionPt() == CSI->getIterator() &&
189+
CSI->getParent()->size() <= 2 &&
190+
"CoroSuspend must be in its own BB");
191+
182192
markSuspendBlock(CSI);
183193
if (auto *Save = CSI->getCoroSave())
184194
markSuspendBlock(Save);

0 commit comments

Comments
 (0)