Skip to content

Commit e854ac4

Browse files
authored
Merge pull request #36042 from adrian-prantl/74460135
2 parents 6a43d39 + 582bbbd commit e854ac4

File tree

4 files changed

+114
-126
lines changed

4 files changed

+114
-126
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2474,7 +2474,6 @@ bool IRGenDebugInfoImpl::verifyCoroutineArgument(llvm::Value *Addr) {
24742474
"unhandled projection");
24752475
Storage = CallInst->getArgOperand(0);
24762476
} else
2477-
24782477
break;
24792478
}
24802479
return llvm::isa<llvm::Argument>(Storage);

lib/IRGen/IRGenSIL.cpp

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,8 @@ class IRGenSILFunction :
853853
IGM.DebugInfo->emitVariableDeclaration(Builder, Storage, Ty, DS, VarDecl,
854854
VarInfo, Indirection);
855855
}
856+
/// Emit a direct path to an Argument.
857+
llvm::Value *getDirectCoroutineArgument(llvm::Value *Addr);
856858

857859
void emitFailBB() {
858860
if (!FailBBs.empty()) {
@@ -4297,6 +4299,53 @@ void IRGenSILFunction::emitErrorResultVar(CanSILFunctionType FnTy,
42974299
IndirectValue, ArtificialValue);
42984300
}
42994301

4302+
llvm::Value *IRGenSILFunction::getDirectCoroutineArgument(llvm::Value *Addr) {
4303+
auto getDirect = [&](llvm::Instruction *Orig) {
4304+
llvm::Value *Buffered = Orig->getOperand(0);
4305+
llvm::Value *Direct = getDirectCoroutineArgument(Buffered);
4306+
if (Buffered == Direct)
4307+
return Orig;
4308+
llvm::Instruction *Cloned = Orig->clone();
4309+
Cloned->setOperand(0, Direct);
4310+
Cloned->insertBefore(Orig);
4311+
return Cloned;
4312+
};
4313+
if (auto *LdInst = dyn_cast<llvm::LoadInst>(Addr))
4314+
return getDirect(LdInst);
4315+
if (auto *GEPInst = dyn_cast<llvm::GetElementPtrInst>(Addr))
4316+
return getDirect(GEPInst);
4317+
if (auto *BCInst = dyn_cast<llvm::BitCastInst>(Addr))
4318+
return getDirect(BCInst);
4319+
if (auto *CallInst = dyn_cast<llvm::CallInst>(Addr)) {
4320+
llvm::Value *Buffered = CallInst->getArgOperand(0);
4321+
if (CallInst->getCalledFunction() != IGM.getProjectBoxFn()) {
4322+
assert(false && "unhandled projection");
4323+
return CallInst;
4324+
}
4325+
llvm::Value *Direct = getDirectCoroutineArgument(Buffered);
4326+
if (Buffered == Direct)
4327+
return CallInst;
4328+
auto *Cloned = cast<llvm::CallInst>(CallInst->clone());
4329+
Cloned->setArgOperand(0, Direct);
4330+
Cloned->insertBefore(CallInst);
4331+
return Cloned;
4332+
}
4333+
if (auto *AllocaInst = dyn_cast<llvm::AllocaInst>(Addr)) {
4334+
llvm::Value *Direct = nullptr;
4335+
unsigned NumStores = 0;
4336+
for (auto &AIUse : AllocaInst->uses()) {
4337+
llvm::User *U = AIUse.getUser();
4338+
if (llvm::StoreInst *StInst = llvm::dyn_cast<llvm::StoreInst>(U)) {
4339+
++NumStores;
4340+
Direct = StInst->getOperand(0);
4341+
}
4342+
}
4343+
if (NumStores == 1)
4344+
return Direct;
4345+
}
4346+
return Addr;
4347+
}
4348+
43004349
void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) {
43014350
if (i->getDebugScope()->getInlinedFunction()->isTransparent())
43024351
return;
@@ -4322,8 +4371,8 @@ void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) {
43224371
if (VarDecl *Decl = i->getDecl()) {
43234372
DbgTy = DebugTypeInfo::getLocalVariable(
43244373
Decl, RealTy, getTypeInfo(SILVal->getType()));
4325-
} else if (i->getFunction()->isBare() &&
4326-
!SILTy.hasArchetype() && !VarInfo->Name.empty()) {
4374+
} else if (i->getFunction()->isBare() && !SILTy.hasArchetype() &&
4375+
!VarInfo->Name.empty()) {
43274376
// Preliminary support for .sil debug information.
43284377
DbgTy = DebugTypeInfo::getFromTypeInfo(RealTy, getTypeInfo(SILTy));
43294378
} else
@@ -4337,8 +4386,19 @@ void IRGenSILFunction::visitDebugValueInst(DebugValueInst *i) {
43374386
if (!IGM.DebugInfo)
43384387
return;
43394388

4389+
IndirectionKind Indirection = DirectValue;
4390+
if (CurSILFn->isAsync() && VarInfo->ArgNo &&
4391+
!i->getDebugScope()->InlinedCallSite) {
4392+
for (auto &Val : Copy) {
4393+
Val = getDirectCoroutineArgument(Val);
4394+
assert(IGM.DebugInfo->verifyCoroutineArgument(Val) &&
4395+
"arg expected to be load from inside %swift.context");
4396+
}
4397+
Indirection = CoroDirectValue;
4398+
}
4399+
43404400
emitDebugVariableDeclaration(Copy, DbgTy, SILTy, i->getDebugScope(),
4341-
i->getDecl(), *VarInfo);
4401+
i->getDecl(), *VarInfo, Indirection);
43424402
}
43434403

