From 8b509286367901dd99ac3b5f3b5b8b371b3a82ca Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Tue, 6 Dec 2011 13:55:01 +0400 Subject: [PATCH] =?UTF-8?q?Fixed=20#37=20=E2=80=94=20ICE:=20llvm::GlobalVa?= =?UTF-8?q?riable::setInitializer=20assert=20failed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gen/declarations.cpp | 3 +++ gen/rttibuilder.cpp | 10 ++++++---- gen/typinf.cpp | 19 +++++++++++-------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/gen/declarations.cpp b/gen/declarations.cpp index b3cd6f3a..6ae5d5f9 100644 --- a/gen/declarations.cpp +++ b/gen/declarations.cpp @@ -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()); diff --git a/gen/rttibuilder.cpp b/gen/rttibuilder.cpp index 33fc9721..52cb6ce1 100644 --- a/gen/rttibuilder.cpp +++ b/gen/rttibuilder.cpp @@ -153,10 +153,12 @@ void RTTIBuilder::finalize(LLType* type, LLValue* value) assert(st); // set struct body - std::vector 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 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); diff --git a/gen/typinf.cpp b/gen/typinf.cpp index d62ba559..0e8e71ac 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -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;