mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01:00
Fixed #37 — ICE: llvm::GlobalVariable::setInitializer assert failed
This commit is contained in:
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user