diff --git a/configure b/configure index 20a5fa390f00b..c21324af96443 100755 --- a/configure +++ b/configure @@ -922,11 +922,11 @@ then LLVM_VERSION=$($LLVM_CONFIG --version) case $LLVM_VERSION in - (3.[5-6]*) + (3.6*) msg "found ok version of LLVM: $LLVM_VERSION" ;; (*) - err "bad LLVM version: $LLVM_VERSION, need >=3.5" + err "bad LLVM version: $LLVM_VERSION, need 3.6*" ;; esac fi diff --git a/src/rustllvm/ExecutionEngineWrapper.cpp b/src/rustllvm/ExecutionEngineWrapper.cpp index 7e0630fd242d3..2d8cdbab30326 100644 --- a/src/rustllvm/ExecutionEngineWrapper.cpp +++ b/src/rustllvm/ExecutionEngineWrapper.cpp @@ -88,18 +88,12 @@ extern "C" LLVMExecutionEngineRef LLVMBuildExecutionEngine( options.JITEmitDebugInfo = true; options.NoFramePointerElim = true; - ExecutionEngine *ee = - #if LLVM_VERSION_MINOR >= 6 - EngineBuilder(std::unique_ptr(unwrap(mod))) - .setMCJITMemoryManager(std::unique_ptr(unwrap(mref))) - #else - EngineBuilder(unwrap(mod)) - .setMCJITMemoryManager(unwrap(mref)) - #endif - .setEngineKind(EngineKind::JIT) - .setErrorStr(&error_str) - .setTargetOptions(options) - .create(); + ExecutionEngine *ee = EngineBuilder(std::unique_ptr(unwrap(mod))) + .setMCJITMemoryManager(std::unique_ptr(unwrap(mref))) + .setEngineKind(EngineKind::JIT) + .setErrorStr(&error_str) + .setTargetOptions(options) + .create(); if (!ee) LLVMRustSetLastError(error_str.c_str()); diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index a2ab8040198ff..078814b17b21a 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -123,11 +123,7 @@ LLVMRustAddAnalysisPasses(LLVMTargetMachineRef TM, LLVMPassManagerRef PMR, LLVMModuleRef M) { PassManagerBase *PM = unwrap(PMR); -#if LLVM_VERSION_MINOR >= 6 PM->add(new DataLayoutPass()); -#else - PM->add(new DataLayoutPass(unwrap(M))); -#endif unwrap(TM)->addAnalysisPasses(*PM); } @@ -192,14 +188,10 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, PassManager *PM = unwrap(PMR); std::string ErrorInfo; -#if LLVM_VERSION_MINOR >= 6 std::error_code EC; raw_fd_ostream OS(path, EC, sys::fs::F_None); if (EC) ErrorInfo = EC.message(); -#else - raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None); -#endif if (ErrorInfo != "") { LLVMRustSetLastError(ErrorInfo.c_str()); return false; @@ -218,14 +210,10 @@ LLVMRustPrintModule(LLVMPassManagerRef PMR, PassManager *PM = unwrap(PMR); std::string ErrorInfo; -#if LLVM_VERSION_MINOR >= 6 std::error_code EC; raw_fd_ostream OS(path, EC, sys::fs::F_None); if (EC) ErrorInfo = EC.message(); -#else - raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None); -#endif formatted_raw_ostream FOS(OS); diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 66db7326d21bf..f8a6a47899582 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -214,7 +214,6 @@ extern "C" LLVMValueRef LLVMInlineAsm(LLVMTypeRef Ty, typedef DIBuilder* DIBuilderRef; -#if LLVM_VERSION_MINOR >= 6 typedef struct LLVMOpaqueMetadata *LLVMMetadataRef; namespace llvm { @@ -224,16 +223,13 @@ inline Metadata **unwrap(LLVMMetadataRef *Vals) { return reinterpret_cast(Vals); } } -#else -typedef LLVMValueRef LLVMMetadataRef; -#endif template DIT unwrapDI(LLVMMetadataRef ref) { return DIT(ref ? unwrap(ref) : NULL); } -extern "C" const uint32_t LLVMRustDebugMetadataVersion() { +extern "C" uint32_t LLVMRustDebugMetadataVersion() { return DEBUG_METADATA_VERSION; } @@ -288,11 +284,7 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateSubroutineType( LLVMMetadataRef ParameterTypes) { return wrap(Builder->createSubroutineType( unwrapDI(File), -#if LLVM_VERSION_MINOR >= 6 unwrapDI(ParameterTypes))); -#else - unwrapDI(ParameterTypes))); -#endif } extern "C" LLVMMetadataRef LLVMDIBuilderCreateFunction( @@ -398,11 +390,7 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock( unsigned Col) { return wrap(Builder->createLexicalBlock( unwrapDI(Scope), - unwrapDI(File), Line, Col -#if LLVM_VERSION_MINOR == 5 - , 0 -#endif - )); + unwrapDI(File), Line, Col)); } extern "C" LLVMMetadataRef LLVMDIBuilderCreateStaticVariable( @@ -416,11 +404,7 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateStaticVariable( bool isLocalToUnit, LLVMValueRef Val, LLVMMetadataRef Decl = NULL) { -#if LLVM_VERSION_MINOR >= 6 return wrap(Builder->createGlobalVariable(unwrapDI(Context), -#else - return wrap(Builder->createStaticVariable(unwrapDI(Context), -#endif Name, LinkageName, unwrapDI(File), @@ -444,25 +428,6 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateVariable( int64_t* AddrOps, unsigned AddrOpsCount, unsigned ArgNo) { -#if LLVM_VERSION_MINOR == 5 - if (AddrOpsCount > 0) { - SmallVector addr_ops; - llvm::Type *Int64Ty = Type::getInt64Ty(unwrap(Scope)->getContext()); - for (unsigned i = 0; i < AddrOpsCount; ++i) - addr_ops.push_back(ConstantInt::get(Int64Ty, AddrOps[i])); - - return wrap(Builder->createComplexVariable( - Tag, - unwrapDI(Scope), - Name, - unwrapDI(File), - LineNo, - unwrapDI(Ty), - addr_ops, - ArgNo - )); - } -#endif return wrap(Builder->createLocalVariable(Tag, unwrapDI(Scope), Name, unwrapDI(File), @@ -504,11 +469,7 @@ extern "C" LLVMMetadataRef LLVMDIBuilderGetOrCreateArray( LLVMMetadataRef* Ptr, unsigned Count) { return wrap(Builder->getOrCreateArray( -#if LLVM_VERSION_MINOR >= 6 ArrayRef(unwrap(Ptr), Count))); -#else - ArrayRef(reinterpret_cast(Ptr), Count))); -#endif } extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd( @@ -518,7 +479,6 @@ extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd( int64_t* AddrOps, unsigned AddrOpsCount, LLVMBasicBlockRef InsertAtEnd) { -#if LLVM_VERSION_MINOR >= 6 DIExpression Expr; if (AddrOpsCount == 0) { Expr = Builder->createExpression(); @@ -526,13 +486,10 @@ extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd( llvm::ArrayRef addr_ops(AddrOps, AddrOpsCount); Expr = Builder->createExpression(addr_ops); } -#endif return wrap(Builder->insertDeclare( unwrap(Val), unwrapDI(VarInfo), -#if LLVM_VERSION_MINOR >= 6 Expr, -#endif unwrap(InsertAtEnd))); } @@ -543,7 +500,6 @@ extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareBefore( int64_t* AddrOps, unsigned AddrOpsCount, LLVMValueRef InsertBefore) { -#if LLVM_VERSION_MINOR >= 6 DIExpression Expr; if (AddrOpsCount == 0) { Expr = Builder->createExpression(); @@ -551,13 +507,10 @@ extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareBefore( llvm::ArrayRef addr_ops(AddrOps, AddrOpsCount); Expr = Builder->createExpression(addr_ops); } -#endif return wrap(Builder->insertDeclare( unwrap(Val), unwrapDI(VarInfo), -#if LLVM_VERSION_MINOR >= 6 Expr, -#endif unwrap(InsertBefore))); } @@ -665,12 +618,8 @@ extern "C" void LLVMDICompositeTypeSetTypeArray( LLVMMetadataRef CompositeType, LLVMMetadataRef TypeArray) { -#if LLVM_VERSION_MINOR >= 6 DICompositeType tmp = unwrapDI(CompositeType); Builder->replaceArrays(tmp, unwrapDI(TypeArray)); -#else - unwrapDI(CompositeType).setTypeArray(unwrapDI(TypeArray)); -#endif } extern "C" LLVMValueRef LLVMDIBuilderCreateDebugLocation( @@ -687,11 +636,7 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateDebugLocation( unwrapDI(Scope), unwrapDI(InlinedAt)); -#if LLVM_VERSION_MINOR >= 6 return wrap(MetadataAsValue::get(context, debug_loc.getAsMDNode(context))); -#else - return wrap(debug_loc.getAsMDNode(context)); -#endif } extern "C" void LLVMWriteTypeToString(LLVMTypeRef Type, RustStringRef str) { @@ -711,30 +656,18 @@ extern "C" void LLVMWriteValueToString(LLVMValueRef Value, RustStringRef str) { extern "C" bool LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) { Module *Dst = unwrap(dst); -#if LLVM_VERSION_MINOR >= 6 std::unique_ptr buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len)); ErrorOr Src = llvm::getLazyBitcodeModule(std::move(buf), Dst->getContext()); -#else - MemoryBuffer* buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len)); - ErrorOr Src = llvm::getLazyBitcodeModule(buf, Dst->getContext()); -#endif if (!Src) { LLVMRustSetLastError(Src.getError().message().c_str()); -#if LLVM_VERSION_MINOR == 5 - delete buf; -#endif return false; } std::string Err; -#if LLVM_VERSION_MINOR >= 6 raw_string_ostream Stream(Err); DiagnosticPrinterRawOStream DP(Stream); if (Linker::LinkModules(Dst, *Src, [&](const DiagnosticInfo &DI) { DI.print(DP); })) { -#else - if (Linker::LinkModules(Dst, *Src, Linker::DestroySource, &Err)) { -#endif LLVMRustSetLastError(Err.c_str()); return false; } @@ -751,7 +684,6 @@ LLVMRustOpenArchive(char *path) { return nullptr; } -#if LLVM_VERSION_MINOR >= 6 ErrorOr> archive_or = Archive::create(buf_or.get()->getMemBufferRef()); @@ -762,25 +694,12 @@ LLVMRustOpenArchive(char *path) { OwningBinary *ret = new OwningBinary( std::move(archive_or.get()), std::move(buf_or.get())); -#else - std::error_code err; - Archive *ret = new Archive(std::move(buf_or.get()), err); - if (err) { - LLVMRustSetLastError(err.message().c_str()); - return nullptr; - } -#endif return ret; } -#if LLVM_VERSION_MINOR >= 6 typedef OwningBinary RustArchive; #define GET_ARCHIVE(a) ((a)->getBinary()) -#else -typedef Archive RustArchive; -#define GET_ARCHIVE(a) (a) -#endif extern "C" void LLVMRustDestroyArchive(RustArchive *ar) {