diff --git a/builtins.cpp b/builtins.cpp index f6ab185c..f70b6c73 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -72,7 +72,11 @@ #include #include #include -#include +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_9 + #include +#else + #include +#endif extern int yyparse(); struct yy_buffer_state; @@ -800,7 +804,13 @@ AddBitcodeToModule(const unsigned char *bitcode, int length, llvm::MemoryBufferRef bcBuf = llvm::MemoryBuffer::getMemBuffer(sb)->getMemBufferRef(); #endif -#if ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+ +#if ISPC_LLVM_VERSION >= ISPC_LLVM_4_0 // LLVM 4.0+ + llvm::Expected> ModuleOrErr = llvm::parseBitcodeFile(bcBuf, *g->ctx); + if (!ModuleOrErr) { + Error(SourcePos(), "Error parsing stdlib bitcode: %s", toString(ModuleOrErr.takeError()).c_str()); + } else { + llvm::Module *bcModule = ModuleOrErr.get().release(); +#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_7 // LLVM 3.7+ llvm::ErrorOr> ModuleOrErr = llvm::parseBitcodeFile(bcBuf, *g->ctx); if (std::error_code EC = ModuleOrErr.getError()) Error(SourcePos(), "Error parsing stdlib bitcode: %s", EC.message().c_str()); diff --git a/module.cpp b/module.cpp index 1ec2dcbc..6a5a2f4f 100644 --- a/module.cpp +++ b/module.cpp @@ -128,7 +128,11 @@ #include #include #include -#include +#if ISPC_LLVM_VERSION <= ISPC_LLVM_3_9 + #include +#else + #include +#endif /*! list of files encountered by the parser. this allows emitting of the module file's dependencies via the -MMM option */