From f3ea671ed6cebc4e60c1daba5f9e37d8806a0ca8 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Sat, 21 Jun 2008 17:57:36 +0200 Subject: [PATCH] [svn r311] Fixed: structs no longer output two static typeinfos. Updated the DtoTypeInfoOf helper a bit after figuring out how it worked. --- gen/llvmhelpers.cpp | 9 ++++----- gen/typinf.cpp | 3 +-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/gen/llvmhelpers.cpp b/gen/llvmhelpers.cpp index 09256696..ab821f6a 100644 --- a/gen/llvmhelpers.cpp +++ b/gen/llvmhelpers.cpp @@ -1085,17 +1085,16 @@ void DtoAnnotation(const char* str) LLConstant* DtoTypeInfoOf(Type* type, bool base) { - type = type->merge(); // seems like this is needed in some cases with templates. - const LLType* typeinfotype = DtoType(Type::typeinfo->type); - if (!type->vtinfo) - type->getTypeInfo(NULL); + type = type->merge(); // needed.. getTypeInfo does the same + type->getTypeInfo(NULL); TypeInfoDeclaration* tidecl = type->vtinfo; + assert(tidecl); DtoForceDeclareDsymbol(tidecl); assert(tidecl->ir.irGlobal != NULL); LLConstant* c = isaConstant(tidecl->ir.irGlobal->value); assert(c != NULL); if (base) - return llvm::ConstantExpr::getBitCast(c, typeinfotype); + return llvm::ConstantExpr::getBitCast(c, DtoType(Type::typeinfo->type)); return c; } diff --git a/gen/typinf.cpp b/gen/typinf.cpp index 669d4d9a..7457dc94 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -383,6 +383,7 @@ void TypeInfoTypedefDeclaration::llvmDefine() TypedefDeclaration *sd = tc->sym; // TypeInfo base + sd->basetype = sd->basetype->merge(); // DMD does this! LLConstant* castbase = DtoTypeInfoOf(sd->basetype, true); assert(castbase->getType() == stype->getElementType(2)); sinits.push_back(castbase); @@ -962,8 +963,6 @@ void TypeInfoStructDeclaration::llvmDefine() // create the symbol LLConstant* tiInit = llvm::ConstantStruct::get(stype, sinits); - llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,tiInit,toChars(),gIR->module); - isaGlobalVar(this->ir.irGlobal->value)->setInitializer(tiInit); }