Remove Module::moduleInfoType

This commit is contained in:
Alexey Prokhin
2013-07-28 21:59:01 +04:00
parent 69e7907875
commit 21b07c783a
3 changed files with 10 additions and 26 deletions

View File

@@ -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()

View File

@@ -201,7 +201,6 @@ struct Module : Package
bool llvmForceLogging;
llvm::GlobalVariable* moduleInfoVar;
llvm::StructType* moduleInfoType;
// array ops emitted in this module already
AA *arrayfuncs;

View File

@@ -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);
}