@@ -1057,7 +1057,7 @@ class IRGenSILFunction :
10571057 void emitDebugVariableDeclaration (StorageType Storage, DebugTypeInfo Ty,
10581058 SILType SILTy, const SILDebugScope *DS,
10591059 VarDecl *VarDecl, SILDebugVariable VarInfo,
1060- IndirectionKind Indirection = DirectValue ) {
1060+ IndirectionKind Indirection) {
10611061 // TODO: fix demangling for C++ types (SR-13223).
10621062 if (swift::TypeBase *ty = SILTy.getASTType ().getPointer ()) {
10631063 if (MetatypeType *metaTy = dyn_cast<MetatypeType>(ty))
@@ -4695,6 +4695,14 @@ void IRGenSILFunction::emitPoisonDebugValueInst(DebugValueInst *i) {
46954695 Builder.CreateStore (newShadowVal, shadowAddress, ptrAlign);
46964696}
46974697
4698+ // / Determine whether the debug-info-carrying instruction \c i belongs to an
4699+ // / async function and thus may get allocated in the coroutine context. These
4700+ // / variables need to be marked with the Coro flag, so LLVM's CoroSplit pass can
4701+ // / recognize them.
4702+ static bool InCoroContext (SILFunction &f, SILInstruction &i) {
4703+ return f.isAsync () && !i.getDebugScope ()->InlinedCallSite ;
4704+ }
4705+
46984706void IRGenSILFunction::visitDebugValueInst (DebugValueInst *i) {
46994707 if (i->poisonRefs ()) {
47004708 emitPoisonDebugValueInst (i);
@@ -4739,11 +4747,8 @@ void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) {
47394747 if (!IGM.DebugInfo )
47404748 return ;
47414749
4742- IndirectionKind Indirection = DirectValue;
4743- if (CurSILFn->isAsync () && !i->getDebugScope ()->InlinedCallSite &&
4744- (Copy.empty () || !isa<llvm::Constant>(Copy[0 ]))) {
4745- Indirection = CoroDirectValue;
4746- }
4750+ IndirectionKind Indirection =
4751+ InCoroContext (*CurSILFn, *i) ? CoroDirectValue : DirectValue;
47474752
47484753 emitDebugVariableDeclaration (Copy, DbgTy, SILTy, i->getDebugScope (),
47494754 i->getDecl (), *VarInfo, Indirection);
@@ -5103,15 +5108,17 @@ void IRGenSILFunction::emitDebugInfoForAllocStack(AllocStackInst *i,
51035108 assert (isa<llvm::AllocaInst>(addr) || isa<llvm::UndefValue>(addr) ||
51045109 isa<llvm::IntrinsicInst>(addr) || isCallToSwiftTaskAlloc (addr));
51055110
5106- auto Indirection = DirectValue;
5111+ auto Indirection =
5112+ InCoroContext (*CurSILFn, *i) ? CoroDirectValue : DirectValue;
51075113 if (!IGM.IRGen .Opts .DisableDebuggerShadowCopies &&
51085114 !IGM.IRGen .Opts .shouldOptimize ())
51095115 if (auto *Alloca = dyn_cast<llvm::AllocaInst>(addr))
51105116 if (!Alloca->isStaticAlloca ()) {
51115117 // Store the address of the dynamic alloca on the stack.
51125118 addr = emitShadowCopy (addr, DS, *VarInfo, IGM.getPointerAlignment (),
51135119 /* init*/ true );
5114- Indirection = IndirectValue;
5120+ Indirection =
5121+ InCoroContext (*CurSILFn, *i) ? CoroIndirectValue : IndirectValue;
51155122 }
51165123
51175124 if (!Decl)
@@ -5352,9 +5359,9 @@ void IRGenSILFunction::visitAllocBoxInst(swift::AllocBoxInst *i) {
53525359 if (!IGM.DebugInfo )
53535360 return ;
53545361
5355- IGM.DebugInfo ->emitVariableDeclaration (Builder, Storage, DbgTy,
5356- i->getDebugScope (), Decl, *VarInfo,
5357- IndirectValue);
5362+ IGM.DebugInfo ->emitVariableDeclaration (
5363+ Builder, Storage, DbgTy, i->getDebugScope (), Decl, *VarInfo,
5364+ InCoroContext (*CurSILFn, *i) ? CoroIndirectValue : IndirectValue);
53585365}
53595366
53605367void IRGenSILFunction::visitProjectBoxInst (swift::ProjectBoxInst *i) {
0 commit comments