@@ -105,8 +105,7 @@ DebugTypeInfo DebugTypeInfo::getForwardDecl(swift::Type Ty) {
105105 return DbgTy;
106106}
107107
108- DebugTypeInfo DebugTypeInfo::getGlobal (SILGlobalVariable *GV,
109- IRGenModule &IGM) {
108+ static TypeBase *getTypeForGlobal (SILGlobalVariable *GV, IRGenModule &IGM) {
110109 // Prefer the original, potentially sugared version of the type if
111110 // the type hasn't been mucked with by an optimization pass.
112111 auto LowTy = GV->getLoweredType ().getASTType ();
@@ -116,6 +115,15 @@ DebugTypeInfo DebugTypeInfo::getGlobal(SILGlobalVariable *GV,
116115 if (DeclType->isEqual (LowTy))
117116 Type = DeclType.getPointer ();
118117 }
118+ // If this global variable contains an opaque type, replace it with its
119+ // underlying type.
120+ Type = IGM.substOpaqueTypesWithUnderlyingTypes (Type).getPointer ();
121+ return Type;
122+ }
123+
124+ DebugTypeInfo DebugTypeInfo::getGlobal (SILGlobalVariable *GV,
125+ IRGenModule &IGM) {
126+ auto *Type = getTypeForGlobal (GV, IGM);
119127 auto &TI = IGM.getTypeInfoForUnlowered (Type);
120128 DebugTypeInfo DbgTy = getFromTypeInfo (Type, TI, IGM);
121129 assert (!DbgTy.isContextArchetype () &&
@@ -124,17 +132,9 @@ DebugTypeInfo DebugTypeInfo::getGlobal(SILGlobalVariable *GV,
124132}
125133
126134DebugTypeInfo DebugTypeInfo::getGlobalFixedBuffer (SILGlobalVariable *GV,
127- Size SizeInBytes,
128- Alignment Align) {
129- // Prefer the original, potentially sugared version of the type if
130- // the type hasn't been mucked with by an optimization pass.
131- auto LowTy = GV->getLoweredType ().getASTType ();
132- auto *Type = LowTy.getPointer ();
133- if (auto *Decl = GV->getDecl ()) {
134- auto DeclType = Decl->getTypeInContext ();
135- if (DeclType->isEqual (LowTy))
136- Type = DeclType.getPointer ();
137- }
135+ Alignment Align,
136+ IRGenModule &IGM) {
137+ auto *Type = getTypeForGlobal (GV, IGM);
138138 DebugTypeInfo DbgTy (Type, Align, ::hasDefaultAlignment (Type),
139139 /* IsMetadataType = */ false , /* IsFixedBuffer = */ true );
140140 assert (!DbgTy.isContextArchetype () &&
0 commit comments