Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions llvm/lib/Transforms/Coroutines/CoroFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1212,14 +1212,25 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
Builder.SetInsertPoint(Shape.AllocaSpillBlock,
Shape.AllocaSpillBlock->begin());
SmallVector<Instruction *, 4> UsersToUpdate;
SmallVector<Instruction *, 4> Lifetimes;
for (const auto &A : FrameData.Allocas) {
AllocaInst *Alloca = A.Alloca;
UsersToUpdate.clear();
Lifetimes.clear();
for (User *U : Alloca->users()) {
auto *I = cast<Instruction>(U);
if (DT.dominates(Shape.CoroBegin, I))
if (I->isLifetimeStartOrEnd())
Lifetimes.push_back(I);
else if (DT.dominates(Shape.CoroBegin, I))
UsersToUpdate.push_back(I);
}

// It is meaningless to retain the lifetime intrinsics refer for the
// member of coroutine frames and the meaningless lifetime intrinsics
// are possible to block further optimizations.
for (auto *I : Lifetimes)
I->eraseFromParent();

if (UsersToUpdate.empty())
continue;
auto *G = GetFramePointer(Alloca);
Expand All @@ -1233,17 +1244,8 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
for (auto *DVR : DbgVariableRecords)
DVR->replaceVariableLocationOp(Alloca, G);

for (Instruction *I : UsersToUpdate) {
// It is meaningless to retain the lifetime intrinsics refer for the
// member of coroutine frames and the meaningless lifetime intrinsics
// are possible to block further optimizations.
if (I->isLifetimeStartOrEnd()) {
I->eraseFromParent();
continue;
}

for (Instruction *I : UsersToUpdate)
I->replaceUsesOfWith(Alloca, G);
}
}
Builder.SetInsertPoint(&*Shape.getInsertPtAfterFramePtr());
for (const auto &A : FrameData.Allocas) {
Expand Down
Loading