From 90c6e0172a7eb6a142a1e6cb93c3a5dcd694e26d Mon Sep 17 00:00:00 2001 From: Andrey Shishpanov Date: Tue, 28 Jul 2015 18:35:58 +0300 Subject: [PATCH] some fixes for new LLVM API --- ctx.cpp | 13 ++++++++++++- ispc.cpp | 4 +++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/ctx.cpp b/ctx.cpp index 50b03653..8690c9b8 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -380,11 +380,22 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym, llvm::DICompositeType diSubprogramType_n = static_cast(diSubprogramType); int flags = llvm::DIDescriptor::FlagPrototyped; -#else /* LLVM 3.7+ */ +#elif ISPC_LLVM_VERSION == ISPC_LLVM_3_7 /* LLVM 3.7 */ Assert(llvm::isa(diSubprogramType)); llvm::DISubroutineType *diSubprogramType_n = llvm::cast(getDICompositeType(diSubprogramType)); int flags = llvm::DINode::FlagPrototyped; +#else /* LLVM 3.8+ */ + Assert(llvm::isa(diSubprogramType)); + llvm::DICompositeType *C = llvm::dyn_cast_or_null(diSubprogramType); + if (!C){ + llvm::DITypeIdentifierMap EmptyMap; + C = llvm::dyn_cast_or_null(llvm::dyn_cast_or_null(diSubprogramType)->getBaseType().resolve(EmptyMap)); + } //restored function getDICompositeType() from 3.7 which absents in 3.8 + llvm::DISubroutineType *diSubprogramType_n = + llvm::cast(C); + int flags = llvm::DINode::FlagPrototyped; + #endif std::string mangledName = llvmFunction->getName(); diff --git a/ispc.cpp b/ispc.cpp index 3b92fa05..5438a4e4 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -1044,7 +1044,9 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo std::string dl_string; #if ISPC_LLVM_VERSION == ISPC_LLVM_3_6 dl_string = m_targetMachine->getSubtargetImpl()->getDataLayout()->getStringRepresentation(); -#else // LLVM 3.5- or LLVM 3.7+ +#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_8 // LLVM 3.8+ + dl_string = m_targetMachine->createDataLayout().getStringRepresentation(); +#else // LLVM 3.5- or LLVM 3.7 dl_string = m_targetMachine->getDataLayout()->getStringRepresentation(); #endif // 2. Adjust for generic