Mercurial > projects > ldc
diff gen/toobj.cpp @ 117:56a21f3e5d3e trunk
[svn r121] Finished ModuleInfo implementation.
Static ctors/dtors now work according to spec.
Changed class vtable types slightly in some cases. Overridden functions now always take the the type of the first class declaring the method as this parameter. This helps when using headers (w. implementation somewhere else)
author | lindquist |
---|---|
date | Mon, 26 Nov 2007 04:49:23 +0100 |
parents | fd7ad91fd713 |
children | 9c79b61fb638 |
line wrap: on
line diff
--- a/gen/toobj.cpp Sun Nov 25 18:55:52 2007 +0100 +++ b/gen/toobj.cpp Mon Nov 26 04:49:23 2007 +0100 @@ -123,6 +123,7 @@ if (!global.params.novalidate) { std::string verifyErr; Logger::println("Verifying module..."); + LOG_SCOPE; if (llvm::verifyModule(*ir.module,llvm::ReturnStatusAction,&verifyErr)) { error("%s", verifyErr.c_str()); @@ -364,6 +365,14 @@ // declare // flags will be modified at runtime so can't make it constant llvm::GlobalVariable* gvar = new llvm::GlobalVariable(moduleinfoTy, false, llvm::GlobalValue::ExternalLinkage, constMI, MIname, gIR->module); + + // declare the appending array + const llvm::ArrayType* appendArrTy = llvm::ArrayType::get(llvm::PointerType::get(llvm::Type::Int8Ty), 1); + std::vector<llvm::Constant*> appendInits; + appendInits.push_back(llvm::ConstantExpr::getBitCast(gvar, llvm::PointerType::get(llvm::Type::Int8Ty))); + llvm::Constant* appendInit = llvm::ConstantArray::get(appendArrTy, appendInits); + std::string appendName("_d_moduleinfo_array"); + llvm::GlobalVariable* appendVar = new llvm::GlobalVariable(appendArrTy, true, llvm::GlobalValue::AppendingLinkage, appendInit, appendName, gIR->module); } /* ================================================================== */