Skip to content

Commit bd79ba2

Browse files
Merge pull request #15694 from adrian-prantl/39023374
Represent indirect function arguments in the DWARF expression instead…
2 parents 187ab0b + 6632a20 commit bd79ba2

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

lib/IRGen/DebugTypeInfo.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,9 @@ class DebugTypeInfo {
9696
/// LValues, inout args, and Archetypes are implicitly indirect by
9797
/// virtue of their DWARF type.
9898
//
99-
// FIXME: Should this check if the lowered SILType is address only
100-
// instead? Otherwise optionals of archetypes etc will still have
101-
// 'isImplicitlyIndirect()' return false.
99+
// FIXME: There exists an inverse workaround in LLDB. Both should be removed.
102100
bool isImplicitlyIndirect() const {
103-
return Type->hasLValueType() || isArchetype() || Type->is<InOutType>();
101+
return isArchetype();
104102
}
105103

106104
bool isNull() const { return Type == nullptr; }

lib/IRGen/IRGenSIL.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3693,8 +3693,6 @@ void IRGenSILFunction::visitDebugValueAddrInst(DebugValueAddrInst *i) {
36933693
auto Addr = getLoweredAddress(SILVal).getAddress();
36943694
SILType SILTy = SILVal->getType();
36953695
auto RealType = SILTy.getSwiftRValueType();
3696-
if (SILTy.isAddress() && !IsLoadablyByAddress)
3697-
RealType = CanInOutType::get(RealType);
36983696
// Unwrap implicitly indirect types and types that are passed by
36993697
// reference only at the SIL level and below.
37003698
//
@@ -4178,8 +4176,6 @@ void IRGenSILFunction::visitAllocBoxInst(swift::AllocBoxInst *i) {
41784176
&& "box for a local variable should only have one field");
41794177
auto SILTy = i->getBoxType()->getFieldType(IGM.getSILModule(), 0);
41804178
auto RealType = SILTy.getSwiftRValueType();
4181-
if (SILTy.isAddress())
4182-
RealType = CanInOutType::get(RealType);
41834179
auto DbgTy = DebugTypeInfo::getLocalVariable(
41844180
CurSILFn->getDeclContext(), CurSILFn->getGenericEnvironment(), Decl,
41854181
RealType, type, /*Unwrap=*/false);

test/DebugInfo/byref-capture.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ func makeIncrementor(_ inc : Int64) -> () -> Int64
77
func inner() -> Int64 {
88
// CHECK: call void @llvm.dbg.declare(metadata %Ts5Int64V**
99
// CHECK-SAME: metadata ![[SUM_CAPTURE:[0-9]+]],
10-
// CHECK-SAME: metadata !DIExpression())
11-
// CHECK: ![[INOUTTY:[0-9]+]] = !DICompositeType({{.*}}identifier: "$Ss5Int64VzD"
12-
// ^ inout type.
10+
// CHECK-SAME: metadata !DIExpression(DW_OP_deref))
11+
// CHECK: ![[INOUTTY:[0-9]+]] = !DICompositeType({{.*}}identifier: "$Ss5Int64VD"
1312
// CHECK: ![[SUM_CAPTURE]] = !DILocalVariable(name: "sum", arg: 1,
14-
// CHECK-SAME: line: [[@LINE-9]], type: ![[INOUTTY]]
13+
// CHECK-SAME: line: [[@LINE-8]], type: ![[INOUTTY]]
1514
sum += inc
1615
return sum
1716
}

test/DebugInfo/inout.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ typealias MyFloat = Float
1616
// Closure with promoted capture.
1717
// PROMO-CHECK: define {{.*}}@"$S5inout13modifyFooHeapyys5Int64Vz_SftFADyXEfU_"
1818
// PROMO-CHECK: call void @llvm.dbg.declare(metadata %Ts5Int64V** %
19-
// PROMO-CHECK-SAME: metadata ![[A1:[0-9]+]], metadata !DIExpression())
19+
// PROMO-CHECK-SAME: metadata ![[A1:[0-9]+]], metadata !DIExpression(DW_OP_deref))
2020

2121
// PROMO-CHECK-DAG: ![[INT:.*]] = !DICompositeType({{.*}}identifier: "$Ss5Int64VD"
22-
// PROMO-CHECK-DAG: ![[INT:.*]] = !DICompositeType({{.*}}identifier: "$Ss5Int64VzD"
2322
// PROMO-CHECK: ![[A1]] = !DILocalVariable(name: "a", arg: 1
2423
// PROMO-CHECK-SAME: type: ![[INT]]
2524
func modifyFooHeap(_ a: inout Int64,
2625
// CHECK-DAG: ![[A]] = !DILocalVariable(name: "a", arg: 1{{.*}} line: [[@LINE-1]],{{.*}} type: ![[RINT:[0-9]+]]
27-
// CHECK-DAG: ![[RINT]] = !DICompositeType({{.*}}identifier: "$Ss5Int64VzD"
26+
// CHECK-DAG: ![[RINT]] = !DICompositeType({{.*}}identifier: "$Ss5Int64VD"
2827
_ b: MyFloat)
2928
{
3029
let b = b
@@ -39,11 +38,11 @@ func modifyFooHeap(_ a: inout Int64,
3938
// Inout reference type.
4039
// FOO-CHECK: define {{.*}}@"$S5inout9modifyFooyys5Int64Vz_SftF"
4140
// FOO-CHECK: call void @llvm.dbg.declare(metadata %Ts5Int64V** %
42-
// FOO-CHECK-SAME: metadata ![[U:[0-9]+]], metadata !DIExpression())
41+
// FOO-CHECK-SAME: metadata ![[U:[0-9]+]], metadata !DIExpression(DW_OP_deref))
4342
func modifyFoo(_ u: inout Int64,
4443
// FOO-CHECK-DAG: !DILocalVariable(name: "v", arg: 2{{.*}} line: [[@LINE+3]],{{.*}} type: ![[MYFLOAT:[0-9]+]]
4544
// FOO-CHECK-DAG: [[U]] = !DILocalVariable(name: "u", arg: 1{{.*}} line: [[@LINE-2]],{{.*}} type: ![[RINT:[0-9]+]]
46-
// FOO-CHECK-DAG: ![[RINT]] = !DICompositeType({{.*}}identifier: "$Ss5Int64VzD"
45+
// FOO-CHECK-DAG: ![[RINT]] = !DICompositeType({{.*}}identifier: "$Ss5Int64VD"
4746
_ v: MyFloat)
4847
// FOO-CHECK-DAG: ![[MYFLOAT]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$S5inout7MyFloataD",{{.*}} baseType: ![[FLOAT:[0-9]+]]
4948
// FOO-CHECK-DAG: ![[FLOAT]] = !DICompositeType({{.*}}identifier: "$SSfD"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
2+
public class ClosureMaker {
3+
var a : Int
4+
5+
init (a : Int) { self.a = a }
6+
7+
public func getClosure() -> (() -> Int) {
8+
return { [weak self] () -> Int in
9+
if let _self = self {
10+
return _self.a
11+
} else {
12+
return 0
13+
}
14+
}
15+
}
16+
}
17+
18+
// CHECK: define {{.*}} @"$S4main12ClosureMakerC03getB0SiycyFSiycfU_"
19+
// CHECK: call void @llvm.dbg.declare(metadata %swift.weak** %{{.*}} !DIExpression(DW_OP_deref)),

0 commit comments

Comments
 (0)