From 2304c25f31fb69c279110ecaf51627cc36bffd55 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 2 Dec 2019 11:35:59 -0800 Subject: Update the minimum external LLVM to 7 LLVM 7 is over a year old, which should be plenty for compatibility. The last LLVM 6 holdout was llvm-emscripten, which went away in #65501. I've also included a fix for LLVM 8 lacking `MemorySanitizerOptions`, which was broken by #66522. --- src/rustllvm/PassWrapper.cpp | 16 +++------------- src/rustllvm/RustWrapper.cpp | 37 ------------------------------------- 2 files changed, 3 insertions(+), 50 deletions(-) (limited to 'src/rustllvm') diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index a116ed282ac..a6b46f40dbc 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -101,11 +101,13 @@ extern "C" LLVMPassRef LLVMRustCreateModuleAddressSanitizerPass(bool Recover) { } extern "C" LLVMPassRef LLVMRustCreateMemorySanitizerPass(int TrackOrigins, bool Recover) { -#if LLVM_VERSION_GE(8, 0) +#if LLVM_VERSION_GE(9, 0) const bool CompileKernel = false; return wrap(createMemorySanitizerLegacyPassPass( MemorySanitizerOptions{TrackOrigins, Recover, CompileKernel})); +#elif LLVM_VERSION_GE(8, 0) + return wrap(createMemorySanitizerLegacyPassPass(TrackOrigins, Recover)); #else return wrap(createMemorySanitizerPass(TrackOrigins, Recover)); #endif @@ -449,9 +451,7 @@ extern "C" void LLVMRustConfigurePassManagerBuilder( LLVMPassManagerBuilderRef PMBR, LLVMRustCodeGenOptLevel OptLevel, bool MergeFunctions, bool SLPVectorize, bool LoopVectorize, bool PrepareForThinLTO, const char* PGOGenPath, const char* PGOUsePath) { -#if LLVM_VERSION_GE(7, 0) unwrap(PMBR)->MergeFunctions = MergeFunctions; -#endif unwrap(PMBR)->SLPVectorize = SLPVectorize; unwrap(PMBR)->OptLevel = fromRust(OptLevel); unwrap(PMBR)->LoopVectorize = LoopVectorize; @@ -558,12 +558,8 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, LLVMPassManagerRef PMR, return LLVMRustResult::Failure; } -#if LLVM_VERSION_GE(7, 0) buffer_ostream BOS(OS); unwrap(Target)->addPassesToEmitFile(*PM, BOS, nullptr, FileType, false); -#else - unwrap(Target)->addPassesToEmitFile(*PM, OS, FileType, false); -#endif PM->run(*unwrap(M)); // Apparently `addPassesToEmitFile` adds a pointer to our on-the-stack output @@ -847,9 +843,7 @@ struct LLVMRustThinLTOData { StringMap ExportLists; StringMap ModuleToDefinedGVSummaries; -#if LLVM_VERSION_GE(7, 0) LLVMRustThinLTOData() : Index(/* HaveGVs = */ false) {} -#endif }; // Just an argument to the `LLVMRustCreateThinLTOData` function below. @@ -920,7 +914,6 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, // combined index // // This is copied from `lib/LTO/ThinLTOCodeGenerator.cpp` -#if LLVM_VERSION_GE(7, 0) auto deadIsPrevailing = [&](GlobalValue::GUID G) { return PrevailingType::Unknown; }; @@ -932,9 +925,6 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, deadIsPrevailing, /* ImportEnabled = */ false); #else computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing); -#endif -#else - computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols); #endif ComputeCrossModuleImport( Ret->Index, diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index e6c45b8e362..a83ba9a8f13 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -88,11 +88,7 @@ extern "C" char *LLVMRustGetLastError(void) { } extern "C" unsigned int LLVMRustGetInstructionCount(LLVMModuleRef M) { -#if LLVM_VERSION_GE(7, 0) return unwrap(M)->getInstructionCount(); -#else - report_fatal_error("Module::getInstructionCount not available before LLVM 7"); -#endif } extern "C" void LLVMRustSetLastError(const char *Err) { @@ -761,14 +757,10 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantPart( LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, LLVMRustDIFlags Flags, LLVMMetadataRef Discriminator, LLVMMetadataRef Elements, const char *UniqueId) { -#if LLVM_VERSION_GE(7, 0) return wrap(Builder->createVariantPart( unwrapDI(Scope), Name, unwrapDI(File), LineNumber, SizeInBits, AlignInBits, fromRust(Flags), unwrapDI(Discriminator), DINodeArray(unwrapDI(Elements)), UniqueId)); -#else - abort(); -#endif } extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateMemberType( @@ -787,7 +779,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantMemberType( const char *Name, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, LLVMValueRef Discriminant, LLVMRustDIFlags Flags, LLVMMetadataRef Ty) { -#if LLVM_VERSION_GE(7, 0) llvm::ConstantInt* D = nullptr; if (Discriminant) { D = unwrap(Discriminant); @@ -796,12 +787,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateVariantMemberType( unwrapDI(File), LineNo, SizeInBits, AlignInBits, OffsetInBits, D, fromRust(Flags), unwrapDI(Ty))); -#else - return wrap(Builder->createMemberType(unwrapDI(Scope), Name, - unwrapDI(File), LineNo, - SizeInBits, AlignInBits, OffsetInBits, - fromRust(Flags), unwrapDI(Ty))); -#endif } extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateLexicalBlock( @@ -911,18 +896,10 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerationType( LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, LLVMMetadataRef Elements, LLVMMetadataRef ClassTy, bool IsScoped) { -#if LLVM_VERSION_GE(7, 0) return wrap(Builder->createEnumerationType( unwrapDI(Scope), Name, unwrapDI(File), LineNumber, SizeInBits, AlignInBits, DINodeArray(unwrapDI(Elements)), unwrapDI(ClassTy), "", IsScoped)); -#else - // Ignore IsScoped on older LLVM. - return wrap(Builder->createEnumerationType( - unwrapDI(Scope), Name, unwrapDI(File), LineNumber, - SizeInBits, AlignInBits, DINodeArray(unwrapDI(Elements)), - unwrapDI(ClassTy), "")); -#endif } extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateUnionType( @@ -1275,34 +1252,20 @@ extern "C" LLVMValueRef LLVMRustBuildMemCpy(LLVMBuilderRef B, LLVMValueRef Dst, unsigned DstAlign, LLVMValueRef Src, unsigned SrcAlign, LLVMValueRef Size, bool IsVolatile) { -#if LLVM_VERSION_GE(7, 0) return wrap(unwrap(B)->CreateMemCpy( unwrap(Dst), DstAlign, unwrap(Src), SrcAlign, unwrap(Size), IsVolatile)); -#else - unsigned Align = std::min(DstAlign, SrcAlign); - return wrap(unwrap(B)->CreateMemCpy( - unwrap(Dst), unwrap(Src), - unwrap(Size), Align, IsVolatile)); -#endif } extern "C" LLVMValueRef LLVMRustBuildMemMove(LLVMBuilderRef B, LLVMValueRef Dst, unsigned DstAlign, LLVMValueRef Src, unsigned SrcAlign, LLVMValueRef Size, bool IsVolatile) { -#if LLVM_VERSION_GE(7, 0) return wrap(unwrap(B)->CreateMemMove( unwrap(Dst), DstAlign, unwrap(Src), SrcAlign, unwrap(Size), IsVolatile)); -#else - unsigned Align = std::min(DstAlign, SrcAlign); - return wrap(unwrap(B)->CreateMemMove( - unwrap(Dst), unwrap(Src), - unwrap(Size), Align, IsVolatile)); -#endif } extern "C" LLVMValueRef -- cgit 1.4.1-3-g733a5