[llvm-branch-commits] [llvm] release/20.x: [CoroSplit] Always erase lifetime intrinsics for spilled allocas (#142551) (PR #147448)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jul 7 19:12:56 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-coroutines
@llvm/pr-subscribers-llvm-transforms
Author: None (llvmbot)
<details>
<summary>Changes</summary>
Backport 038dc2c63b2db744be6afeea74b18be4938149e9
Requested by: @<!-- -->ChuanqiXu9
---
Full diff: https://github.com/llvm/llvm-project/pull/147448.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+9-12)
``````````diff
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index 68edabb083be3..35832b594e9a3 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -1213,11 +1213,17 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
for (const auto &A : FrameData.Allocas) {
AllocaInst *Alloca = A.Alloca;
UsersToUpdate.clear();
- for (User *U : Alloca->users()) {
+ for (User *U : make_early_inc_range(Alloca->users())) {
auto *I = cast<Instruction>(U);
- if (DT.dominates(Shape.CoroBegin, 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.
+ if (I->isLifetimeStartOrEnd())
+ I->eraseFromParent();
+ else if (DT.dominates(Shape.CoroBegin, I))
UsersToUpdate.push_back(I);
}
+
if (UsersToUpdate.empty())
continue;
auto *G = GetFramePointer(Alloca);
@@ -1231,17 +1237,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) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/147448
More information about the llvm-branch-commits
mailing list