@@ -1057,7 +1057,7 @@ class IRGenSILFunction :
1057
1057
void emitDebugVariableDeclaration (StorageType Storage, DebugTypeInfo Ty,
1058
1058
SILType SILTy, const SILDebugScope *DS,
1059
1059
VarDecl *VarDecl, SILDebugVariable VarInfo,
1060
- IndirectionKind Indirection = DirectValue ) {
1060
+ IndirectionKind Indirection) {
1061
1061
// TODO: fix demangling for C++ types (SR-13223).
1062
1062
if (swift::TypeBase *ty = SILTy.getASTType ().getPointer ()) {
1063
1063
if (MetatypeType *metaTy = dyn_cast<MetatypeType>(ty))
@@ -4695,6 +4695,14 @@ void IRGenSILFunction::emitPoisonDebugValueInst(DebugValueInst *i) {
4695
4695
Builder.CreateStore (newShadowVal, shadowAddress, ptrAlign);
4696
4696
}
4697
4697
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
+
4698
4706
void IRGenSILFunction::visitDebugValueInst (DebugValueInst *i) {
4699
4707
if (i->poisonRefs ()) {
4700
4708
emitPoisonDebugValueInst (i);
@@ -4739,11 +4747,8 @@ void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) {
4739
4747
if (!IGM.DebugInfo )
4740
4748
return ;
4741
4749
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;
4747
4752
4748
4753
emitDebugVariableDeclaration (Copy, DbgTy, SILTy, i->getDebugScope (),
4749
4754
i->getDecl (), *VarInfo, Indirection);
@@ -5103,15 +5108,17 @@ void IRGenSILFunction::emitDebugInfoForAllocStack(AllocStackInst *i,
5103
5108
assert (isa<llvm::AllocaInst>(addr) || isa<llvm::UndefValue>(addr) ||
5104
5109
isa<llvm::IntrinsicInst>(addr) || isCallToSwiftTaskAlloc (addr));
5105
5110
5106
- auto Indirection = DirectValue;
5111
+ auto Indirection =
5112
+ InCoroContext (*CurSILFn, *i) ? CoroDirectValue : DirectValue;
5107
5113
if (!IGM.IRGen .Opts .DisableDebuggerShadowCopies &&
5108
5114
!IGM.IRGen .Opts .shouldOptimize ())
5109
5115
if (auto *Alloca = dyn_cast<llvm::AllocaInst>(addr))
5110
5116
if (!Alloca->isStaticAlloca ()) {
5111
5117
// Store the address of the dynamic alloca on the stack.
5112
5118
addr = emitShadowCopy (addr, DS, *VarInfo, IGM.getPointerAlignment (),
5113
5119
/* init*/ true );
5114
- Indirection = IndirectValue;
5120
+ Indirection =
5121
+ InCoroContext (*CurSILFn, *i) ? CoroIndirectValue : IndirectValue;
5115
5122
}
5116
5123
5117
5124
if (!Decl)
@@ -5352,9 +5359,9 @@ void IRGenSILFunction::visitAllocBoxInst(swift::AllocBoxInst *i) {
5352
5359
if (!IGM.DebugInfo )
5353
5360
return ;
5354
5361
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);
5358
5365
}
5359
5366
5360
5367
void IRGenSILFunction::visitProjectBoxInst (swift::ProjectBoxInst *i) {
0 commit comments