Do not construct Ir-Types twice for the same type.

This is the same as in PR #1269. The Ir-Types may be initialized
twice (due to pointers, forward references etc.).
This commit fixes hopefully all instances of this problem, using
the same approach in each factory function.

This fixes issue #1112.
This commit is contained in:
Kai Nacke 2016-02-01 21:52:15 +01:00
parent 4aac6351d4
commit 6ca3d730ae
3 changed files with 21 additions and 11 deletions

View file

@ -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) {