diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp --- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp @@ -1883,7 +1883,7 @@ // 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 @@ void coro::salvageDebugInfo( SmallDenseMap &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 @@ // 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 --- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp @@ -701,9 +701,13 @@ SmallVector Worklist = collectDbgVariableIntrinsics(*NewF); SmallDenseMap 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 @@ SmallDenseMap 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 --- 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