Skip to content

Commit 6ffaf4b

Browse files
committed
Don't ask for TypeInfo of IntegerType when generating debug info for generic args
1 parent 61702fb commit 6ffaf4b

File tree

4 files changed

+43
-9
lines changed

4 files changed

+43
-9
lines changed

lib/IRGen/GenType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2375,7 +2375,7 @@ const TypeInfo *TypeConverter::convertType(CanType ty) {
23752375
case TypeKind::SILToken:
23762376
llvm_unreachable("should not be asking for representation of a SILToken");
23772377
case TypeKind::Integer:
2378-
llvm_unreachable("implement me");
2378+
llvm_unreachable("should not be asking for the type info an IntegerType");
23792379
}
23802380
}
23812381
llvm_unreachable("bad type kind");

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,13 +1534,18 @@ createSpecializedStructOrClassType(NominalOrBoundGenericNominalType *Type,
15341534
for (auto Arg : GenericArgs) {
15351535
DebugTypeInfo ParamDebugType;
15361536
if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes &&
1537-
!AsForwardDeclarations)
1538-
// For the DwarfTypes level don't generate just a forward declaration
1539-
// for the generic type parameters.
1540-
ParamDebugType = DebugTypeInfo::getFromTypeInfo(
1541-
Arg, IGM.getTypeInfoForUnlowered(Arg), IGM);
1542-
else
1537+
!AsForwardDeclarations) {
1538+
if (Arg->is<IntegerType>()) {
1539+
ParamDebugType = DebugTypeInfo(Arg);
1540+
} else {
1541+
// For the DwarfTypes level don't generate just a forward declaration
1542+
// for the generic type parameters.
1543+
ParamDebugType = DebugTypeInfo::getFromTypeInfo(
1544+
Arg, IGM.getTypeInfoForUnlowered(Arg), IGM);
1545+
}
1546+
} else {
15431547
ParamDebugType = DebugTypeInfo::getForwardDecl(Arg);
1548+
}
15441549

15451550
TemplateParams.push_back(DBuilder.createTemplateTypeParameter(
15461551
TheCU, "", getOrCreateType(ParamDebugType), false));
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %target-swift-frontend %s -target %target-cpu-apple-macos14 -emit-ir -g -enable-experimental-feature ValueGenerics -enable-experimental-feature Embedded -wmo -disable-availability-checking -o - | %FileCheck %s
2+
3+
// REQUIR123ES: swift_feature_ValueGenerics
4+
5+
// CHECK-DAG: !DICompositeType({{.*}}templateParams: ![[VECTOR_PARAMS:.*]], {{.*}}identifier: "$ss6VectorVy$0_4main8MySpriteVGD"
6+
// CHECK-DAG: ![[VECTOR_PARAMS]] = !{![[COUNT_PARAM:.*]], ![[ELEMENT_PARAM:.*]]}
7+
// CHECK-DAG: ![[COUNT_PARAM]] = !DITemplateTypeParameter(type: ![[COUNT_TYPE:.*]])
8+
// CHECK-DAG: ![[COUNT_TYPE]] = !DICompositeType({{.*}}name: "$s$0_D"
9+
// CHECK-DAG: ![[ELEMENT_PARAM]] = !DITemplateTypeParameter(type: ![[ELEMENT_TYPE:.*]])
10+
// CHECK-DAG: ![[ELEMENT_TYPE]] = !DICompositeType({{.*}}name: "MySprite", {{.*}}identifier: "$s4main8MySpriteVD"
11+
struct MySprites {
12+
var bricks: Vector<1,MySprite>
13+
}
14+
15+
struct MySprite {
16+
var x = 42
17+
}
18+
19+
nonisolated(unsafe)
20+
var sprites: MySprites? = nil
21+
public func foo() {
22+
let bricks: Vector<1,MySprite> = [MySprite()]
23+
sprites = .init(bricks: bricks)
24+
}

test/DebugInfo/value-generics.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend %s -emit-ir -g -enable-builtin-module -enable-experimental-feature ValueGenerics -disable-experimental-parser-round-trip -disable-availability-checking -o - | %FileCheck %s
1+
// RUN: %target-swift-frontend %s -emit-ir -g -enable-builtin-module -enable-experimental-feature ValueGenerics -disable-availability-checking -o - | %FileCheck %s
22

33
// REQUIRES: swift_feature_ValueGenerics
44

@@ -19,5 +19,10 @@ func genericV<let N: Int, Element>(_: Vector<N, Element>) {}
1919
// CHECK-DAG: !DICompositeType({{.*}}name: "Builtin.FixedArray", {{.*}}identifier: "$s$3_SiBVD"
2020
func concreteBA(_: Builtin.FixedArray<4, Int>) {}
2121

22-
// CHECK-DAG: !DICompositeType({{.*}}name: "$s4main6VectorVy$1_SiGD"
22+
// CHECK-DAG: !DICompositeType({{.*}}name: "$s4main6VectorVy$1_SiGD", {{.*}}templateParams: ![[VECTOR_PARAMS:.*]])
23+
// CHECK-DAG: ![[VECTOR_PARAMS]] = !{![[COUNT_PARAM:.*]], ![[ELEMENT_PARAM:.*]]}
24+
// CHECK-DAG: ![[COUNT_PARAM]] = !DITemplateTypeParameter(type: ![[COUNT_TYPE:.*]])
25+
// CHECK-DAG: ![[COUNT_TYPE]] = !DICompositeType({{.*}}name: "$s$1_D"
26+
// CHECK-DAG: ![[ELEMENT_PARAM]] = !DITemplateTypeParameter(type: ![[ELEMENT_TYPE:.*]])
27+
// CHECK-DAG: ![[ELEMENT_TYPE]] = !DICompositeType({{.*}}name: "$sSiD"
2328
func concreteV(_: Vector<2, Int>) {}

0 commit comments

Comments
 (0)