Skip to content

Commit ec890e8

Browse files
Merge pull request swiftlang#79068 from adrian-prantl/revert
Revert "[Debug info] Emit bound generic class type parameters when em…
2 parents d585d16 + 45d4648 commit ec890e8

File tree

4 files changed

+36
-34
lines changed

4 files changed

+36
-34
lines changed

lib/IRGen/IRGenDebugInfo.cpp

+22-16
Original file line numberDiff line numberDiff line change
@@ -1283,12 +1283,16 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
12831283
DBuilder.createInheritance(UnsubstitutedType, SuperClassDITy, 0, 0,
12841284
llvm::DINode::FlagZero);
12851285
}
1286+
1287+
auto *OpaqueType = createPointerSizedStruct(
1288+
Scope, Decl ? Decl->getNameStr() : MangledName, File, 0, Flags,
1289+
MangledName, UnsubstitutedType);
1290+
return OpaqueType;
12861291
}
12871292

1288-
auto *OpaqueType =
1289-
createOpaqueStruct(Scope, Decl ? Decl->getNameStr() : "", File, Line,
1290-
SizeInBits, AlignInBits, Flags, MangledName,
1291-
collectGenericParams(Type), UnsubstitutedType);
1293+
auto *OpaqueType = createOpaqueStruct(
1294+
Scope, "", File, Line, SizeInBits, AlignInBits, Flags, MangledName,
1295+
collectGenericParams(Type), UnsubstitutedType);
12921296
DBuilder.replaceTemporary(std::move(FwdDecl), OpaqueType);
12931297
return OpaqueType;
12941298
}
@@ -1975,9 +1979,18 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
19751979
auto L = getFileAndLocation(Decl);
19761980
unsigned FwdDeclLine = 0;
19771981

1978-
return createSpecializedStructOrClassType(ClassTy, Decl, Scope, L.File,
1979-
L.Line, SizeInBits, AlignInBits,
1980-
Flags, MangledName);
1982+
if (Opts.DebugInfoLevel > IRGenDebugInfoLevel::ASTTypes)
1983+
return createSpecializedStructOrClassType(
1984+
ClassTy, Decl, Scope, L.File, L.Line, SizeInBits, AlignInBits,
1985+
Flags, MangledName);
1986+
1987+
// TODO: We may want to peek at Decl->isObjC() and set this
1988+
// attribute accordingly.
1989+
assert(SizeInBits ==
1990+
CI.getTargetInfo().getPointerWidth(clang::LangAS::Default));
1991+
return createPointerSizedStruct(
1992+
Scope, Decl ? Decl->getNameStr() : MangledName, L.File, FwdDeclLine,
1993+
Flags, MangledName, SpecificationOf);
19811994
}
19821995

19831996
case TypeKind::Pack:
@@ -2161,14 +2174,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
21612174
AliasedTy, DbgTy.getAlignment(), DbgTy.hasDefaultAlignment(),
21622175
/* IsMetadataType = */ false, DbgTy.isFixedBuffer(),
21632176
DbgTy.getNumExtraInhabitants());
2164-
auto *TypeDef = DBuilder.createTypedef(getOrCreateType(AliasedDbgTy),
2165-
MangledName, L.File, 0, Scope);
2166-
// Bound generic types don't reference their type parameters in ASTTypes
2167-
// mode, so we need to artificially keep typealiases alive, since they can
2168-
// appear in reflection metadata.
2169-
if (Opts.DebugInfoLevel < IRGenDebugInfoLevel::DwarfTypes)
2170-
DBuilder.retainType(TypeDef);
2171-
return TypeDef;
2177+
return DBuilder.createTypedef(getOrCreateType(AliasedDbgTy), MangledName,
2178+
L.File, 0, Scope);
21722179
}
21732180

