diff --git a/dmd2/declaration.h b/dmd2/declaration.h index 6db1c5fc91..5a546f6397 100644 --- a/dmd2/declaration.h +++ b/dmd2/declaration.h @@ -19,8 +19,12 @@ #include #include #include +#if LDC_LLVM_VER >= 302 +#include +#else #include #endif +#endif #include "dsymbol.h" #include "lexer.h" diff --git a/gen/declarations.cpp b/gen/declarations.cpp index 6e4886b69f..4f0b2f70c6 100644 --- a/gen/declarations.cpp +++ b/gen/declarations.cpp @@ -159,8 +159,16 @@ void VarDeclaration::codegen(Ir* p) LLType *_type = DtoConstInitializerType(type, init); // create the global variable +#if LDC_LLVM_VER >= 302 + // FIXME: clang uses a command line option for the thread model + LLGlobalVariable* gvar = new LLGlobalVariable(*gIR->module, _type, _isconst, + DtoLinkage(this), NULL, _name, 0, + isThreadlocal() ? LLGlobalVariable::GeneralDynamicTLSModel + : LLGlobalVariable::NotThreadLocal); +#else LLGlobalVariable* gvar = new LLGlobalVariable(*gIR->module, _type, _isconst, DtoLinkage(this), NULL, _name, 0, isThreadlocal()); +#endif this->ir.irGlobal->value = gvar; // set the alignment diff --git a/gen/functions.cpp b/gen/functions.cpp index 97d4d7748a..d4ea7291d3 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -455,7 +455,11 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati } } +#if LDC_LLVM_VER >= 302 + llvm::AttrListPtr attrlist = llvm::AttrListPtr::get(llvm::ArrayRef(attrs)); +#else llvm::AttrListPtr attrlist = llvm::AttrListPtr::get(attrs.begin(), attrs.end()); +#endif func->setAttributes(attrlist); } diff --git a/gen/irstate.h b/gen/irstate.h index d553a211bd..3c4c78047f 100644 --- a/gen/irstate.h +++ b/gen/irstate.h @@ -13,7 +13,11 @@ #include "ir/irstruct.h" #include "ir/irvar.h" +#if LDC_LLVM_VER >= 302 +#include "llvm/DIBuilder.h" +#else #include "llvm/Analysis/DIBuilder.h" +#endif #include "llvm/Support/CallSite.h" namespace llvm { diff --git a/gen/llvm.h b/gen/llvm.h index da246f9425..da9b652a55 100644 --- a/gen/llvm.h +++ b/gen/llvm.h @@ -14,11 +14,16 @@ #include "llvm/Target/TargetData.h" +#if LDC_LLVM_VER >= 302 +#include "llvm/DebugInfo.h" +#include "llvm/IRBuilder.h" +#else #include "llvm/Analysis/DebugInfo.h" +#include "llvm/Support/IRBuilder.h" +#endif #include "llvm/Support/CallSite.h" -#include "llvm/Support/IRBuilder.h" using llvm::IRBuilder; // for WriteTypeSymbolic diff --git a/gen/passes/SimplifyDRuntimeCalls.cpp b/gen/passes/SimplifyDRuntimeCalls.cpp index 9f4d996e10..c2441ba51a 100644 --- a/gen/passes/SimplifyDRuntimeCalls.cpp +++ b/gen/passes/SimplifyDRuntimeCalls.cpp @@ -21,7 +21,11 @@ #include "llvm/Function.h" #include "llvm/Pass.h" #include "llvm/Intrinsics.h" +#if LDC_LLVM_VER >= 302 +#include "llvm/IRBuilder.h" +#else #include "llvm/Support/IRBuilder.h" +#endif #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/Target/TargetData.h" diff --git a/gen/tocall.cpp b/gen/tocall.cpp index 79f12fc8d8..71f639d83e 100644 --- a/gen/tocall.cpp +++ b/gen/tocall.cpp @@ -674,7 +674,11 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* } // set calling convention and parameter attributes +#if LDC_LLVM_VER >= 302 + llvm::AttrListPtr attrlist = llvm::AttrListPtr::get(llvm::ArrayRef(attrs)); +#else llvm::AttrListPtr attrlist = llvm::AttrListPtr::get(attrs.begin(), attrs.end()); +#endif if (dfnval && dfnval->func) { LLFunction* llfunc = llvm::dyn_cast(dfnval->val);