Skip to content

Commit 361beff

Browse files
committed
Emit pointer-sized structs only when -gdwarf-types is specified.
rdar://problem/25498103
1 parent 0847225 commit 361beff

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,11 +1212,18 @@ uint64_t IRGenDebugInfo::getSizeOfBasicType(DebugTypeInfo DbgTy) {
12121212
llvm::DIType *IRGenDebugInfo::createPointerSizedStruct(
12131213
llvm::DIScope *Scope, StringRef Name, llvm::DIFile *File, unsigned Line,
12141214
unsigned Flags, StringRef MangledName) {
1215-
auto FwdDecl = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type,
1216-
Name, Scope, File, Line,
1217-
llvm::dwarf::DW_LANG_Swift, 0, 0);
1218-
return createPointerSizedStruct(Scope, Name, FwdDecl, File, Line, Flags,
1219-
MangledName);
1215+
if (Opts.DebugInfoKind > IRGenDebugInfoKind::ASTTypes) {
1216+
auto FwdDecl = DBuilder.createForwardDecl(
1217+
llvm::dwarf::DW_TAG_structure_type, Name, Scope, File, Line,
1218+
llvm::dwarf::DW_LANG_Swift, 0, 0);
1219+
return createPointerSizedStruct(Scope, Name, FwdDecl, File, Line, Flags,
1220+
MangledName);
1221+
} else {
1222+
unsigned SizeInBits = CI.getTargetInfo().getPointerWidth(0);
1223+
unsigned AlignInBits = CI.getTargetInfo().getPointerAlign(0);
1224+
return createOpaqueStruct(Scope, Name, File, Line, SizeInBits, AlignInBits,
1225+
Flags, MangledName);
1226+
}
12201227
}
12211228

12221229
llvm::DIType *IRGenDebugInfo::createPointerSizedStruct(
@@ -1557,10 +1564,14 @@ llvm::DIType *IRGenDebugInfo::createType(DebugTypeInfo DbgTy,
15571564
// DW_TAG_reference_type types, but LLDB can deal better with pointer-sized
15581565
// struct that has the appropriate mangled name.
15591566
auto ObjectTy = BaseTy->castTo<InOutType>()->getObjectType();
1560-
auto DT = getOrCreateDesugaredType(ObjectTy, DbgTy);
1561-
return createPointerSizedStruct(Scope, MangledName, DT, File, 0, Flags,
1562-
BaseTy->isUnspecializedGeneric()
1563-
? StringRef() : MangledName);
1567+
if (Opts.DebugInfoKind > IRGenDebugInfoKind::ASTTypes) {
1568+
auto DT = getOrCreateDesugaredType(ObjectTy, DbgTy);
1569+
return createPointerSizedStruct(
1570+
Scope, MangledName, DT, File, 0, Flags,
1571+
BaseTy->isUnspecializedGeneric() ? StringRef() : MangledName);
1572+
} else
1573+
return createOpaqueStruct(Scope, MangledName, File, 0, SizeInBits,
1574+
AlignInBits, Flags, MangledName);
15641575
}
15651576

15661577
case TypeKind::Archetype: {

test/DebugInfo/enum.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ enum Rose<A> {
7070
func foo<T>(_ x : Rose<T>) -> Rose<T> { return x }
7171

7272
// CHECK: !DICompositeType({{.*}}name: "Tuple", {{.*}}elements: ![[ELTS:[0-9]+]],
73-
// CHECK-SAME: {{.*}}identifier: "_TtGO4enum5Tuplex_")
73+
// CHECK-SAME: {{.*}}identifier: "_TtGO4enum5TupleQq_FS_3barurFGS0_x_GS0_x__")
74+
// DWARF: !DICompositeType({{.*}}name: "Tuple", {{.*}}elements: ![[ELTS:[0-9]+]],
75+
// DWARF-SAME: {{.*}}identifier: "_TtGO4enum5Tuplex_")
7476
public enum Tuple<P> {
7577
// DWARF: !DICompositeType({{.*}}name: "Tuple",{{.*}}identifier: "_TtGO4enum5TupleQq_S0__")
7678
case C(P, () -> Tuple)

test/DebugInfo/protocolarg.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %target-swift-frontend %s -emit-ir -g -o - | FileCheck %s
22

33
func markUsed<T>(_ t: T) {}
4+
func use<T>(_ t: inout T) {}
45

56
public protocol IGiveOutInts {
67
func callMe() -> Int64
@@ -13,15 +14,16 @@ public protocol IGiveOutInts {
1314
// CHECK-SAME: metadata ![[ARG:.*]], metadata ![[DEREF:.*]])
1415

1516
// CHECK: ![[EMPTY]] = !DIExpression()
16-
// FIXME: Should be DW_TAG_interface_type
17-
// CHECK: ![[PT:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "IGiveOutInts"
1817

1918
public func printSomeNumbers(_ gen: IGiveOutInts) {
2019
var gen = gen
2120
// CHECK: ![[VAR]] = !DILocalVariable(name: "gen", {{.*}} line: [[@LINE-1]]
21+
// FIXME: Should be DW_TAG_interface_type
22+
// CHECK: ![[PT:.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "IGiveOutInts"
2223
// CHECK: ![[ARG]] = !DILocalVariable(name: "gen", arg: 1,
23-
// CHECK-SAME: line: [[@LINE-4]], type: ![[PT]]
24+
// CHECK-SAME: line: [[@LINE-6]], type: ![[PT]]
2425
// CHECK: ![[DEREF]] = !DIExpression(DW_OP_deref)
2526
markUsed(gen.callMe())
27+
use(&gen)
2628
}
2729

0 commit comments

Comments
 (0)