Skip to content

Commit c451db4

Browse files
committed
Debug Info: Only bind the archetypes referenced by variable types early
at -Onone. Thanks to rjmccall for the feedback!
1 parent ca1c7f1 commit c451db4

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,14 @@ class IRGenSILFunction :
652652
StringRef Name,
653653
unsigned ArgNo = 0,
654654
IndirectionKind Indirection = DirectValue) {
655-
// Eagerly load the type metadata at -Onone.
656-
if (!IGM.Opts.Optimize && SILTy && SILTy.hasArchetype())
657-
emitTypeMetadataRefForLayout(SILTy);
655+
// Force all archetypes referenced by the type to be bound by this point.
656+
// TODO: just make sure that we have a path to them that the debug info
657+
// can follow.
658+
if (!IGM.Opts.Optimize && Ty.getType()->hasArchetype())
659+
Ty.getType()->getCanonicalType().visit([&](Type t) {
660+
if (auto archetype = dyn_cast<ArchetypeType>(CanType(t)))
661+
emitTypeMetadataRef(archetype);
662+
});
658663

659664
assert(IGM.DebugInfo && "debug info not enabled");
660665
if (ArgNo) {

test/DebugInfo/EagerTypeMetadata.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class C<T>
99
// CHECK: %T = load %swift.type*, %swift.type**
1010
// CHECK-SAME: !dbg ![[LOC:[0-9]+]], !invariant.load
1111
// CHECK: ![[LOC]] = !DILocation(line: 0,
12-
var x = i
12+
var x = [i]
1313
}
1414
}
1515

0 commit comments

Comments
 (0)