[PATCH] D136749: [Don't Commit] [DRAFT] Workaround the example in 57861
Chuanqi Xu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 26 02:18:35 PDT 2022
ChuanqiXu created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
ChuanqiXu requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
https://reviews.llvm.org/D136749
Files:
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
Index: llvm/lib/Transforms/Coroutines/CoroFrame.cpp
===================================================================
--- llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -2400,19 +2400,26 @@
/// after the coro.begin intrinsic.
static void sinkSpillUsesAfterCoroBegin(Function &F,
const FrameDataInfo &FrameData,
- CoroBeginInst *CoroBegin) {
+ coro::Shape &Shape) {
DominatorTree Dom(F);
SmallSetVector<Instruction *, 32> ToMove;
SmallVector<Instruction *, 32> Worklist;
+ CoroBeginInst *CoroBegin = Shape.CoroBegin;
+ SmallVector<Value *, 8> AllDefs = FrameData.getAllDefs();
+
+ if (Shape.ABI == coro::ABI::Switch) {
+ AllDefs.push_back(Shape.getPromiseAlloca());
+ }
+
// Collect all users that precede coro.begin.
- for (auto *Def : FrameData.getAllDefs()) {
+ for (auto *Def : AllDefs) {
for (User *U : Def->users()) {
auto Inst = cast<Instruction>(U);
- if (Inst->getParent() != CoroBegin->getParent() ||
- Dom.dominates(CoroBegin, Inst))
+ if (Dom.dominates(CoroBegin, Inst))
continue;
+
if (ToMove.insert(Inst))
Worklist.push_back(Inst);
}
@@ -2805,11 +2812,9 @@
if (Checker.isDefinitionAcrossSuspend(*V, DVI))
FrameData.Spills[V].push_back(DVI);
}
-
+
LLVM_DEBUG(dumpSpills("Spills", FrameData.Spills));
- if (Shape.ABI == coro::ABI::Retcon || Shape.ABI == coro::ABI::RetconOnce ||
- Shape.ABI == coro::ABI::Async)
- sinkSpillUsesAfterCoroBegin(F, FrameData, Shape.CoroBegin);
+ sinkSpillUsesAfterCoroBegin(F, FrameData, Shape);
Shape.FrameTy = buildFrameType(F, Shape, FrameData);
createFramePtr(Shape);
// For now, this works for C++ programs only.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136749.470752.patch
Type: text/x-patch
Size: 1867 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221026/e256c124/attachment.bin>
More information about the llvm-commits
mailing list