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 @@ -1882,7 +1882,8 @@ &*Builder.GetInsertPoint()); // 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); + coro::salvageDebugInfo(ArgToAllocaMap, DDI, Shape.OptimizeFrame, + true /*IsEntryPoint*/); } } @@ -2818,7 +2819,7 @@ void coro::salvageDebugInfo( SmallDenseMap &ArgToAllocaMap, - DbgVariableIntrinsic *DVI, bool OptimizeFrame) { + DbgVariableIntrinsic *DVI, bool OptimizeFrame, bool IsEntryPoint) { Function *F = DVI->getFunction(); IRBuilder<> Builder(F->getContext()); auto InsertPt = F->getEntryBlock().getFirstInsertionPt(); @@ -2870,7 +2871,10 @@ // Swift async arguments are described by an entry value of the ABI-defined // register containing the coroutine context. - if (IsSwiftAsyncArg && !Expr->isEntryValue()) + // 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()) 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/CoroInternal.h b/llvm/lib/Transforms/Coroutines/CoroInternal.h --- a/llvm/lib/Transforms/Coroutines/CoroInternal.h +++ b/llvm/lib/Transforms/Coroutines/CoroInternal.h @@ -32,7 +32,7 @@ /// OptimizeFrame is false. void salvageDebugInfo( SmallDenseMap &ArgToAllocaMap, - DbgVariableIntrinsic *DVI, bool OptimizeFrame); + DbgVariableIntrinsic *DVI, bool OptimizeFrame, bool IsEntryPoint); // Keeps data and helper functions for lowering coroutine intrinsics. struct LowererBase { 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 @@ -702,7 +702,8 @@ collectDbgVariableIntrinsics(*NewF); SmallDenseMap ArgToAllocaMap; for (DbgVariableIntrinsic *DVI : Worklist) - coro::salvageDebugInfo(ArgToAllocaMap, DVI, Shape.OptimizeFrame); + coro::salvageDebugInfo(ArgToAllocaMap, DVI, Shape.OptimizeFrame, + false /*IsEntryPoint*/); // Remove all salvaged dbg.declare intrinsics that became // either unreachable or stale due to the CoroSplit transformation. @@ -1995,7 +1996,8 @@ // coroutine funclets. SmallDenseMap ArgToAllocaMap; for (auto *DDI : collectDbgVariableIntrinsics(F)) - coro::salvageDebugInfo(ArgToAllocaMap, DDI, Shape.OptimizeFrame); + coro::salvageDebugInfo(ArgToAllocaMap, DDI, Shape.OptimizeFrame, + true /*IsEntryPoint*/); 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 @@ -19,9 +19,9 @@ ; CHECK-LABEL: define {{.*}} @coroutineA( ; CHECK-SAME: ptr swiftasync %[[frame_ptr:.*]]) ; CHECK: @llvm.dbg.declare(metadata ptr %[[frame_ptr]], {{.*}} !DIExpression( -; CHECK-SAME: DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8) +; CHECK-SAME: DW_OP_plus_uconst, 16, DW_OP_plus_uconst, 8) ; CHECK: @llvm.dbg.value(metadata ptr %[[frame_ptr]], {{.*}} !DIExpression( -; CHECK-SAME: DW_OP_LLVM_entry_value, 1, DW_OP_plus_uconst, 16, DW_OP_deref) +; CHECK-SAME: DW_OP_plus_uconst, 16, DW_OP_deref) ; CHECK: call {{.*}} @swift_task_switch %i7 = call ptr @llvm.coro.async.resume(), !dbg !54