[PATCH] D90977: [Coroutine] Move all used local allocas to the .resume function
Xun Li via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 6 14:56:59 PST 2020
lxfind created this revision.
Herald added subscribers: llvm-commits, modimo, wenlei, modocache, hiraditya.
Herald added a project: LLVM.
lxfind requested review of this revision.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90977
Files:
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
Index: llvm/lib/Transforms/Coroutines/CoroSplit.cpp
===================================================================
--- llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -581,15 +581,6 @@
Builder.CreateUnreachable();
BranchToEntry->eraseFromParent();
- // Move any allocas into Entry that weren't moved into the frame.
- for (auto IT = OldEntry->begin(), End = OldEntry->end(); IT != End;) {
- Instruction &I = *IT++;
- if (!isa<AllocaInst>(&I) || I.use_empty())
- continue;
-
- I.moveBefore(*Entry, Entry->getFirstInsertionPt());
- }
-
// Branch from the entry to the appropriate place.
Builder.SetInsertPoint(Entry);
switch (Shape.ABI) {
@@ -614,6 +605,19 @@
break;
}
}
+
+ // Any alloca that's still being used but not reachable from the new entry
+ // needs to be moved to the new entry.
+ Function *F = OldEntry->getParent();
+ DominatorTree DT{*F};
+ for (auto IT = inst_begin(F), End = inst_end(F); IT != End;) {
+ Instruction &I = *IT++;
+ if (!isa<AllocaInst>(&I) || I.use_empty())
+ continue;
+ if (DT.isReachableFromEntry(I.getParent()))
+ continue;
+ I.moveBefore(*Entry, Entry->getFirstInsertionPt());
+ }
}
/// Derive the value of the new frame pointer.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90977.303559.patch
Type: text/x-patch
Size: 1296 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201106/a351866f/attachment.bin>
More information about the llvm-commits
mailing list