[Coroutines] Always drop lifetime markers after moving allocas to frame#149141
Merged
[Coroutines] Always drop lifetime markers after moving allocas to frame#149141
Conversation
llvm#142551 started always dropping lifetime markers after moving allocas on the frame, as these are not useful on non-allocas but can cause issues. However, this was not done for other ABIs (retcon, retcononce, async) that go through a different code path. We should probably be treating those the same way?
Member
|
@llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-coroutines Author: Nikita Popov (nikic) Changes#142551 started always dropping lifetime markers after moving allocas on the frame, as these are not useful on non-allocas but can cause issues. However, this was not done for other ABIs (retcon, retcononce, async) that go through a different code path. We should probably be treating those the same way? Full diff: https://github.com/llvm/llvm-project/pull/149141.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index fe30c6dc6abe4..fbeb7218ba9a3 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -1179,6 +1179,13 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
AllocaInst *Alloca = P.Alloca;
auto *G = GetFramePointer(Alloca);
+ // Remove any lifetime intrinsics, now that these are no longer allocas.
+ for (User *U : make_early_inc_range(Alloca->users())) {
+ auto *I = cast<Instruction>(U);
+ if (I->isLifetimeStartOrEnd())
+ I->eraseFromParent();
+ }
+
// We are not using ReplaceInstWithInst(P.first, cast<Instruction>(G))
// here, as we are changing location of the instruction.
G->takeName(Alloca);
diff --git a/llvm/test/Transforms/Coroutines/coro-async-addr-lifetime-start-bug.ll b/llvm/test/Transforms/Coroutines/coro-async-addr-lifetime-start-bug.ll
index 2306b72a0055f..40101595092b0 100644
--- a/llvm/test/Transforms/Coroutines/coro-async-addr-lifetime-start-bug.ll
+++ b/llvm/test/Transforms/Coroutines/coro-async-addr-lifetime-start-bug.ll
@@ -87,9 +87,9 @@ loop_exit:
}
; CHECK: define {{.*}} void @my_async_function.resume.0(
-; CHECK-NOT: call void @llvm.lifetime.start.p0(i64 4, ptr %3)
-; CHECK: br i1 %exitCond, label %loop_exit, label %loop
-; CHECK: lifetime.end
+; CHECK-NOT: llvm.lifetime
+; CHECK: br i1 %exitCond, label %common.ret, label %loop
+; CHECK-NOT: llvm.lifetime
; CHECK: }
declare { ptr, ptr, ptr, ptr } @llvm.coro.suspend.async.sl_p0i8p0i8p0i8p0i8s(i32, ptr, ptr, ...)
|
This was referenced Jul 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#142551 started always dropping lifetime markers after moving allocas on the frame, as these are not useful on non-allocas but can cause issues.
However, this was not done for other ABIs (retcon, retcononce, async) that go through a different code path. We should probably be treating those the same way?