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
This commit is contained in:
Adrian Prantl
2021-08-13 14:31:38 -07:00
parent ec913af429
commit cbb89c78de
4 changed files with 12 additions and 16 deletions

View File

@@ -952,9 +952,6 @@ public:
if (ValueVariables.insert(shadow).second) if (ValueVariables.insert(shadow).second)
ValueDomPoints.push_back({shadow, getActiveDominancePoint()}); ValueDomPoints.push_back({shadow, getActiveDominancePoint()});
} }
auto inst = cast<llvm::Instruction>(shadow);
llvm::IRBuilder<> builder(inst->getNextNode());
shadow = builder.CreateLoad(shadow);
} }
return shadow; return shadow;

View File

@@ -10,17 +10,15 @@ func withGenericArg<T>(_ msg: T) async {
// This odd debug info is part of a contract with CoroSplit/CoroFrame to fix // This odd debug info is part of a contract with CoroSplit/CoroFrame to fix
// this up after coroutine splitting. // this up after coroutine splitting.
// CHECK-LABEL: {{^define .*}} @"$s1M14withGenericArgyyxYalF"(%swift.context* swiftasync %0 // CHECK-LABEL: {{^define .*}} @"$s1M14withGenericArgyyxYalF"(%swift.context* swiftasync %0
// CHECK: call void @llvm.dbg.declare(metadata %swift.context* %0, // CHECK: call void @llvm.dbg.declare(metadata %swift.type** %
// CHECK-SAME: metadata ![[MSG:[0-9]+]], metadata !DIExpression( // CHECK-SAME: metadata ![[TAU:[0-9]+]], metadata !DIExpression()
// CHECK-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref)) // CHECK: call void @llvm.dbg.declare(metadata %swift.opaque** %
// CHECK: call void @llvm.dbg.declare(metadata %swift.context* %0, // CHECK-SAME: metadata ![[MSG:[0-9]+]], metadata !DIExpression(DW_OP_deref))
// CHECK-SAME: metadata ![[TAU:[0-9]+]], metadata !DIExpression(
// CHECK-SAME: DW_OP_plus_uconst, {{[0-9]+}}))
await forceSplit() await forceSplit()
// CHECK-LABEL: {{^define .*}} @"$s1M14withGenericArgyyxYalFTQ0_"(i8* swiftasync %0) // CHECK-LABEL: {{^define .*}} @"$s1M14withGenericArgyyxYalFTQ0_"(i8* swiftasync %0)
// CHECK: call void @llvm.dbg.declare(metadata i8* %0, // CHECK: call void @llvm.dbg.declare(metadata i8* %0,
// CHECK-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression(DW_OP_deref, // CHECK-SAME: metadata ![[MSG_R:[0-9]+]], metadata !DIExpression(
// CHECK-SAME: DW_OP_plus_uconst, [[OFFSET:[0-9]+]], // CHECK-SAME: DW_OP_plus_uconst, [[OFFSET:[0-9]+]],
// CHECK-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref)) // CHECK-SAME: DW_OP_plus_uconst, {{[0-9]+}}, DW_OP_deref))
// CHECK: call void @llvm.dbg.declare(metadata i8* %0, // CHECK: call void @llvm.dbg.declare(metadata i8* %0,
@@ -35,7 +33,8 @@ func withGenericArg<T>(_ msg: T) async {
await withGenericArg("hello (asynchronously)") await withGenericArg("hello (asynchronously)")
} }
} }
// CHECK: ![[MSG]] = !DILocalVariable(name: "msg", arg: 1,
// CHECK: ![[TAU]] = !DILocalVariable(name: "$\CF\84_0_0", // CHECK: ![[TAU]] = !DILocalVariable(name: "$\CF\84_0_0",
// CHECK: ![[MSG]] = !DILocalVariable(name: "msg", arg: 1,
// CHECK: ![[MSG_R]] = !DILocalVariable(name: "msg", arg: 1, // CHECK: ![[MSG_R]] = !DILocalVariable(name: "msg", arg: 1,
// CHECK: ![[TAU_R]] = !DILocalVariable(name: "$\CF\84_0_0", // CHECK: ![[TAU_R]] = !DILocalVariable(name: "$\CF\84_0_0",

View File

@@ -11,7 +11,7 @@ public func getVegetables() async -> [String] {
public func chopVegetables() async throws -> [String] { public func chopVegetables() async throws -> [String] {
let veggies = await getVegetables() let veggies = await getVegetables()
// CHECK-NOT: {{^define }} // CHECK-NOT: {{^define }}
// CHECK: call void @llvm.dbg.declare(metadata i8* %0, metadata ![[V:[0-9]+]], metadata !DIExpression(DW_OP_deref // CHECK: call void @llvm.dbg.declare(metadata i8* %0, metadata ![[V:[0-9]+]], metadata !DIExpression(
// CHECK: ![[V]] = !DILocalVariable(name: "veggies" // CHECK: ![[V]] = !DILocalVariable(name: "veggies"
return veggies.map { "chopped \($0)" } return veggies.map { "chopped \($0)" }
} }

View File

@@ -8,16 +8,16 @@
// CHECK-LABEL: define {{.*}} void @"$s1a4fiboyS2iYaFTQ0_" // CHECK-LABEL: define {{.*}} void @"$s1a4fiboyS2iYaFTQ0_"
// CHECK-NEXT: entryresume.0: // CHECK-NEXT: entryresume.0:
// CHECK-NEXT: call void @llvm.dbg.declare(metadata {{.*}}%0, metadata ![[RHS:[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 ![[R:[0-9]+]], {{.*}}!DIExpression(DW_OP // 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 ![[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-NOT: {{ ret }}
// CHECK: call void asm sideeffect "" // CHECK: call void asm sideeffect ""
// CHECK: ![[RHS]] = !DILocalVariable(name: "rhs"
// CHECK: ![[LHS]] = !DILocalVariable(name: "lhs"
// CHECK: ![[R]] = !DILocalVariable(name: "retval" // CHECK: ![[R]] = !DILocalVariable(name: "retval"
// CHECK: ![[N]] = !DILocalVariable(name: "n" // CHECK: ![[N]] = !DILocalVariable(name: "n"
// CHECK: ![[LHS]] = !DILocalVariable(name: "lhs"
// CHECK: ![[RHS]] = !DILocalVariable(name: "rhs"
public func fibo(_ n: Int) async -> Int { public func fibo(_ n: Int) async -> Int {
var retval = n var retval = n
if retval < 2 { return 1 } if retval < 2 { return 1 }