43444404
void IRGenSILFunction::visitDebugValueAddrInst(DebugValueAddrInst *i) {
@@ -4363,7 +4423,8 @@ void IRGenSILFunction::visitDebugValueAddrInst(DebugValueAddrInst *i) {
43634423
auto *Addr = getLoweredAddress(SILVal).getAddress();
43644424
SILType SILTy = SILVal->getType();
43654425
auto RealType = SILTy.getASTType();
4366-
if (CurSILFn->isAsync() && VarInfo->ArgNo) {
4426+
if (CurSILFn->isAsync() && VarInfo->ArgNo &&
4427+
!i->getDebugScope()->InlinedCallSite) {
43674428
if (IGM.DebugInfo)
43684429
assert(IGM.DebugInfo->verifyCoroutineArgument(Addr) &&
43694430
"arg expected to be load from inside %swift.context");
@@ -5322,7 +5383,7 @@ static void emitUncheckedValueBitCast(IRGenSILFunction &IGF,
53225383
in.transferInto(out, in.size());
53235384
return;
53245385
}
5325-
5386+
53265387
// TODO: We could do bitcasts entirely in the value domain in some cases, but
53275388
// for simplicity, let's just always go through the stack for now.
53285389

@@ -5427,7 +5488,7 @@ static void trivialRefConversion(IRGenSILFunction &IGF,
54275488
}
54285489
out.add(value);
54295490
}
5430-
5491+
54315492
IGF.setLoweredExplosion(result, out);
54325493
}
54335494

@@ -5627,7 +5688,7 @@ void IRGenSILFunction::visitBridgeObjectToRefInst(
56275688
// If it's not a tagged pointer, mask off the spare bits.
56285689
Builder.emitBlock(notTagged);
56295690
}
5630-
5691+
56315692
// Mask off the spare bits (if they exist).
56325693
auto &spareBits = IGM.getHeapObjectSpareBits();
56335694
llvm::Value *result;
@@ -5715,7 +5776,7 @@ void IRGenSILFunction::visitCheckedCastBranchInst(
57155776
llvm::ConstantPointerNull::get(cast<llvm::PointerType>(val->getType()));
57165777
castResult.succeeded = Builder.CreateICmpNE(val, nil);
57175778
}
5718-
5779+
57195780
// Branch on the success of the cast.
57205781
// All cast operations currently return null on failure.
57215782

@@ -5783,7 +5844,7 @@ void IRGenSILFunction::visitKeyPathInst(swift::KeyPathInst *I) {
57835844
argsBufSize = llvm::ConstantInt::get(IGM.SizeTy, 0);
57845845
argsBufAlign = llvm::ConstantInt::get(IGM.SizeTy, 0);
57855846
}
5786-
5847+
57875848
SmallVector<llvm::Value *, 4> operandOffsets;
57885849
for (unsigned i : indices(I->getAllOperands())) {
57895850
auto operand = I->getAllOperands()[i].get();

test/DebugInfo/async-args.swift

Lines changed: 16 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// RUN: %target-swift-frontend %s -emit-ir -g -o - \
22
// RUN: -module-name M -enable-experimental-concurrency \
3-
// RUN: -parse-as-library | %FileCheck %s --check-prefix=CHECK \
4-
// RUN: --check-prefix=CHECK-%target-cpu
3+
// RUN: -parse-as-library | %FileCheck %s
54
// REQUIRES: concurrency
65

76
// REQUIRES: rdar74551043
@@ -13,122 +12,23 @@ func withGenericArg<T>(_ msg: T) async {
1312
// This odd debug info is part of a contract with CoroSplit/CoroFrame to fix
1413
// this up after coroutine splitting.
1514
// CHECK-LABEL: {{^define .*}} @"$s1M14withGenericArgyyxYlF"(%swift.task* %0, %swift.executor* %1, %swift.context* swiftasync %2)
16-
// CHECK: call void @llvm.dbg.declare(metadata %swift.context** %[[ALLOCA:[^,]+]],
17-
// CHECK-SAME: metadata ![[TAU:[0-9]+]], metadata !DIExpression(
18-
// CHECK-SAME: DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}))
19-
// CHECK: call void @llvm.dbg.declare(metadata %swift.context** %[[ALLOCA]],
15+
// CHECK: call void @llvm.dbg.declare(metadata %swift.context* %2,
2016
// CHECK-SAME: metadata ![[MSG:[0-9]+]], metadata !DIExpression(
21-
// CHECK-SAME: DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
22-
// CHECK: store %swift.context* %2, %swift.context** %[[ALLOCA]], align
17+
// CHECK-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
18+
// CHECK: call void @llvm.dbg.declare(metadata %swift.context* %2,
19+
// CHECK-SAME: metadata ![[TAU:[0-9]+]], metadata !DIExpression(
20+
// CHECK-SAME: DW_OP_plus_uconst, {{[0-9]+}}))
2321

2422
await forceSplit()
2523
// CHECK-LABEL: {{^define .*}} @"$s1M14withGenericArgyyxYlF.resume.0"(i8* %0, i8* %1, i8* swiftasync %2)
26-
27-
// CHECK-arm64e: [[CTXT_PTR:%[0-9]+]] = bitcast i8* %2 to i8**
28-
// CHECK-arm64e: [[SIGNED_CTXT:%[0-9]+]] = load i8*, i8** [[CTXT_PTR]]
29-
// CHECK-arm64e: [[CTXT_PTR_INT:%[0-9]+]] = ptrtoint i8** [[CTXT_PTR]] to i64
30-
// CHECK-arm64e: [[PTRAUTH_BLEND:%[0-9]+]] = call i64 @llvm.ptrauth.blend.i64(i64 [[CTXT_PTR_INT]], i64 48546)
31-
// CHECK-arm64e: [[SIGNED_CTXT_INT:%[0-9]+]] = ptrtoint i8* [[SIGNED_CTXT]]
32-
// CHECK-arm64e: [[CTXT:%[0-9]+]] = call i64 @llvm.ptrauth.auth.i64(i64 [[SIGNED_CTXT_INT]], i32 2, i64 [[PTRAUTH_BLEND]])
33-
// CHECK-arm64e: %[[ALLOCA:[0-9+]]] = inttoptr i64 [[CTXT]] to i8*
34-
// CHECK-arm64e: call void @llvm.dbg.declare(metadata i8* %[[ALLOCA]],
35-
// CHECK-arm64e-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression(
36-
// CHECK-arm64e-SAME: DW_OP_plus_uconst, [[OFFSET:[0-9]+]],
37-
// CHECK-arm64e-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
38-
// CHECK-arm64e: call void @llvm.dbg.declare(metadata i8* %[[ALLOCA]],
39-
// CHECK-arm64e-SAME: metadata ![[TAU_R:[0-9]+]], metadata !DIExpression(
40-
// CHECK-arm64e-SAME: DW_OP_plus_uconst, [[OFFSET]],
41-
// CHECK-arm64e-SAME: DW_OP_plus_uconst, {{[0-9]+}}))
42-
43-
// CHECK-i386: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA:[^,]+]],
44-
// CHECK-i386-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression(
45-
// CHECK-i386-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET:[0-9]+]],
46-
// CHECK-i386-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
47-
// CHECK-i386: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA]],
48-
// CHECK-i386-SAME: metadata ![[TAU_R:[0-9]+]], metadata !DIExpression(
49-
// CHECK-i386-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET]],
50-
// CHECK-i386-SAME: DW_OP_plus_uconst, {{[0-9]+}}))
51-
// CHECK-i386: store i8* %2, i8** %[[ALLOCA]], align
52-
53-
// CHECK-x86_64: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA:[^,]+]],
54-
// CHECK-x86_64-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression(
55-
// CHECK-x86_64-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET:[0-9]+]],
56-
// CHECK-x86_64-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
57-
// CHECK-x86_64: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA]],
58-
// CHECK-x86_64-SAME: metadata ![[TAU_R:[0-9]+]], metadata !DIExpression(
59-
// CHECK-x86_64-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET]],
60-
// CHECK-x86_64-SAME: DW_OP_plus_uconst, {{[0-9]+}}))
61-
// CHECK-x86_64: store i8* %2, i8** %[[ALLOCA]], align
62-
63-
// CHECK-armv7: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA:[^,]+]],
64-
// CHECK-armv7-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression(
65-
// CHECK-armv7-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET:[0-9]+]],
66-
// CHECK-armv7-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
67-
// CHECK-armv7: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA]],
68-
// CHECK-armv7-SAME: metadata ![[TAU_R:[0-9]+]], metadata !DIExpression(
69-
// CHECK-armv7-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET]],
70-
// CHECK-armv7-SAME: DW_OP_plus_uconst, {{[0-9]+}}))
71-
// CHECK-armv7: store i8* %2, i8** %[[ALLOCA]], align
72-
73-
// CHECK-armv7k: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA:[^,]+]],
74-
// CHECK-armv7k-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression(
75-
// CHECK-armv7k-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET:[0-9]+]],
76-
// CHECK-armv7k-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
77-
// CHECK-armv7k: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA]],
78-
// CHECK-armv7k-SAME: metadata ![[TAU_R:[0-9]+]], metadata !DIExpression(
79-
// CHECK-armv7k-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET]],
80-
// CHECK-armv7k-SAME: DW_OP_plus_uconst, {{[0-9]+}}))
81-
// CHECK-armv7k: store i8* %2, i8** %[[ALLOCA]], align
82-
83-
// CHECK-armv7s: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA:[^,]+]],
84-
// CHECK-armv7s-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression(
85-
// CHECK-armv7s-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET:[0-9]+]],
86-
// CHECK-armv7s-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
87-
// CHECK-armv7s: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA]],
88-
// CHECK-armv7s-SAME: metadata ![[TAU_R:[0-9]+]], metadata !DIExpression(
89-
// CHECK-armv7s-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET]],
90-
// CHECK-armv7s-SAME: DW_OP_plus_uconst, {{[0-9]+}}))
91-
// CHECK-armv7s: store i8* %2, i8** %[[ALLOCA]], align
92-
93-
// CHECK-arm64: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA:[^,]+]],
94-
// CHECK-arm64-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression(
95-
// CHECK-arm64-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET:[0-9]+]],
96-
// CHECK-arm64-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
97-
// CHECK-arm64: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA]],
98-
// CHECK-arm64-SAME: metadata ![[TAU_R:[0-9]+]], metadata !DIExpression(
99-
// CHECK-arm64-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET]],
100-
// CHECK-arm64-SAME: DW_OP_plus_uconst, {{[0-9]+}}))
101-
// CHECK-arm64: store i8* %2, i8** %[[ALLOCA]], align
102-
103-
// CHECK-aarch64: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA:[^,]+]],
104-
// CHECK-aarch64-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression(
105-
// CHECK-aarch64-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET:[0-9]+]],
106-
// CHECK-aarch64-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
107-
// CHECK-aarch64: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA]],
108-
// CHECK-aarch64-SAME: metadata ![[TAU_R:[0-9]+]], metadata !DIExpression(
109-
// CHECK-aarch64-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET]],
110-
// CHECK-aarch64-SAME: DW_OP_plus_uconst, {{[0-9]+}}))
111-
// CHECK-aarch64: store i8* %2, i8** %[[ALLOCA]], align
112-
113-
// CHECK-powerpc64: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA:[^,]+]],
114-
// CHECK-powerpc64-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression(
115-
// CHECK-powerpc64-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET:[0-9]+]],
116-
// CHECK-powerpc64-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
117-
// CHECK-powerpc64: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA]],
118-
// CHECK-powerpc64-SAME: metadata ![[TAU_R:[0-9]+]], metadata !DIExpression(
119-
// CHECK-powerpc64-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET]],
120-
// CHECK-powerpc64-SAME: DW_OP_plus_uconst, {{[0-9]+}}))
121-
// CHECK-powerpc64: store i8* %2, i8** %[[ALLOCA]], align
122-
123-
// CHECK-powerpc64le: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA:[^,]+]],
124-
// CHECK-powerpc64le-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression(
125-
// CHECK-powerpc64le-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET:[0-9]+]],
126-
// CHECK-powerpc64le-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
127-
// CHECK-powerpc64le: call void @llvm.dbg.declare(metadata i8** %[[ALLOCA]],
128-
// CHECK-powerpc64le-SAME: metadata ![[TAU_R:[0-9]+]], metadata !DIExpression(
129-
// CHECK-powerpc64le-SAME: DW_OP_deref, DW_OP_plus_uconst, [[OFFSET]],
130-
// CHECK-powerpc64le-SAME: DW_OP_plus_uconst, {{[0-9]+}}))
131-
// CHECK-powerpc64le: store i8* %2, i8** %[[ALLOCA]], align
24+
// CHECK: call void @llvm.dbg.declare(metadata i8* %2,
25+
// CHECK-SAME: metadata ![[TAU_R:[0-9]+]], metadata !DIExpression(
26+
// CHECK-SAME: DW_OP_plus_uconst, [[OFFSET:[0-9]+]],
27+
// CHECK-SAME: DW_OP_plus_uconst, {{[0-9]+}}))
28+
// CHECK: call void @llvm.dbg.declare(metadata i8* %2,
29+
// CHECK-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression(
30+
// CHECK-SAME: DW_OP_plus_uconst, [[OFFSET]],
31+
// CHECK-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
13232

13333
use(msg)
13434
}
@@ -138,8 +38,8 @@ func withGenericArg<T>(_ msg: T) async {
13838
await withGenericArg("hello (asynchronously)")
13939
}
14040
}
141-
// CHECK: ![[TAU]] = !DILocalVariable(name: "$\CF\84_0_0",
14241
// CHECK: ![[MSG]] = !DILocalVariable(name: "msg", arg: 1,
143-
// CHECK: ![[MSG_R]] = !DILocalVariable(name: "msg", arg: 1,
42+
// CHECK: ![[TAU]] = !DILocalVariable(name: "$\CF\84_0_0",
14443
// CHECK: ![[TAU_R]] = !DILocalVariable(name: "$\CF\84_0_0",
44+
// CHECK: ![[MSG_R]] = !DILocalVariable(name: "msg", arg: 1,
14545

test/DebugInfo/async-direct-arg.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %target-swift-frontend %s -emit-ir -g -o - \
2+
// RUN: -module-name a -enable-experimental-concurrency \
3+
// RUN: -parse-as-library | %FileCheck %s --check-prefix=CHECK \
4+
// RUN: --check-prefix=CHECK-%target-cpu
5+
// REQUIRES: concurrency
6+
7+
// Test that x is described as a direct dbg.declare of the incoming function
8+
// argument.
9+
10+
// CHECK-LABEL: define {{.*}} void @"$s1a3fibyS2iYF.resume.0"
11+
// CHECK: call void @llvm.dbg.declare(metadata {{.*}}%2, metadata ![[X0:[0-9]+]], {{.*}}!DIExpression(DW_OP
12+
// CHECK-LABEL: define {{.*}} void @"$s1a3fibyS2iYF.resume.1"
13+
// FIXME: call void @llvm.dbg.declare(metadata {{.*}}%2, metadata ![[X1:[0-9]+]], {{.*}}!DIExpression(DW_OP
14+
15+
// CHECK: ![[X0]] = !DILocalVariable(name: "x"
16+
// FIXME: ![[X1]] = !DILocalVariable(name: "x"
17+
func fib(_ x: Int) async -> Int {
18+
if x <= 1 { return 1 }
19+
let a = await fib(x - 1)
20+
let b = await fib(x - 2)
21+
return a + b
22+
}
23+
24+
@main struct Main {
25+
static func main() async {
26+
await fib(4)
27+
}
28+
}

0 commit comments

Comments
 (0)