Skip to content

Commit 33e39ad

Browse files
[CoroSplit][DebugInfo] Don't use entry_value for async args in 32-bit targets
Only X86_64 and ARM64 have a reserved register for async arguments, and so the debugger is only able to handle those targets. For other architectures, we use a non-entry-value expression and let the debugger do its best with that. Differential Revision: https://reviews.llvm.org/D158638 (cherry picked from commit aefa9ff)
1 parent fbdb691 commit 33e39ad

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,7 +1879,7 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
18791879
// This dbg.declare is for the main function entry point. It
18801880
// will be deleted in all coro-split functions.
18811881
coro::salvageDebugInfo(ArgToAllocaMap, DDI, Shape.OptimizeFrame,
1882-
true /*IsEntryPoint*/);
1882+
false /*UseEntryValue*/);
18831883
}
18841884
}
18851885

@@ -2819,7 +2819,7 @@ static void collectFrameAlloca(AllocaInst *AI, coro::Shape &Shape,
28192819

28202820
void coro::salvageDebugInfo(
28212821
SmallDenseMap<Argument *, AllocaInst *, 4> &ArgToAllocaMap,
2822-
DbgVariableIntrinsic *DVI, bool OptimizeFrame, bool IsEntryPoint) {
2822+
DbgVariableIntrinsic *DVI, bool OptimizeFrame, bool UseEntryValue) {
28232823
Function *F = DVI->getFunction();
28242824
IRBuilder<> Builder(F->getContext());
28252825
auto InsertPt = F->getEntryBlock().getFirstInsertionPt();
@@ -2878,7 +2878,7 @@ void coro::salvageDebugInfo(
28782878
// For the EntryPoint funclet, don't use EntryValues. This funclet can be
28792879
// inlined, which would remove the guarantee that this intrinsic targets an
28802880
// Argument.
2881-
if (IsSwiftAsyncArg && !IsEntryPoint && !Expr->isEntryValue())
2881+
if (IsSwiftAsyncArg && UseEntryValue && !Expr->isEntryValue())
28822882
Expr = DIExpression::prepend(Expr, DIExpression::EntryValue);
28832883

28842884
// If the coroutine frame is an Argument, store it in an alloca to improve

llvm/lib/Transforms/Coroutines/CoroSplit.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,9 +701,13 @@ void CoroCloner::salvageDebugInfo() {
701701
SmallVector<DbgVariableIntrinsic *, 8> Worklist =
702702
collectDbgVariableIntrinsics(*NewF);
703703
SmallDenseMap<Argument *, AllocaInst *, 4> ArgToAllocaMap;
704+
705+
// Only 64-bit ABIs have a register we can refer to with the entry value.
706+
bool UseEntryValue =
707+
llvm::Triple(OrigF.getParent()->getTargetTriple()).isArch64Bit();
704708
for (DbgVariableIntrinsic *DVI : Worklist)
705709
coro::salvageDebugInfo(ArgToAllocaMap, DVI, Shape.OptimizeFrame,
706-
false /*IsEntryPoint*/);
710+
UseEntryValue);
707711

708712
// Remove all salvaged dbg.declare intrinsics that became
709713
// either unreachable or stale due to the CoroSplit transformation.
@@ -1989,7 +1993,7 @@ splitCoroutine(Function &F, SmallVectorImpl<Function *> &Clones,
19891993
SmallDenseMap<Argument *, AllocaInst *, 4> ArgToAllocaMap;
19901994
for (auto *DDI : collectDbgVariableIntrinsics(F))
19911995
coro::salvageDebugInfo(ArgToAllocaMap, DDI, Shape.OptimizeFrame,
1992-
true /*IsEntryPoint*/);
1996+
false /*UseEntryValue*/);
19931997

19941998
return Shape;
19951999
}

llvm/test/Transforms/Coroutines/swift-async-dbg.ll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
; RUN: opt %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s
1+
; RUN: opt -mtriple='arm64-' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s
2+
; RUN: opt -mtriple='x86_64' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s
3+
; RUN: opt -mtriple='i386-' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s --check-prefix=NOENTRY
4+
; RUN: opt -mtriple='armv7-' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s --check-prefix=NOENTRY
5+
; NOENTRY-NOT: OP_llvm_entry_value
6+
27
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
3-
target triple = "arm64-apple-macosx13.0.0"
48

59
; This coroutine has one split point and two variables defined by:
610
; %var_with_dbg_value, which has multiple dbg.value intrinsics associated with

0 commit comments

Comments
 (0)