mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 08:01:11 +03:00
Merge pull request #1272 from redstar/issue1112
Do not construct Ir-Types twice for the same type.
This commit is contained in:
commit
06ad20a920
3 changed files with 21 additions and 11 deletions
|
@ -186,12 +186,16 @@ IrTypeArray *IrTypeArray::get(Type *dt) {
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
IrTypeVector::IrTypeVector(Type *dt) : IrType(dt, vector2llvm(dt)) {}
|
||||
IrTypeVector::IrTypeVector(Type *dt, llvm::Type *lt) : IrType(dt, lt) {}
|
||||
|
||||
IrTypeVector *IrTypeVector::get(Type *dt) {
|
||||
auto t = new IrTypeVector(dt);
|
||||
dt->ctype = t;
|
||||
return t;
|
||||
LLType *lt = vector2llvm(dt);
|
||||
// Could have already built the type as part of a struct forward reference,
|
||||
// just as for pointers and arrays.
|
||||
if (!dt->ctype) {
|
||||
dt->ctype = new IrTypeVector(dt, lt);
|
||||
}
|
||||
return dt->ctype->isVector();
|
||||
}
|
||||
|
||||
llvm::Type *IrTypeVector::vector2llvm(Type *dt) {
|
||||
|
|
|
@ -182,7 +182,7 @@ public:
|
|||
|
||||
protected:
|
||||
///
|
||||
explicit IrTypeVector(Type *dt);
|
||||
explicit IrTypeVector(Type *dt, llvm::Type *lt);
|
||||
|
||||
static llvm::Type *vector2llvm(Type *dt);
|
||||
};
|
||||
|
|
|
@ -26,9 +26,12 @@ IrTypeFunction *IrTypeFunction::get(Type *dt) {
|
|||
IrFuncTy irFty;
|
||||
llvm::Type *lt = DtoFunctionType(dt, irFty, nullptr, nullptr);
|
||||
|
||||
auto result = new IrTypeFunction(dt, lt, irFty);
|
||||
dt->ctype = result;
|
||||
return result;
|
||||
// Could have already built the type as part of a struct forward reference,
|
||||
// just as for pointers and arrays.
|
||||
if (!dt->ctype) {
|
||||
dt->ctype = new IrTypeFunction(dt, lt, irFty);
|
||||
}
|
||||
return dt->ctype->isFunction();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -47,7 +50,10 @@ IrTypeDelegate *IrTypeDelegate::get(Type *t) {
|
|||
llvm::Type *types[] = {getVoidPtrType(), getPtrToType(ltf)};
|
||||
LLStructType *lt = LLStructType::get(gIR->context(), types, false);
|
||||
|
||||
auto result = new IrTypeDelegate(t, lt, irFty);
|
||||
t->ctype = result;
|
||||
return result;
|
||||
// Could have already built the type as part of a struct forward reference,
|
||||
// just as for pointers and arrays.
|
||||
if (!t->ctype) {
|
||||
t->ctype = new IrTypeDelegate(t, lt, irFty);
|
||||
}
|
||||
return t->ctype->isDelegate();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue