mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 16:11:08 +03:00
create our own global context, it's been removed from LLVM
(cherry picked from commit 26a4e2bd13
)
This commit is contained in:
parent
5ec3e7d38b
commit
eaa9e8130c
4 changed files with 17 additions and 5 deletions
|
@ -31,6 +31,7 @@
|
|||
#include "gen/irstate.h"
|
||||
#include "gen/linkage.h"
|
||||
#include "gen/llvm.h"
|
||||
#include "gen/llvmhelpers.h"
|
||||
#include "gen/logger.h"
|
||||
#include "gen/metadata.h"
|
||||
#include "gen/optimizer.h"
|
||||
|
@ -1258,7 +1259,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
// Generate one or more object/IR/bitcode files.
|
||||
if (global.params.obj && !modules.empty()) {
|
||||
ldc::CodeGenerator cg(llvm::getGlobalContext(), singleObj);
|
||||
ldc::CodeGenerator cg(getGlobalContext(), singleObj);
|
||||
|
||||
for (unsigned i = 0; i < modules.dim; i++) {
|
||||
Module *const m = modules[i];
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Transforms/Utils/ModuleUtils.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include <stack>
|
||||
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
|
@ -56,6 +57,13 @@ llvm::cl::opt<llvm::GlobalVariable::ThreadLocalMode> clThreadModel(
|
|||
|
||||
Type *getTypeInfoType(Type *t, Scope *sc);
|
||||
|
||||
/******************************************************************************
|
||||
* Global context
|
||||
******************************************************************************/
|
||||
static llvm::ManagedStatic<llvm::LLVMContext> GlobalContext;
|
||||
|
||||
llvm::LLVMContext& getGlobalContext() { return *GlobalContext; }
|
||||
|
||||
/******************************************************************************
|
||||
* DYNAMIC MEMORY HELPERS
|
||||
******************************************************************************/
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "mtype.h"
|
||||
#include "statement.h"
|
||||
|
||||
llvm::LLVMContext& getGlobalContext();
|
||||
|
||||
// dynamic memory helpers
|
||||
LLValue *DtoNew(Loc &loc, Type *newtype);
|
||||
LLValue *DtoNewStruct(Loc &loc, TypeStruct *newtype);
|
||||
|
|
|
@ -13,10 +13,11 @@
|
|||
#include "mtype.h"
|
||||
#include "gen/irstate.h"
|
||||
#include "gen/logger.h"
|
||||
#include "gen/llvmhelpers.h"
|
||||
#include "gen/tollvm.h"
|
||||
#include "ir/irtype.h"
|
||||
|
||||
// These functions use llvm::getGlobalContext() as they are invoked before gIR
|
||||
// These functions use getGlobalContext() as they are invoked before gIR
|
||||
// is set.
|
||||
|
||||
IrType::IrType(Type *dt, LLType *lt) : dtype(dt), type(lt) {
|
||||
|
@ -68,7 +69,7 @@ llvm::Type *getReal80Type(llvm::LLVMContext &ctx) {
|
|||
}
|
||||
|
||||
llvm::Type *IrTypeBasic::basic2llvm(Type *t) {
|
||||
llvm::LLVMContext &ctx = llvm::getGlobalContext();
|
||||
llvm::LLVMContext &ctx = getGlobalContext();
|
||||
|
||||
switch (t->ty) {
|
||||
case Tvoid:
|
||||
|
@ -135,7 +136,7 @@ IrTypePointer *IrTypePointer::get(Type *dt) {
|
|||
|
||||
LLType *elemType;
|
||||
if (dt->ty == Tnull) {
|
||||
elemType = llvm::Type::getInt8Ty(llvm::getGlobalContext());
|
||||
elemType = llvm::Type::getInt8Ty(getGlobalContext());
|
||||
} else {
|
||||
elemType = DtoMemType(dt->nextOf());
|
||||
|
||||
|
@ -186,7 +187,7 @@ IrTypeArray *IrTypeArray::get(Type *dt) {
|
|||
// just as for pointers.
|
||||
if (!dt->ctype) {
|
||||
llvm::Type *types[] = {DtoSize_t(), llvm::PointerType::get(elemType, 0)};
|
||||
LLType *at = llvm::StructType::get(llvm::getGlobalContext(), types, false);
|
||||
LLType *at = llvm::StructType::get(getGlobalContext(), types, false);
|
||||
dt->ctype = new IrTypeArray(dt, at);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue