Fixed #37 — ICE: llvm::GlobalVariable::setInitializer assert failed

This commit is contained in:
Alexey Prokhin
2011-12-06 13:55:01 +04:00
parent f8bf70ff7a
commit 8b50928636
3 changed files with 20 additions and 12 deletions

View File

@@ -139,6 +139,9 @@ void VarDeclaration::codegen(Ir* p)
LLType *_type = DtoConstInitializerType(type, init);
if (_name == "_D13TypeInfo_yAAa6__initZ")
printf("!!!\n");
// create the global variable
LLGlobalVariable* gvar = new LLGlobalVariable(*gIR->module, _type, _isconst,
DtoLinkage(this), NULL, _name, 0, isThreadlocal());

View File

@@ -153,10 +153,12 @@ void RTTIBuilder::finalize(LLType* type, LLValue* value)
assert(st);
// set struct body
std::vector<LLType*> types;
for (int i = 0, n = inits.size(); i < n; ++i)
types.push_back(inits[i]->getType());
st->setBody(types);
if (st->isOpaque()) {
std::vector<LLType*> types;
for (int i = 0, n = inits.size(); i < n; ++i)
types.push_back(inits[i]->getType());
st->setBody(types);
}
// create the inititalizer
LLConstant* tiInit = LLConstantStruct::get(st, inits);

View File

@@ -302,18 +302,21 @@ void DtoResolveTypeInfo(TypeInfoDeclaration* tid)
Logger::println("DtoResolveTypeInfo(%s)", tid->toChars());
LOG_SCOPE;
IrGlobal* irg = new IrGlobal(tid);
if (tid->tinfo->builtinTypeInfo()) // this is a declaration of a builtin __initZ var
irg->type = Type::typeinfo->type->irtype->getType();
else
irg->type = LLStructType::create(gIR->context(), tid->toPrettyChars());
std::string mangle(tid->mangle());
IrGlobal* irg = new IrGlobal(tid);
irg->value = gIR->module->getGlobalVariable(mangle);
if (!irg->value)
if (!irg->value) {
if (tid->tinfo->builtinTypeInfo()) // this is a declaration of a builtin __initZ var
irg->type = Type::typeinfo->type->irtype->getType();
else
irg->type = LLStructType::create(gIR->context(), tid->toPrettyChars());
irg->value = new llvm::GlobalVariable(*gIR->module, irg->type, true,
TYPEINFO_LINKAGE_TYPE, NULL, mangle);
TYPEINFO_LINKAGE_TYPE, NULL, mangle);
} else {
irg->type = irg->value->getType()->getContainedType(0);
}
tid->ir.irGlobal = irg;