Files
swift-mirror/test/DebugInfo/async-lifetime-extension.swift
Adrian Prantl cbb89c78de Remove an extra load that was generated for coro shadow copies.
emitShadowCopyIfNeeded has some extra code that was added when function
arguments were moved out of the async context to ensure that they are being
lifetime-extended, and there is also code that generates an incorrect load from
the shadow copy. However, emitShadowCopyIfNeeded is supposed return either an
alloca or the value, and IRGenDebugInfo knows to describe the value in the
alloca already. The load is counterproductive it's only valid until whatever
register it ends up in is clobbered, whereas the alloca is valid throughout the
function.

This patch removes the load and updates the tests accordingly.

rdar://81805727
2021-08-13 14:39:07 -07:00

29 lines
1.3 KiB
Swift

// RUN: %target-swift-frontend %s -emit-ir -g -o - \
// RUN: -module-name a -disable-availability-checking \
// RUN: | %FileCheck %s --check-prefix=CHECK
// REQUIRES: concurrency
// Test that lifetime extension preserves a dbg.declare for "n" in the resume
// funclet.
// CHECK-LABEL: define {{.*}} void @"$s1a4fiboyS2iYaFTQ0_"
// CHECK-NEXT: entryresume.0:
// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[R:[0-9]+]], {{.*}}!DIExpression(DW_OP
// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[N:[0-9]+]], {{.*}}!DIExpression(DW_OP
// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[LHS:[0-9]+]], {{.*}}!DIExpression(DW_OP
// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[RHS:[0-9]+]], {{.*}}!DIExpression(DW_OP
// CHECK-NOT: {{ ret }}
// CHECK: call void asm sideeffect ""
// CHECK: ![[R]] = !DILocalVariable(name: "retval"
// CHECK: ![[N]] = !DILocalVariable(name: "n"
// CHECK: ![[LHS]] = !DILocalVariable(name: "lhs"
// CHECK: ![[RHS]] = !DILocalVariable(name: "rhs"
public func fibo(_ n: Int) async -> Int {
var retval = n
if retval < 2 { return 1 }
retval = retval - 1
let lhs = await fibo(retval - 1)
let rhs = await fibo(retval - 2)
return lhs + rhs + retval
}