@@ -105,8 +105,7 @@ DebugTypeInfo DebugTypeInfo::getForwardDecl(swift::Type Ty) {
105
105
return DbgTy;
106
106
}
107
107
108
- DebugTypeInfo DebugTypeInfo::getGlobal (SILGlobalVariable *GV,
109
- IRGenModule &IGM) {
108
+ static TypeBase *getTypeForGlobal (SILGlobalVariable *GV, IRGenModule &IGM) {
110
109
// Prefer the original, potentially sugared version of the type if
111
110
// the type hasn't been mucked with by an optimization pass.
112
111
auto LowTy = GV->getLoweredType ().getASTType ();
@@ -116,6 +115,15 @@ DebugTypeInfo DebugTypeInfo::getGlobal(SILGlobalVariable *GV,
116
115
if (DeclType->isEqual (LowTy))
117
116
Type = DeclType.getPointer ();
118
117
}
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);
119
127
auto &TI = IGM.getTypeInfoForUnlowered (Type);
120
128
DebugTypeInfo DbgTy = getFromTypeInfo (Type, TI, IGM);
121
129
assert (!DbgTy.isContextArchetype () &&
@@ -124,17 +132,9 @@ DebugTypeInfo DebugTypeInfo::getGlobal(SILGlobalVariable *GV,
124
132
}
125
133
126
134
DebugTypeInfo 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);
138
138
DebugTypeInfo DbgTy (Type, Align, ::hasDefaultAlignment (Type),
139
139
/* IsMetadataType = */ false , /* IsFixedBuffer = */ true );
140
140
assert (!DbgTy.isContextArchetype () &&
0 commit comments