Skip to content

Commit 94c2875

Browse files
authored
Merge pull request #2777 from swiftwasm/main
[pull] swiftwasm from main
2 parents 4843d91 + e854ac4 commit 94c2875

File tree

4 files changed

+116
-126
lines changed

4 files changed

+116
-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");
@@ -5323,7 +5384,7 @@ static void emitUncheckedValueBitCast(IRGenSILFunction &IGF,
53235384
in.transferInto(out, in.size());
53245385
return;
53255386
}
5326-
5387+
53275388
// TODO: We could do bitcasts entirely in the value domain in some cases, but
53285389
// for simplicity, let's just always go through the stack for now.
53295390

@@ -5428,7 +5489,7 @@ static void trivialRefConversion(IRGenSILFunction &IGF,
54285489
}
54295490
out.add(value);
54305491
}
5431-
5492+
54325493
IGF.setLoweredExplosion(result, out);
54335494
}
54345495

@@ -5628,7 +5689,7 @@ void IRGenSILFunction::visitBridgeObjectToRefInst(
56285689
// If it's not a tagged pointer, mask off the spare bits.
56295690
Builder.emitBlock(notTagged);
56305691
}
5631-
5692+
56325693
// Mask off the spare bits (if they exist).
56335694
auto &spareBits = IGM.getHeapObjectSpareBits();
56345695
llvm::Value *result;
@@ -5716,7 +5777,7 @@ void IRGenSILFunction::visitCheckedCastBranchInst(
57165777
llvm::ConstantPointerNull::get(cast<llvm::PointerType>(val->getType()));
57175778
castResult.succeeded = Builder.CreateICmpNE(val, nil);
57185779
}
5719-
5780+
57205781
// Branch on the success of the cast.
57215782
// All cast operations currently return null on failure.
57225783

@@ -5784,7 +5845,7 @@ void IRGenSILFunction::visitKeyPathInst(swift::KeyPathInst *I) {
57845845
argsBufSize = llvm::ConstantInt::get(IGM.SizeTy, 0);
57855846
argsBufAlign = llvm::ConstantInt::get(IGM.SizeTy, 0);
57865847
}
5787-
5848+
57885849
SmallVector<llvm::Value *, 4> operandOffsets;
57895850
for (unsigned i : indices(I->getAllOperands())) {
57905851
auto operand = I->getAllOperands()[i].get();

test/DebugInfo/async-args.swift

Lines changed: 18 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,34 @@
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

6+
// REQUIRES: rdar74551043
7+
78
func use<T>(_ t: T) {}
89
func forceSplit() async {
910
}
1011
func withGenericArg<T>(_ msg: T) async {
1112
// This odd debug info is part of a contract with CoroSplit/CoroFrame to fix
1213
// this up after coroutine splitting.
1314
// CHECK-LABEL: {{^define .*}} @"$s1M14withGenericArgyyxYlF"(%swift.task* %0, %swift.executor* %1, %swift.context* swiftasync %2)
14-
// CHECK: call void @llvm.dbg.declare(metadata %swift.context** %[[ALLOCA:[^,]+]],
15-
// CHECK-SAME: metadata ![[TAU:[0-9]+]], metadata !DIExpression(
16-
// CHECK-SAME: DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}))
17-
// CHECK: call void @llvm.dbg.declare(metadata %swift.context** %[[ALLOCA]],
15+
// CHECK: call void @llvm.dbg.declare(metadata %swift.context* %2,
1816
// CHECK-SAME: metadata ![[MSG:[0-9]+]], metadata !DIExpression(
19-
// CHECK-SAME: DW_OP_deref, DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
20-
// 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]+}}))
2121

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

13133
use(msg)
13234
}
@@ -136,8 +38,8 @@ func withGenericArg<T>(_ msg: T) async {
13638
await withGenericArg("hello (asynchronously)")
13739
}
13840
}
139-
// CHECK: ![[TAU]] = !DILocalVariable(name: "$\CF\84_0_0",
14041
// CHECK: ![[MSG]] = !DILocalVariable(name: "msg", arg: 1,
141-
// CHECK: ![[MSG_R]] = !DILocalVariable(name: "msg", arg: 1,
42+
// CHECK: ![[TAU]] = !DILocalVariable(name: "$\CF\84_0_0",
14243
// CHECK: ![[TAU_R]] = !DILocalVariable(name: "$\CF\84_0_0",
44+
// CHECK: ![[MSG_R]] = !DILocalVariable(name: "msg", arg: 1,
14345

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)