diff --git a/builtins.cpp b/builtins.cpp index 6be41f13..d6eefde5 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -643,13 +643,21 @@ lSetInternalFunctions(llvm::Module *module) { void AddBitcodeToModule(const unsigned char *bitcode, int length, llvm::Module *module, SymbolTable *symbolTable) { - std::string bcErr; llvm::StringRef sb = llvm::StringRef((char *)bitcode, length); llvm::MemoryBuffer *bcBuf = llvm::MemoryBuffer::getMemBuffer(sb); +#if defined(LLVM_3_5) + llvm::ErrorOr ModuleOrErr = llvm::parseBitcodeFile(bcBuf, *g->ctx); + if (llvm::error_code EC = ModuleOrErr.getError()) + Error(SourcePos(), "Error parsing stdlib bitcode: %s", EC.message().c_str()); + else { + llvm::Module *bcModule = ModuleOrErr.get(); +#else + std::string bcErr; llvm::Module *bcModule = llvm::ParseBitcodeFile(bcBuf, *g->ctx, &bcErr); if (!bcModule) Error(SourcePos(), "Error parsing stdlib bitcode: %s", bcErr.c_str()); else { +#endif // FIXME: this feels like a bad idea, but the issue is that when we // set the llvm::Module's target triple in the ispc Module::Module // constructor, we start by calling llvm::sys::getHostTriple() (and diff --git a/cbackend.cpp b/cbackend.cpp index 2ac6cc0b..6465d466 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -2327,7 +2327,11 @@ bool CWriter::doInitialization(llvm::Module &M) { if (I->hasExternalLinkage() || I->hasExternalWeakLinkage() || I->hasCommonLinkage()) Out << "extern "; +#if defined (LLVM_3_5) + else if (I->hasDLLImportStorageClass()) +#else else if (I->hasDLLImportLinkage()) +#endif Out << "__declspec(dllimport) "; else continue; // Internal Global @@ -2499,11 +2503,13 @@ bool CWriter::doInitialization(llvm::Module &M) { if (I->hasLocalLinkage()) Out << "static "; - else if (I->hasDLLImportLinkage()) - Out << "__declspec(dllimport) "; - else if (I->hasDLLExportLinkage()) - Out << "__declspec(dllexport) "; - +#if defined(LLVM_3_5) + else if (I->hasDLLImportStorageClass()) Out << "__declspec(dllimport) "; + else if (I->hasDLLExportStorageClass()) Out << "__declspec(dllexport) "; +#else + else if (I->hasDLLImportLinkage()) Out << "__declspec(dllimport) "; + else if (I->hasDLLExportLinkage()) Out << "__declspec(dllexport) "; +#endif // Thread Local Storage if (I->isThreadLocal()) Out << "__thread "; @@ -2782,8 +2788,13 @@ void CWriter::printFunctionSignature(const llvm::Function *F, bool Prototype) { bool isStructReturn = F->hasStructRetAttr(); if (F->hasLocalLinkage()) Out << "static "; +#if defined(LLVM_3_5) + if (F->hasDLLImportStorageClass()) Out << "__declspec(dllimport) "; + if (F->hasDLLExportStorageClass()) Out << "__declspec(dllexport) "; +#else if (F->hasDLLImportLinkage()) Out << "__declspec(dllimport) "; if (F->hasDLLExportLinkage()) Out << "__declspec(dllexport) "; +#endif switch (F->getCallingConv()) { case llvm::CallingConv::X86_StdCall: Out << "__attribute__((stdcall)) "; diff --git a/func.cpp b/func.cpp index 610a2bef..3d3a4112 100644 --- a/func.cpp +++ b/func.cpp @@ -477,7 +477,11 @@ Function::GenerateIR() { } if (m->errorCount == 0) { +#if defined (LLVM_3_5) + if (llvm::verifyFunction(*function) == true) { +#else if (llvm::verifyFunction(*function, llvm::ReturnStatusAction) == true) { +#endif if (g->debugPrint) function->dump(); FATAL("Function verificication failed"); @@ -523,8 +527,12 @@ Function::GenerateIR() { emitCode(&ec, appFunction, firstStmtPos); if (m->errorCount == 0) { sym->exportedFunction = appFunction; +#if defined(LLVM_3_5) + if (llvm::verifyFunction(*appFunction) == true) { +#else if (llvm::verifyFunction(*appFunction, llvm::ReturnStatusAction) == true) { +#endif if (g->debugPrint) appFunction->dump(); FATAL("Function verificication failed");