diff --git a/dmd2/module.c b/dmd2/module.c index a68c6247..56411c5a 100644 --- a/dmd2/module.c +++ b/dmd2/module.c @@ -27,18 +27,6 @@ #include "d-dmd-gcc.h" #endif -#if IN_LLVM -#if LDC_LLVM_VER >= 303 -#include "llvm/IR/Type.h" -#include "llvm/IR/LLVMContext.h" -#include "llvm/IR/DerivedTypes.h" -#else -#include "llvm/Type.h" -#include "llvm/LLVMContext.h" -#include "llvm/DerivedTypes.h" -#endif -#endif - AggregateDeclaration *Module::moduleinfo; Module *Module::rootModule; @@ -144,7 +132,6 @@ Module::Module(char *filename, Identifier *ident, int doDocComment, int doHdrGen // LDC llvmForceLogging = false; moduleInfoVar = NULL; - moduleInfoType = llvm::StructType::create(llvm::getGlobalContext()); this->doDocComment = doDocComment; this->doHdrGen = doHdrGen; this->isRoot = false; @@ -214,9 +201,6 @@ void Module::deleteObjFile() Module::~Module() { -#if IN_LLVM - delete moduleInfoType; -#endif } const char *Module::kind() diff --git a/dmd2/module.h b/dmd2/module.h index fe213fc3..648e527e 100644 --- a/dmd2/module.h +++ b/dmd2/module.h @@ -201,7 +201,6 @@ struct Module : Package bool llvmForceLogging; llvm::GlobalVariable* moduleInfoVar; - llvm::StructType* moduleInfoType; // array ops emitted in this module already AA *arrayfuncs; diff --git a/gen/module.cpp b/gen/module.cpp index 7e3db31d..f7fc0d8a 100644 --- a/gen/module.cpp +++ b/gen/module.cpp @@ -453,13 +453,13 @@ llvm::GlobalVariable* Module::moduleInfoSymbol() return var; } - if (moduleInfoVar) - return moduleInfoVar; - - // declare global - // flags will be modified at runtime so can't make it constant - moduleInfoVar = getOrCreateGlobal(loc, *gIR->module, moduleInfoType, - false, llvm::GlobalValue::ExternalLinkage, NULL, MIname); + if (!moduleInfoVar) { + // declare global + // flags will be modified at runtime so can't make it constant + LLType *moduleInfoType = llvm::StructType::create(llvm::getGlobalContext()); + moduleInfoVar = getOrCreateGlobal(loc, *gIR->module, moduleInfoType, + false, llvm::GlobalValue::ExternalLinkage, NULL, MIname); + } return moduleInfoVar; } @@ -637,10 +637,11 @@ void Module::genmoduleinfo() b.push(toConstantArray(it, at, name, len, false)); // create and set initializer - b.finalize(moduleInfoType, moduleInfoSymbol()); + LLGlobalVariable *moduleInfoSym = moduleInfoSymbol(); + b.finalize(moduleInfoSym->getType()->getPointerElementType(), moduleInfoSym); // build the modulereference and ctor for registering it - LLFunction* mictor = build_module_reference_and_ctor(moduleInfoSymbol()); + LLFunction* mictor = build_module_reference_and_ctor(moduleInfoSym); AppendFunctionToLLVMGlobalCtorsDtors(mictor, 65535, true); }