mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 00:55:49 +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) {
|
IrTypeVector *IrTypeVector::get(Type *dt) {
|
||||||
auto t = new IrTypeVector(dt);
|
LLType *lt = vector2llvm(dt);
|
||||||
dt->ctype = t;
|
// Could have already built the type as part of a struct forward reference,
|
||||||
return t;
|
// 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) {
|
llvm::Type *IrTypeVector::vector2llvm(Type *dt) {
|
||||||
|
|
|
@ -182,7 +182,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
///
|
///
|
||||||
explicit IrTypeVector(Type *dt);
|
explicit IrTypeVector(Type *dt, llvm::Type *lt);
|
||||||
|
|
||||||
static llvm::Type *vector2llvm(Type *dt);
|
static llvm::Type *vector2llvm(Type *dt);
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,9 +26,12 @@ IrTypeFunction *IrTypeFunction::get(Type *dt) {
|
||||||
IrFuncTy irFty;
|
IrFuncTy irFty;
|
||||||
llvm::Type *lt = DtoFunctionType(dt, irFty, nullptr, nullptr);
|
llvm::Type *lt = DtoFunctionType(dt, irFty, nullptr, nullptr);
|
||||||
|
|
||||||
auto result = new IrTypeFunction(dt, lt, irFty);
|
// Could have already built the type as part of a struct forward reference,
|
||||||
dt->ctype = result;
|
// just as for pointers and arrays.
|
||||||
return result;
|
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)};
|
llvm::Type *types[] = {getVoidPtrType(), getPtrToType(ltf)};
|
||||||
LLStructType *lt = LLStructType::get(gIR->context(), types, false);
|
LLStructType *lt = LLStructType::get(gIR->context(), types, false);
|
||||||
|
|
||||||
auto result = new IrTypeDelegate(t, lt, irFty);
|
// Could have already built the type as part of a struct forward reference,
|
||||||
t->ctype = result;
|
// just as for pointers and arrays.
|
||||||
return result;
|
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