Skip to content

Commit 34c8533

Browse files
authored
[Coroutines] Always drop lifetime markers after moving allocas to frame (#149141)
#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 treat them the same way.
1 parent 72c61a6 commit 34c8533

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,13 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
11791179
AllocaInst *Alloca = P.Alloca;
11801180
auto *G = GetFramePointer(Alloca);
11811181

1182+
// Remove any lifetime intrinsics, now that these are no longer allocas.
1183+
for (User *U : make_early_inc_range(Alloca->users())) {
1184+
auto *I = cast<Instruction>(U);
1185+
if (I->isLifetimeStartOrEnd())
1186+
I->eraseFromParent();
1187+
}
1188+
11821189
// We are not using ReplaceInstWithInst(P.first, cast<Instruction>(G))
11831190
// here, as we are changing location of the instruction.
11841191
G->takeName(Alloca);

llvm/test/Transforms/Coroutines/coro-async-addr-lifetime-start-bug.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ loop_exit:
8787
}
8888

8989
; CHECK: define {{.*}} void @my_async_function.resume.0(
90-
; CHECK-NOT: call void @llvm.lifetime.start.p0(i64 4, ptr %3)
91-
; CHECK: br i1 %exitCond, label %loop_exit, label %loop
92-
; CHECK: lifetime.end
90+
; CHECK-NOT: llvm.lifetime
91+
; CHECK: br i1 %exitCond, label %common.ret, label %loop
92+
; CHECK-NOT: llvm.lifetime
9393
; CHECK: }
9494

9595
declare { ptr, ptr, ptr, ptr } @llvm.coro.suspend.async.sl_p0i8p0i8p0i8p0i8s(i32, ptr, ptr, ...)

0 commit comments

Comments
 (0)