@@ -117,25 +117,12 @@ IrTypePointer *IrTypePointer::get(Type *dt) {
117
117
auto &ctype = getIrType (dt);
118
118
assert (!ctype);
119
119
120
- LLType *elemType;
121
- unsigned addressSpace = 0 ;
122
- if (dt->ty == TY::Tnull) {
123
- elemType = llvm::Type::getInt8Ty (getGlobalContext ());
124
- } else {
125
- elemType = DtoMemType (dt->nextOf ());
126
- if (dt->nextOf ()->ty == TY::Tfunction) {
127
- addressSpace = gDataLayout ->getProgramAddressSpace ();
128
- }
129
-
130
- // DtoType could have already created the same type, e.g. for
131
- // dt == Node* in struct Node { Node* n; }.
132
- if (ctype) {
133
- return ctype->isPointer ();
134
- }
135
- }
120
+ unsigned addressSpace =
121
+ dt->ty == TY::Tpointer && dt->nextOf ()->ty == TY::Tfunction
122
+ ? gDataLayout ->getProgramAddressSpace ()
123
+ : 0 ;
136
124
137
- auto t =
138
- new IrTypePointer (dt, llvm::PointerType::get (elemType, addressSpace));
125
+ auto t = new IrTypePointer (dt, getOpaquePtrType (addressSpace));
139
126
ctype = t;
140
127
return t;
141
128
}
@@ -173,15 +160,9 @@ IrTypeArray *IrTypeArray::get(Type *dt) {
173
160
auto &ctype = getIrType (dt);
174
161
assert (!ctype);
175
162
176
- LLType *elemType = DtoMemType (dt->nextOf ());
177
-
178
- // Could have already built the type as part of a struct forward reference,
179
- // just as for pointers.
180
- if (!ctype) {
181
- llvm::Type *types[] = {DtoSize_t (), llvm::PointerType::get (elemType, 0 )};
182
- LLType *at = llvm::StructType::get (getGlobalContext (), types, false );
183
- ctype = new IrTypeArray (dt, at);
184
- }
163
+ llvm::Type *types[] = {DtoSize_t (), getOpaquePtrType ()};
164
+ LLType *at = llvm::StructType::get (getGlobalContext (), types, false );
165
+ ctype = new IrTypeArray (dt, at);
185
166
186
167
return ctype->isArray ();
187
168
}
0 commit comments