24
24
using namespace swift ;
25
25
using namespace irgen ;
26
26
27
- DebugTypeInfo::DebugTypeInfo (DeclContext *DC, GenericEnvironment *GE,
28
- swift::Type Ty, llvm::Type *StorageTy, Size size,
29
- Alignment align, bool HasDefaultAlignment)
30
- : DeclCtx(DC), GenericEnv(GE), Type(Ty.getPointer()),
31
- StorageType(StorageTy), size(size), align(align),
32
- DefaultAlignment(HasDefaultAlignment) {
27
+ DebugTypeInfo::DebugTypeInfo (swift::Type Ty, llvm::Type *StorageTy, Size size,
28
+ Alignment align, bool HasDefaultAlignment,
29
+ bool IsMetadata)
30
+ : Type(Ty.getPointer()), StorageType(StorageTy), size(size), align(align),
31
+ DefaultAlignment(HasDefaultAlignment), IsMetadataType(IsMetadata) {
33
32
assert (StorageType && " StorageType is a nullptr" );
34
33
assert (align.getValue () != 0 );
35
34
}
@@ -43,9 +42,7 @@ static bool hasDefaultAlignment(swift::Type Ty) {
43
42
return true ;
44
43
}
45
44
46
- DebugTypeInfo DebugTypeInfo::getFromTypeInfo (DeclContext *DC,
47
- GenericEnvironment *GE,
48
- swift::Type Ty,
45
+ DebugTypeInfo DebugTypeInfo::getFromTypeInfo (swift::Type Ty,
49
46
const TypeInfo &Info) {
50
47
Size size;
51
48
if (Info.isFixedSize ()) {
@@ -56,13 +53,12 @@ DebugTypeInfo DebugTypeInfo::getFromTypeInfo(DeclContext *DC,
56
53
// encounter one.
57
54
size = Size (0 );
58
55
}
59
- return DebugTypeInfo (DC, GE, Ty.getPointer (), Info.getStorageType (), size,
60
- Info.getBestKnownAlignment (), hasDefaultAlignment (Ty));
56
+ return DebugTypeInfo (Ty.getPointer (), Info.getStorageType (), size,
57
+ Info.getBestKnownAlignment (), hasDefaultAlignment (Ty),
58
+ false );
61
59
}
62
60
63
- DebugTypeInfo DebugTypeInfo::getLocalVariable (DeclContext *DC,
64
- GenericEnvironment *GE,
65
- VarDecl *Decl, swift::Type Ty,
61
+ DebugTypeInfo DebugTypeInfo::getLocalVariable (VarDecl *Decl, swift::Type Ty,
66
62
const TypeInfo &Info) {
67
63
68
64
auto DeclType = Decl->getInterfaceType ();
@@ -77,13 +73,21 @@ DebugTypeInfo DebugTypeInfo::getLocalVariable(DeclContext *DC,
77
73
// the type hasn't been mucked with by an optimization pass.
78
74
auto *Type = Sugared->isEqual (RealType) ? DeclType.getPointer ()
79
75
: RealType.getPointer ();
80
- return getFromTypeInfo (DC, GE, Type, Info);
76
+ return getFromTypeInfo (Type, Info);
81
77
}
82
78
83
79
DebugTypeInfo DebugTypeInfo::getMetadata (swift::Type Ty, llvm::Type *StorageTy,
84
80
Size size, Alignment align) {
85
- DebugTypeInfo DbgTy (nullptr , nullptr , Ty.getPointer (), StorageTy, size,
86
- align, true );
81
+ DebugTypeInfo DbgTy (Ty.getPointer (), StorageTy, size,
82
+ align, true , false );
83
+ assert (!DbgTy.isArchetype () && " type metadata cannot contain an archetype" );
84
+ return DbgTy;
85
+ }
86
+
87
+ DebugTypeInfo DebugTypeInfo::getArchetype (swift::Type Ty, llvm::Type *StorageTy,
88
+ Size size, Alignment align) {
89
+ DebugTypeInfo DbgTy (Ty.getPointer (), StorageTy, size,
90
+ align, true , true );
87
91
assert (!DbgTy.isArchetype () && " type metadata cannot contain an archetype" );
88
92
return DbgTy;
89
93
}
@@ -93,19 +97,15 @@ DebugTypeInfo DebugTypeInfo::getGlobal(SILGlobalVariable *GV,
93
97
Alignment align) {
94
98
// Prefer the original, potentially sugared version of the type if
95
99
// the type hasn't been mucked with by an optimization pass.
96
- DeclContext *DC = nullptr ;
97
- GenericEnvironment *GE = nullptr ;
98
100
auto LowTy = GV->getLoweredType ().getASTType ();
99
101
auto *Type = LowTy.getPointer ();
100
102
if (auto *Decl = GV->getDecl ()) {
101
- DC = Decl->getDeclContext ();
102
- GE = DC->getGenericEnvironmentOfContext ();
103
103
auto DeclType = Decl->getType ();
104
104
if (DeclType->isEqual (LowTy))
105
105
Type = DeclType.getPointer ();
106
106
}
107
- DebugTypeInfo DbgTy (DC, GE, Type, StorageTy, size, align,
108
- hasDefaultAlignment (Type) );
107
+ DebugTypeInfo DbgTy (Type, StorageTy, size, align, hasDefaultAlignment (Type) ,
108
+ false );
109
109
assert (StorageTy && " StorageType is a nullptr" );
110
110
assert (!DbgTy.isArchetype () &&
111
111
" type of global variable cannot be an archetype" );
@@ -116,13 +116,19 @@ DebugTypeInfo DebugTypeInfo::getGlobal(SILGlobalVariable *GV,
116
116
DebugTypeInfo DebugTypeInfo::getObjCClass (ClassDecl *theClass,
117
117
llvm::Type *StorageType, Size size,
118
118
Alignment align) {
119
- DebugTypeInfo DbgTy (nullptr , nullptr ,
120
- theClass->getInterfaceType ().getPointer (), StorageType,
121
- size, align, true );
119
+ DebugTypeInfo DbgTy (theClass->getInterfaceType ().getPointer (), StorageType,
120
+ size, align, true , false );
122
121
assert (!DbgTy.isArchetype () && " type of objc class cannot be an archetype" );
123
122
return DbgTy;
124
123
}
125
124
125
+ DebugTypeInfo DebugTypeInfo::getErrorResult (swift::Type Ty,
126
+ llvm::Type *StorageType, Size size,
127
+ Alignment align) {
128
+ assert (StorageType && " StorageType is a nullptr" );
129
+ return {Ty, StorageType, size, align, true , false };
130
+ }
131
+
126
132
bool DebugTypeInfo::operator ==(DebugTypeInfo T) const {
127
133
return (getType () == T.getType () &&
128
134
size == T.size &&
0 commit comments