21742181
case TypeKind::Locatable: {
@@ -2504,7 +2511,6 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
25042511
// winning over a full definition.
25052512
auto *FwdDecl = DBuilder.createReplaceableCompositeType(
25062513
llvm::dwarf::DW_TAG_structure_type, MangledName, Scope, 0, 0,
2507-
25082514
llvm::dwarf::DW_LANG_Swift);
25092515
FwdDeclTypes.emplace_back(
25102516
std::piecewise_construct, std::make_tuple(MangledName),

test/ClangImporter/objc_ir.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,14 @@ func testBlocksWithGenerics(hba: HasBlockArray) -> Any {
351351

352352
// CHECK: attributes [[NOUNWIND]] = { nounwind memory(read) }
353353

354-
// CHECK-DAG: ![[SWIFT_NAME_ALIAS_VAR]] = !DILocalVariable(name: "obj", arg: 1, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 328, type: ![[LET_SWIFT_NAME_ALIAS_TYPE:[0-9]+]])
355-
// CHECK-DAG: ![[LET_SWIFT_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[SWIFT_NAME_ALIAS_TYPE:[0-9]+]])
356-
// CHECK-DAG: ![[SWIFT_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo14SwiftNameAliasaD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, baseType: !{{[0-9]+}})
354+
// CHECK: ![[SWIFT_NAME_ALIAS_VAR]] = !DILocalVariable(name: "obj", arg: 1, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: ![[SWIFT_NAME_ALIAS_TYPE:[0-9]+]])
355+
// CHECK: ![[LET_SWIFT_NAME_ALIAS_TYPE:[0-9]+]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[SWIFT_NAME_ALIAS_TYPE:[0-9]+]])
356+
// CHECK: ![[SWIFT_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo14SwiftNameAliasaD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, baseType: !{{[0-9]+}})
357357

358-
// CHECK-DAG: ![[SWIFT_GENERIC_NAME_ALIAS_VAR]] = !DILocalVariable(name: "generic_obj", arg: 1, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: ![[LET_SWIFT_GENERIC_NAME_ALIAS_TYPE:[0-9]+]])
359-
// CHECK-DAG: ![[LET_SWIFT_GENERIC_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[SWIFT_GENERIC_NAME_ALIAS_TYPE:[0-9]+]])
360-
// CHECK-DAG: ![[SWIFT_GENERIC_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo21SwiftGenericNameAliasaySo8NSNumberCGD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, baseType: !{{[0-9]+}})
358+
// CHECK: ![[SWIFT_GENERIC_NAME_ALIAS_VAR]] = !DILocalVariable(name: "generic_obj", arg: 1, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: ![[LET_SWIFT_GENERIC_NAME_ALIAS_TYPE:[0-9]+]])
359+
// CHECK: ![[LET_SWIFT_GENERIC_NAME_ALIAS_TYPE:[0-9]+]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[SWIFT_GENERIC_NAME_ALIAS_TYPE:[0-9]+]])
360+
// CHECK: ![[SWIFT_GENERIC_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo21SwiftGenericNameAliasaySo8NSNumberCGD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, baseType: !{{[0-9]+}})
361361

362-
// CHECK-DAG: ![[SWIFT_CONSTR_GENERIC_NAME_ALIAS_VAR]] = !DILocalVariable(name: "constr_generic_obj", arg: 1, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: ![[LET_SWIFT_CONSTR_GENERIC_NAME_ALIAS_TYPE:[0-9]+]])
363-
// CHECK-DAG: ![[LET_SWIFT_CONSTR_GENERIC_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[SWIFT_CONSTR_GENERIC_NAME_ALIAS_TYPE:[0-9]+]])
364-
// CHECK-DAG: ![[SWIFT_CONSTR_GENERIC_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo27SwiftConstrGenericNameAliasaySo8NSNumberCGD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, baseType: !{{[0-9]+}})
362+
// CHECK: ![[SWIFT_CONSTR_GENERIC_NAME_ALIAS_VAR]] = !DILocalVariable(name: "constr_generic_obj", arg: 1, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: ![[LET_SWIFT_CONSTR_GENERIC_NAME_ALIAS_TYPE:[0-9]+]])
363+
// CHECK: ![[LET_SWIFT_CONSTR_GENERIC_NAME_ALIAS_TYPE:[0-9]+]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[SWIFT_CONSTR_GENERIC_NAME_ALIAS_TYPE:[0-9]+]])
364+
// CHECK: ![[SWIFT_CONSTR_GENERIC_NAME_ALIAS_TYPE]] = !DIDerivedType(tag: DW_TAG_typedef, name: "$sSo27SwiftConstrGenericNameAliasaySo8NSNumberCGD", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, baseType: !{{[0-9]+}})

test/DebugInfo/BoundGenericStruct.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public let s = S<Int>(t: 0)
1212
// CHECK: ![[INTPARAM]] = !DITemplateTypeParameter(type: ![[INT:[0-9]+]])
1313
// CHECK: ![[INT]] = !DICompositeType(tag: DW_TAG_structure_type, {{.*}}identifier: "$sSiD"
1414

15+
1516
// DWARF: !DICompositeType(tag: DW_TAG_structure_type,
1617
// DWARF-SAME: templateParams: ![[PARAMS:[0-9]+]]
1718
// DWARF-SAME: identifier: "$s18BoundGenericStruct1SVySiGD"
@@ -39,7 +40,10 @@ public let inner = S2<Double>.Inner(t:4.2)
3940
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "$s18BoundGenericStruct2S2VyxGD",
4041
// CHECK-SAME: flags: DIFlagFwdDecl, runtimeLang: DW_LANG_Swift)
4142

42-
// DWARF: !DICompositeType(tag: DW_TAG_structure_type, name: "Inner", scope: ![[SCOPE1:[0-9]+]],{{.*}} size: 64, {{.*}}, templateParams: ![[PARAMS2:[0-9]+]], identifier: "$s18BoundGenericStruct2S2V5InnerVySd_GD",{{.*}} specification: ![[SPECIFICATION:[0-9]+]]
43+
// DWARF: !DICompositeType(tag: DW_TAG_structure_type, scope: ![[SCOPE1:[0-9]+]],
44+
// DWARF-SAME: size: 64, {{.*}}, templateParams: ![[PARAMS2:[0-9]+]], identifier: "$s18BoundGenericStruct2S2V5InnerVySd_GD"
45+
// DWARF-SAME: specification: ![[SPECIFICATION:[0-9]+]]
46+
4347
// DWARF: ![[SCOPE1]] = !DICompositeType(tag: DW_TAG_structure_type, name: "$s18BoundGenericStruct2S2VyxGD",
4448

4549
// DWARF: ![[PARAMS2]] = !{![[PARAMS3:[0-9]+]]}

test/DebugInfo/typealias_indirect.swift

-8
This file was deleted.

0 commit comments

Comments
 (0)