Skip to content

Commit

Permalink
Merge pull request #66479 from adrian-prantl/110329894
Browse files Browse the repository at this point in the history
Avoid emitting variable debug info for closure captures.  … @adrian-prantl
  • Loading branch information
adrian-prantl committed Jun 9, 2023
2 parents 9991468 + 3a97766 commit 7092e50
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/SILGen/RValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ SILValue RValue::forwardAsSingleStorageValue(SILGenFunction &SGF,
return SGF.emitConversionFromSemanticValue(l, result, storageType);
}

void RValue::forwardInto(SILGenFunction &SGF, SILLocation loc,
void RValue::forwardInto(SILGenFunction &SGF, SILLocation loc,
Initialization *I) && {
assert(isComplete() && "rvalue is not complete");
assert(isPlusOneOrTrivial(SGF) && "Can not forward borrowed RValues");
Expand Down
6 changes: 4 additions & 2 deletions lib/SILGen/SILGenDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1808,8 +1808,10 @@ void SILGenFunction::emitStmtCondition(StmtCondition Cond, JumpDest FalseDest,

InitializationPtr SILGenFunction::emitPatternBindingInitialization(
Pattern *P, JumpDest failureDest, bool generateDebugInfo) {
return InitializationForPattern(*this, failureDest, generateDebugInfo)
.visit(P);
auto init =
InitializationForPattern(*this, failureDest, generateDebugInfo).visit(P);
init->setEmitDebugValueOnInit(generateDebugInfo);
return init;
}

/// Enter a cleanup to deallocate the given location.
Expand Down
26 changes: 26 additions & 0 deletions test/DebugInfo/captures.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// RUN: %target-swift-frontend %s -parse-as-library -module-name a -emit-sil -g -o - | %FileCheck %s
struct S {}
public class UIView {}
public protocol View {}
public final class Signal<Value> {
public func map<U>(_ transform: @escaping (Value) -> U) -> Signal<U> {
return Signal<U>()
}
}
public final class C<V: View, V1: View>: UIView {
private let t1: C<V, V1>? = nil
private let t2: C<V1, V>? = nil
func foo() -> Signal<(S, UIView)> {
// CHECK: sil {{.*}}s1a1CC3foo
// CHECK: debug_value {{.*}} name "self"
// CHECK-NOT: debug_value {{.*}} name "view"
// CHECK: return %
return (
Signal<S>()
.map { [view = t1!] in ($0, view) },
Signal<S>()
.map { [view = t2!] in ($0, view) }
).0
}
}

0 comments on commit 7092e50

Please sign in to comment.