[llvm] aefa9ff - [CoroSplit][DebugInfo] Don't use entry_value for async args in 32-bit targets
Felipe de Azevedo Piovezan via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 24 05:50:22 PDT 2023
Author: Felipe de Azevedo Piovezan
Date: 2023-08-24T08:50:12-04:00
New Revision: aefa9ff3ec45e06d7a1302eadf3830513dc97921
URL: https://github.com/llvm/llvm-project/commit/aefa9ff3ec45e06d7a1302eadf3830513dc97921
DIFF: https://github.com/llvm/llvm-project/commit/aefa9ff3ec45e06d7a1302eadf3830513dc97921.diff
LOG: [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
Added:
Modified:
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/test/Transforms/Coroutines/swift-async-dbg.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index c67e2917650bec..771e707dd65ab6 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -1883,7 +1883,7 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
// This dbg.declare is for the main function entry point. It
// will be deleted in all coro-split functions.
coro::salvageDebugInfo(ArgToAllocaMap, DDI, Shape.OptimizeFrame,
- true /*IsEntryPoint*/);
+ false /*UseEntryValue*/);
}
}
@@ -2819,7 +2819,7 @@ static void collectFrameAlloca(AllocaInst *AI, coro::Shape &Shape,
void coro::salvageDebugInfo(
SmallDenseMap<Argument *, AllocaInst *, 4> &ArgToAllocaMap,
- DbgVariableIntrinsic *DVI, bool OptimizeFrame, bool IsEntryPoint) {
+ DbgVariableIntrinsic *DVI, bool OptimizeFrame, bool UseEntryValue) {
Function *F = DVI->getFunction();
IRBuilder<> Builder(F->getContext());
auto InsertPt = F->getEntryBlock().getFirstInsertionPt();
@@ -2874,7 +2874,7 @@ void coro::salvageDebugInfo(
// For the EntryPoint funclet, don't use EntryValues. This funclet can be
// inlined, which would remove the guarantee that this intrinsic targets an
// Argument.
- if (IsSwiftAsyncArg && !IsEntryPoint && !Expr->isEntryValue())
+ if (IsSwiftAsyncArg && UseEntryValue && !Expr->isEntryValue())
Expr = DIExpression::prepend(Expr, DIExpression::EntryValue);
// If the coroutine frame is an Argument, store it in an alloca to improve
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index e3c0ae5d99040c..5569beb6e0273c 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -701,9 +701,13 @@ void CoroCloner::salvageDebugInfo() {
SmallVector<DbgVariableIntrinsic *, 8> Worklist =
collectDbgVariableIntrinsics(*NewF);
SmallDenseMap<Argument *, AllocaInst *, 4> ArgToAllocaMap;
+
+ // Only 64-bit ABIs have a register we can refer to with the entry value.
+ bool UseEntryValue =
+ llvm::Triple(OrigF.getParent()->getTargetTriple()).isArch64Bit();
for (DbgVariableIntrinsic *DVI : Worklist)
coro::salvageDebugInfo(ArgToAllocaMap, DVI, Shape.OptimizeFrame,
- false /*IsEntryPoint*/);
+ UseEntryValue);
// Remove all salvaged dbg.declare intrinsics that became
// either unreachable or stale due to the CoroSplit transformation.
@@ -1997,7 +2001,7 @@ splitCoroutine(Function &F, SmallVectorImpl<Function *> &Clones,
SmallDenseMap<Argument *, AllocaInst *, 4> ArgToAllocaMap;
for (auto *DDI : collectDbgVariableIntrinsics(F))
coro::salvageDebugInfo(ArgToAllocaMap, DDI, Shape.OptimizeFrame,
- true /*IsEntryPoint*/);
+ false /*UseEntryValue*/);
return Shape;
}
diff --git a/llvm/test/Transforms/Coroutines/swift-async-dbg.ll b/llvm/test/Transforms/Coroutines/swift-async-dbg.ll
index 91d605a7e76065..acd077db440dfe 100644
--- a/llvm/test/Transforms/Coroutines/swift-async-dbg.ll
+++ b/llvm/test/Transforms/Coroutines/swift-async-dbg.ll
@@ -1,6 +1,10 @@
-; RUN: opt %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s
+; RUN: opt -mtriple='arm64-' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s
+; RUN: opt -mtriple='x86_64' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s
+; RUN: opt -mtriple='i386-' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s --check-prefix=NOENTRY
+; RUN: opt -mtriple='armv7-' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s --check-prefix=NOENTRY
+; NOENTRY-NOT: OP_llvm_entry_value
+
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
-target triple = "arm64-apple-macosx13.0.0"
; This coroutine has one split point and two variables defined by:
; %var_with_dbg_value, which has multiple dbg.value intrinsics associated with
More information about the llvm-commits
mailing list