Skip to content

Commit 02ba729

Browse files
committed
[debug-info] Debug salvage llvm.dbg.addr in original function that point into the coroutine frame when splitting coros.
We are already doing this in the split functions while we clone. This just handles the original function. I also updated the coroutine split test to validate that we are always referring to the msg in the context object instead of in a shadow copy. rdar://83957028 Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D121324 (cherry picked from commit 0b647fc) Conflicts: llvm/lib/Transforms/Coroutines/CoroSplit.cpp llvm/test/Transforms/Coroutines/coro-debug-frame-variable.ll
1 parent 5a1693c commit 02ba729

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

llvm/lib/Transforms/Coroutines/CoroSplit.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,14 +1839,24 @@ static coro::Shape splitCoroutine(Function &F,
18391839
// This invalidates SwiftErrorOps in the Shape.
18401840
replaceSwiftErrorOps(F, Shape, nullptr);
18411841

1842-
// Salvage debug info that points into the coroutine frame.
1843-
SmallVector<DbgDeclareInst *, 8> Worklist;
1842+
// Finally, salvage the llvm.dbg.{declare,addr} in our original function that
1843+
// point into the coroutine frame. We only do this for the current function
1844+
// since the Cloner salvaged debug info for us in the new coroutine funclets.
1845+
SmallVector<DbgVariableIntrinsic *, 8> Worklist;
18441846
SmallDenseMap<llvm::Value *, llvm::AllocaInst *, 4> DbgPtrAllocaCache;
1845-
for (auto &BB : F)
1846-
for (auto &I : BB)
1847-
if (auto *DDI = dyn_cast<DbgDeclareInst>(&I))
1847+
for (auto &BB : F) {
1848+
for (auto &I : BB) {
1849+
if (auto *DDI = dyn_cast<DbgDeclareInst>(&I)) {
1850+
Worklist.push_back(DDI);
1851+
continue;
1852+
}
1853+
if (auto *DDI = dyn_cast<DbgAddrIntrinsic>(&I)) {
18481854
Worklist.push_back(DDI);
1849-
for (DbgDeclareInst *DDI : Worklist)
1855+
continue;
1856+
}
1857+
}
1858+
}
1859+
for (auto *DDI : Worklist)
18501860
coro::salvageDebugInfo(DbgPtrAllocaCache, DDI, Shape.ReuseFrameSlot);
18511861

18521862
return Shape;

llvm/test/Transforms/Coroutines/coro-debug-dbg.addr-swift.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
; RUN: opt %s -passes='function(coro-early),cgscc(coro-split,simplifycfg)' -S | FileCheck %s
99

1010
; CHECK-LABEL: define swifttailcc void @"$s10async_args14withGenericArgyyxnYalF"(%swift.context* swiftasync %0, %swift.opaque* noalias %1, %swift.type* %T){{.*}} {
11-
; CHECK: call void @llvm.dbg.declare(
12-
; CHECK: call void @llvm.dbg.addr(
11+
; CHECK: call void @llvm.dbg.declare(metadata %swift.context** [[CORO_CTX:%[a-z0-9\.]+]],
12+
; CHECK: call void @llvm.dbg.addr(metadata %swift.context** [[CORO_CTX]],
1313
; CHECK-NOT: llvm.dbg.value
1414
; CHECK-NOT: llvm.dbg.addr
1515
; CHECK-NOT: llvm.dbg.declare
@@ -19,15 +19,15 @@
1919

2020
; CHECK-LABEL: define internal swifttailcc void @"$s10async_args14withGenericArgyyxnYalFTY0_"(i8* swiftasync %0)
2121
; CHECK: entryresume.0
22-
; CHECK: call void @llvm.dbg.declare(
23-
; CHECK: call void @llvm.dbg.addr(
22+
; CHECK: call void @llvm.dbg.declare(metadata i8** [[CORO_CTX:%[a-z0-9\.]+]],
23+
; CHECK: call void @llvm.dbg.addr(metadata i8** [[CORO_CTX]],
2424
; CHECK: musttail call swifttailcc void @"$s10async_args10forceSplityyYaF"(%swift.context* swiftasync
2525
; CHECK-NEXT: ret void
2626
; CHECK-NEXT: }
2727

2828
; CHECK: define internal swifttailcc void @"$s10async_args14withGenericArgyyxnYalFTQ1_"(i8* swiftasync %0)
29-
; CHECK: call void @llvm.dbg.declare
30-
; CHECK: call void @llvm.dbg.addr
29+
; CHECK: call void @llvm.dbg.declare(metadata i8** [[CORO_CTX:%[a-z0-9\.]+]],
30+
; CHECK: call void @llvm.dbg.addr(metadata i8** [[CORO_CTX]],
3131
; CHECK: call void @llvm.dbg.value(metadata %swift.opaque** undef,
3232
; CHECK: ret void
3333
; CHECK-NEXT: }

0 commit comments

Comments
 (0)